]> git.proxmox.com Git - pve-manager-legacy.git/blob - bin/init.d/spiceproxy
160311a2bcf610c424c02883a5fa88cdcefff519
[pve-manager-legacy.git] / bin / init.d / spiceproxy
1 #!/bin/sh
2
3 ### BEGIN INIT INFO
4 # Provides: spiceproxy
5 # Required-Start: $remote_fs $network $syslog pveproxy
6 # Required-Stop: $remote_fs $network $syslog pveproxy
7 # Default-Start: 2 3 4 5
8 # Default-Stop: 0 1 6
9 # Short-Description: PVE SPICE Proxy Server
10 ### END INIT INFO
11
12 . /lib/lsb/init-functions
13
14 PATH=/sbin:/bin:/usr/bin:/usr/sbin
15 DAEMON=/usr/bin/spiceproxy
16 NAME=spiceproxy
17 DESC="PVE SPICE Proxy Server"
18 RUNDIR=/var/run/pveproxy
19 PIDFILE=${RUNDIR}/spiceproxy.pid
20
21 test -f $DAEMON || exit 0
22
23 # avoid warnings about uninstalled locales when pveproxy executes commands
24 export LC_ALL="C"
25
26 mkdir -p ${RUNDIR} || true
27 chmod 0700 ${RUNDIR} || true
28 chown www-data:www-data ${RUNDIR} || true
29
30 DAEMON_OPTS=""
31
32 # Include defaults if available
33 if [ -f /etc/default/$NAME ] ; then
34 ALLOW_FROM=""
35 DENY_FROM=""
36 POLICY=""
37
38 . /etc/default/$NAME
39
40 if [ -n "$ALLOW_FROM" ] ; then
41 DAEMON_OPTS="${DAEMON_OPTS} --allow-from ${ALLOW_FROM}"
42 fi
43
44 if [ -n "$DENY_FROM" ] ; then
45 DAEMON_OPTS="${DAEMON_OPTS} --deny-from ${DENY_FROM}"
46 fi
47
48 if [ -n "$POLICY" ] ; then
49 DAEMON_OPTS="${DAEMON_OPTS} --policy $POLICY"
50 fi
51 fi
52
53
54 case "$1" in
55 start)
56 log_daemon_msg "Starting $DESC" "$NAME"
57 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- ${DAEMON_OPTS}
58 log_end_msg $?
59 ;;
60 stop)
61 log_daemon_msg "Stopping $DESC" "$NAME"
62 start-stop-daemon --stop --quiet --retry TERM/2/TERM/15/KILL/2 --pidfile $PIDFILE
63 log_end_msg $?
64 ;;
65 reload)
66 log_daemon_msg "Reloading $DESC" "$NAME"
67 if ( [ -e $PIDFILE ] && kill -0 `cat $PIDFILE`) then
68 start-stop-daemon --stop --signal HUP --pidfile $PIDFILE
69 else
70 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- ${DAEMON_OPTS}
71 fi
72 log_end_msg $?
73 ;;
74 restart|force-reload)
75 log_daemon_msg "Restarting $DESC" "$NAME"
76 start-stop-daemon --stop --quiet --retry TERM/2/TERM/15/KILL/2 --pidfile $PIDFILE
77 sleep 2
78 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- ${DAEMON_OPTS}
79 log_end_msg $?
80 ;;
81 *)
82 N=/etc/init.d/$NAME
83 echo "Usage: $N {start|stop|restart|force-reload}"
84 exit 1
85 ;;
86 esac
87
88 exit 0