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