forked from Skycrab/Linux-C-Web-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebserver.sh
74 lines (61 loc) · 746 Bytes
/
webserver.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#/bin/bash
PName='webd'
Grep='grep'
Echo='echo'
Skill='skill'
Running=0
run()
{
Command=`ps aux | grep -v grep | grep -c $PName `
if [ $Command -eq 0 ];then
Running=0
else
Running=1
fi
}
start()
{
run
if [ $Running -eq 0 ];then
./$PName
$Echo "$PName is running"
else
$Echo "$PName is running"
fi
}
stop()
{
run
if [ $Running -eq 1 ];then
$Skill -KILL $PName
$Echo "$PName is stopped"
else
$Echo "$PName is stopped"
fi
}
status()
{
run
if [ $Running -eq 0 ];then
$Echo "$PName is stopped"
else
$Echo "$PName is running"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop && start
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac