source: WAeUP_SysConf/nginx/trunk/init.d/nginx @ 2841

Last change on this file since 2841 was 2621, checked in by uli, 17 years ago

Import system config for nginx.

  • Property svn:executable set to *
File size: 2.9 KB
Line 
1#!/bin/sh
2PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
3DAEMON=/usr/sbin/nginx
4NAME=nginx
5DESC="High-performance web-server"
6
7test -x $DAEMON || exit 0
8
9set -e
10
11# check if nginx is configured or not
12if [ -f "/etc/default/nginx" ]
13then
14  . /etc/default/nginx
15  if [ "$startup" != "1" ]
16  then
17    echo "nginx won't start unconfigured. configure & set startup=1 in /etc/default/nginx"
18    exit 0
19  fi
20
21  # Find the right config...
22  SITE1="0"
23  SITE2="0"
24  case "$1" in
25      -muniben)
26          SITE1="1"
27          shift
28          ;;
29      -mfceokene)
30          SITE2="1"
31          shift
32          ;;
33      -h*)
34          echo "usage: $0 [-muniben] [-mfceokene] start|stop|restart|reload"
35          exit 0
36          ;;
37      help)
38          echo "usage: $0 [-muniben] [-mfceokene] start|stop|restart|reload"
39          exit 0
40          ;;
41  esac
42  case "$1" in
43      -muniben)
44          SITE1="1"
45          shift
46          ;;
47      -mfceokene)
48          SITE2="1"
49          shift
50          ;;
51  esac
52  CONF=$SITE1$SITE2
53  case $CONF in
54      "00")
55          echo "Disabling maintenance mode for uniben."
56          echo "Disabling maintenance mode for fceokene."
57          DAEMON_OPTS="-c /etc/nginx/nginx.conf"
58          ;;
59      "01")
60          echo "Disabling maintenance mode for uniben."
61          echo "Enabling maintenance mode for fceokene."
62          DAEMON_OPTS="-c /etc/nginx/maintenance-fceokene.conf"
63          ;;
64      "10")
65          echo "Enabling maintenance mode for uniben."
66          echo "Disabling maintenance mode for fceokene."
67          DAEMON_OPTS="-c /etc/nginx/maintenance-uniben.conf"
68          ;;
69      "11")
70          echo "Enabling maintenance mode for uniben."
71          echo "Enabling maintenance mode for fceokene."
72          DAEMON_OPTS="-c /etc/nginx/maintenance-all.conf"
73          ;;
74  esac
75
76else
77  echo "/etc/default/nginx not found"
78  exit 0
79fi
80
81
82test_config() {
83        if ! $DAEMON -t 2> /dev/null
84        then
85                printf "Configuration syntax error detected. Not reloading.\n\n"
86                $DAEMON -t
87                exit 1
88        fi
89}
90
91case "$1" in
92  start)
93        echo -n "Starting $DESC: "
94        start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
95                --exec $DAEMON -- $DAEMON_OPTS
96        echo "$NAME."
97        exit 0;
98        ;;
99  stop)
100        echo -n "Stopping $DESC: "
101        start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile /var/run/$NAME.pid \
102                --exec $DAEMON
103        echo "$NAME."
104        ;;
105  reload)
106        echo "Reloading $DESC configuration files."
107        test_config
108        start-stop-daemon --stop --signal HUP --quiet --pidfile \
109                /var/run/$NAME.pid --exec $DAEMON
110        ;;
111  rotate-logs)
112        echo "Reopen $DESC logfiles"
113        start-stop-daemon --stop --signal USR1 --quiet --pidfile \
114                /var/run/$NAME.pid --exec $DAEMON
115  ;;
116  restart|force-reload)
117        echo -n "Restarting $DESC: "
118       
119        test_config
120        start-stop-daemon --stop --quiet --pidfile \
121                /var/run/$NAME.pid --exec $DAEMON
122        sleep 1
123        start-stop-daemon --start --quiet --pidfile \
124                /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
125        echo "$NAME."
126        ;;
127  *)
128        N=/etc/init.d/$NAME
129        # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
130        echo "Usage: $N {start|stop|reload|rotate-logs}" >&2
131        exit 1
132        ;;
133esac
134
135exit 0
Note: See TracBrowser for help on using the repository browser.