-
Notifications
You must be signed in to change notification settings - Fork 0
/
case.sh
executable file
·108 lines (102 loc) · 1.3 KB
/
case.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
PIDFILE=1234
haproxy_start(){
echo "haproxy started"
}
haproxy_stop(){
echo "haproxy stoped"
}
haproxy_reload(){
echo "haproxy reload success"
}
haproxy_restart()
{
haproxy_stop
haproxy_start
}
haproxy_status(){
echo 'running pid ' $PIDFILE
}
case "$1" in
start)
echo "Starting haproxy" "haproxy"
haproxy_start
ret=$?
case "$ret" in
0)
echo 0
;;
1)
echo 1
echo "pid file '$PIDFILE' found, haproxy not started."
;;
2)
echo 1
;;
esac
exit $ret
;;
stop)
echo "Stopping haproxy" "haproxy"
haproxy_stop
ret=$?
case "$ret" in
0|1)
echo 0
;;
2)
echo 1
;;
esac
exit $ret
;;
reload|force-reload)
echo "Reloading haproxy" "haproxy"
haproxy_reload
case "$?" in
0|1)
echo 0
;;
2)
echo 1
;;
esac
;;
restart)
log_daemon_msg "Restarting haproxy" "haproxy"
haproxy_stop
haproxy_start
case "$?" in
0)
echo 0
;;
1)
echo 1
;;
2)
echo 1
;;
esac
;;
status)
haproxy_status
ret=$?
case "$ret" in
0)
echo "haproxy is running."
;;
1)
echo "haproxy dead, but $PIDFILE exists."
;;
*)
echo "haproxy not running."
;;
esac
exit $ret
;;
*)
echo "Usage: /etc/init.d/haproxy {start|stop|reload|restart|status}"
exit 2
;;
esac
: