]> git.proxmox.com Git - pve-manager.git/blob - bin/init.d/pveproxy
run pveproxy as unpriviledged user (www-data)
[pve-manager.git] / bin / init.d / pveproxy
1 #!/bin/sh
2
3 ### BEGIN INIT INFO
4 # Provides: pveproxy
5 # Required-Start: $remote_fs $network $syslog pvedaemon
6 # Required-Stop: $remote_fs $network $syslog pvedaemon
7 # Default-Start: 2 3 4 5
8 # Default-Stop: 0 1 6
9 # Short-Description: PVE API 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/pveproxy
16 NAME=pveproxy
17 DESC="PVE API Proxy Server"
18 RUNDIR=/var/run/pveproxy
19 PIDFILE=${RUNDIR}/pveproxy.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 case "$1" in
31 start)
32 log_daemon_msg "Starting $DESC" "$NAME"
33 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON
34 log_end_msg $?
35 ;;
36 stop)
37 log_daemon_msg "Stopping $DESC" "$NAME"
38 start-stop-daemon --stop --quiet --retry TERM/2/TERM/10/KILL/2 --pidfile $PIDFILE
39 log_end_msg $?
40 ;;
41 reload)
42 log_daemon_msg "Reloading $DESC" "$NAME"
43 if ( [ -e $PIDFILE ] && kill -0 `cat $PIDFILE`) then
44 start-stop-daemon --stop --signal HUP --pidfile $PIDFILE
45 else
46 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON
47 fi
48 log_end_msg $?
49 ;;
50 restart|force-reload)
51 log_daemon_msg "Restarting $DESC" "$NAME"
52 start-stop-daemon --stop --quiet --retry TERM/2/TERM/10/KILL/2 --pidfile $PIDFILE
53 sleep 2
54 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON
55 log_end_msg $?
56 ;;
57 *)
58 N=/etc/init.d/$NAME
59 echo "Usage: $N {start|stop|restart|force-reload}"
60 exit 1
61 ;;
62 esac
63
64 exit 0