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