updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / nginx-devel / nginx
blob9de10e99a85c61827c1b5424157d117978d2e8f2
1 #!/bin/bash
3 # general config
5 NGINX_CONFIG="/etc/nginx/conf/nginx.conf"
7 . /etc/conf.d/nginx
8 . /etc/rc.conf
9 . /etc/rc.d/functions
11 function check_config {
12 stat_busy "Checking configuration"
13 /usr/sbin/nginx -t -q -c "$NGINX_CONFIG"
14 if [ $? -ne 0 ]; then
15 stat_die
16 else
17 stat_done
21 case "$1" in
22 start)
23 check_config
24 $0 careless_start
26 careless_start)
27 stat_busy "Starting Nginx"
28 if [ -s /var/run/nginx.pid ]; then
29 stat_fail
30 # probably ;)
31 stat_busy "Nginx is already running"
32 stat_die
34 /usr/sbin/nginx -c "$NGINX_CONFIG" &>/dev/null
35 if [ $? -ne 0 ]; then
36 stat_fail
37 else
38 add_daemon nginx
39 stat_done
42 stop)
43 stat_busy "Stopping Nginx"
44 NGINX_PID=`cat /var/run/nginx.pid 2>/dev/null`
45 kill -QUIT $NGINX_PID &>/dev/null
46 if [ $? -ne 0 ]; then
47 stat_fail
48 else
49 for i in `seq 1 10`; do
50 [ -d /proc/$NGINX_PID ] || { stat_done; rm_daemon nginx; exit 0; }
51 sleep 1
52 done
53 stat_fail
56 restart)
57 check_config
58 $0 stop
59 sleep 1
60 $0 careless_start
62 reload)
63 check_config
64 if [ -s /var/run/nginx.pid ]; then
65 status "Reloading Nginx Configuration" kill -HUP `cat /var/run/nginx.pid`
68 check)
69 check_config
72 echo "usage: $0 {start|stop|restart|reload|check|careless_start}"
73 esac