updated on Wed Jan 18 08:00:29 UTC 2012
[aur-mirror.git] / nginx-svn / nginx.sh
blobbe52bd9d4392e78f867438984d04e8d6e2b60f42
1 #!/bin/bash
3 . /etc/rc.conf
4 . /etc/rc.d/functions
5 . /etc/conf.d/nginx
7 PID="/var/run/nginx/nginx.pid"
8 [ -z "$NGINX_CONFIG" ] && NGINX_CONFIG="/etc/nginx/nginx.conf"
10 function check_config {
11 stat_busy "Checking configuration"
12 /usr/sbin/nginx -q -t -c "$NGINX_CONFIG"
13 if [ $? -ne 0 ]; then
14 stat_die
15 else
16 stat_done
20 case "$1" in
21 start)
22 [ "$_nocheck" ] && check_config
23 stat_busy "Starting Nginx"
24 if [ -s "$PID" ]; then
25 stat_fail
26 # probably ;)
27 stat_busy "Nginx is already running"
28 stat_die
30 /usr/sbin/nginx -c "$NGINX_CONFIG" &>/dev/null
31 if [ $? -ne 0 ]; then
32 stat_fail
33 else
34 add_daemon nginx
35 stat_done
38 stop)
39 stat_busy "Stopping Nginx"
40 kill -QUIT `cat "$PID"` &>/dev/null
41 if [ $? -ne 0 ]; then
42 stat_fail
43 else
44 rm_daemon nginx
45 stat_done
48 restart)
49 check_config
50 $0 stop
51 sleep 1
52 _nocheck=1
53 $0 start
55 reload)
56 check_config
57 if [ -s "$PID" ]; then
58 status "Reloading Nginx Configuration" kill -HUP `cat "$PID"`
61 upgrade)
62 check_config
63 if [ -s "$PID" ]; then
64 status "Upgrading Nginx" kill -USR2 `cat "$PID"`
66 sleep 1
67 if [ -f "${PID}.oldbin" ]; then
68 status "Stopping old Nginx" kill -QUIT `cat "${PID}.oldbin"`
71 check)
72 check_config
75 echo "usage: $0 {start|stop|restart|reload|upgrade|check}"
76 esac