]> git.proxmox.com Git - mirror_lxcfs.git/blob - config/init/sysvinit/lxcfs
config: Adds reload mode to sysvinit and systemd scripts.
[mirror_lxcfs.git] / config / init / sysvinit / lxcfs
1 #! /bin/sh
2
3 ### BEGIN INIT INFO
4 # Short-Description: FUSE filesystem for LXC
5 # Description: FUSE filesystem for LXC
6 # Provides: lxcfs
7 # Required-Start: $remote_fs
8 # Required-Stop: $remote_fs
9 # Should-Start: cgroupfs-mount
10 # Should-Stop: cgroupfs-mount
11 # Default-Start: 2 3 4 5
12 # Default-Stop: 0 1 6
13 ### END INIT INFO
14
15 DAEMON=/usr/bin/lxcfs
16 NAME=lxcfs
17 DESC="FUSE filesystem for LXC"
18 PIDFILE=/var/run/lxcfs.pid
19
20 . /lib/lsb/init-functions
21
22 test -f ${DAEMON} || exit 0
23
24 set -e
25
26 START="-m --start --quiet --pidfile ${PIDFILE} --name ${NAME} --startas $DAEMON --background"
27 case "$1" in
28 start)
29 if init_is_upstart; then
30 exit 1
31 fi
32
33 # Don't start if bind-mounted from host
34 [ ! -d /var/lib/lxcfs/proc ] || exit 0
35
36 # Cleanup in case of crash
37 fusermount -u /var/lib/lxcfs 2> /dev/null || true
38 [ -L /etc/mtab ] || \
39 sed -i "/^lxcfs \/var\/lib\/lxcfs fuse.lxcfs/d" /etc/mtab
40
41 echo -n "Starting $DESC: "
42 if start-stop-daemon ${START} -- /var/lib/lxcfs >/dev/null 2>&1 ; then
43 echo "${NAME}."
44 else
45 if start-stop-daemon --test ${START} >/dev/null 2>&1; then
46 echo "(failed)."
47 exit 1
48 else
49 echo "${DAEMON} already running."
50 exit 0
51 fi
52 fi
53
54 exit 0
55 ;;
56
57 stop)
58 if init_is_upstart; then
59 exit 0
60 fi
61 echo -n "Stopping $DESC: "
62 if start-stop-daemon --stop --quiet --pidfile ${PIDFILE} \
63 --startas ${DAEMON} --retry 10 --name ${NAME} \
64 >/dev/null 2>&1 ; then
65 echo "${NAME}."
66 else
67 if start-stop-daemon --test ${START} >/dev/null 2>&1; then
68 echo "(not running)."
69 exit 0
70 else
71 echo "(failed)."
72 exit 1
73 fi
74 fi
75
76 exit 0
77 ;;
78
79 status)
80 if init_is_upstart; then
81 exit 0
82 fi
83 status_of_proc -p ${PIDFILE} "${DAEMON}" lxcfs
84 ;;
85
86 reload)
87 if init_is_upstart; then
88 exit 1
89 fi
90 kill -USR1 $(cat ${PIDFILE})
91 ;;
92
93 restart|force-reload)
94 if init_is_upstart; then
95 exit 1
96 fi
97 $0 stop
98 exec $0 start
99 ;;
100
101 *)
102 echo "Usage: $0 {start|stop|restart|force-reload}" 1>&2
103 exit 1
104 ;;
105 esac