dstrelau (owner)

Revisions

gist: 179117 Download_button fork
public
Public Clone URL: git://gist.github.com/179117.git
Embed All Files: show embed
Text #
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
#!/bin/sh
 
NAME=nginx
DESC=nginx
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/sbin/nginx
DAEMON_ARGS=""
CONFIG=/etc/nginx/nginx.conf
PID_FILE="/var/run/${NAME}.pid"
 
set -e
 
# Check if DAEMON binary exist
test -x $DAEMON || exit 0
 
# Include nginx defaults if available
test -f /etc/default/nginx && . /etc/default/nginx
 
d_start() {
start-stop-daemon --start --quiet \
--pidfile $PID_FILE --exec $DAEMON -- $DAEMON_ARGS
}
 
d_stop() {
start-stop-daemon --stop --quiet --signal QUIT \
--pidfile $PID_FILE --exec $DAEMON --retry 5
}
 
d_reload() {
start-stop-daemon --stop --quiet --signal HUP \
--pidfile $PID_FILE --exec $DAEMON
}
 
case "$1" in
start)
echo -n "Starting $DESC: "
d_start && echo "success." || echo "failure."
;;
stop)
echo -n "Stopping $DESC: "
d_stop && echo "success." || echo "failure."
;;
restart|force-reload)
echo -n "Restarting $DESC: "
(d_stop && sleep 1 && d_start && echo "success.") || echo "failure."
;;
reload)
echo -n "Reloading $DESC configuration: "
($DAEMON -t && d_reload && echo "success.") || echo "failure."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
exit 1
;;
esac
 
exit 0