Merge branch 'org.openembedded.dev' of git@git.openembedded.net:openembedded into...
[vuplus_openembedded] / packages / mini-httpd / files / init
1 #! /bin/sh
2
3 # Globals
4 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
5 DAEMON=/usr/sbin/mini_httpd
6 NAME=mini-httpd
7 DESC="web server"
8 # Additional options that are passed to the Daemon.
9 DAEMON_OPTS="-C /etc/mini-httpd.conf"
10
11 test -x $DAEMON || exit 0
12
13 # Include mini-httpd defaults if available
14 if [ -f /etc/default/mini-httpd ]
15 then
16         . /etc/default/mini-httpd
17 fi
18
19 set -e
20
21 case "$1" in
22   start)
23         echo -n "Starting $DESC: "
24         start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
25                 --exec $DAEMON -- $DAEMON_OPTS
26         echo "$NAME."
27         ;;
28
29   stop)
30         echo -n "Stopping $DESC: "
31         # Get pid number
32         if [ -e /var/run/$NAME.pid ]
33         then
34                 PID=`cat /var/run/$NAME.pid`
35                 if [ -d /proc/$PID ]
36                 then
37                         start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid
38                 else
39                         # we need to remove the pidfile manually
40                         if [ -e /var/run/$NAME.pid ]
41                         then
42                                 rm -f /var/run/$NAME.pid
43                         fi
44                 fi
45         fi
46         echo "$NAME."
47         ;;
48
49   restart|force-reload)
50         echo -n "Restarting $DESC: "
51         if [ "$START" = "0" ]
52         then
53                 start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
54                         --exec $DAEMON -- $DAEMON_OPTS
55         fi
56         sleep 1
57         start-stop-daemon --start --quiet --pidfile \
58                 /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
59         echo "$NAME."
60         ;;
61
62   *)
63         N=/etc/init.d/$NAME
64         echo "Usage: $N {start|stop|restart|force-reload}" >&2
65         exit 1
66         ;;
67 esac
68
69 exit 0
70