3 # Container hypervisor and a new user experience for LXC
8 # pidfile: /var/run/lxd.pid
11 # Source function library
12 . /etc/rc.d/init.d/functions
15 . /etc/sysconfig/network
17 # Check that networking is up.
18 if is_yes "${NETWORKING}"; then
19 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
20 msg_network_down "lxd"
27 # Get service config - may override defaults
28 [ -f /etc/sysconfig/lxd ] && . /etc/sysconfig/lxd
29 OPTIONS="$OPTIONS --group lxd --logfile /var/log/lxd/lxd.log"
31 pidfile="/var/run/lxd.pid"
34 if status --pidfile $pidfile lxd lxd >/dev/null; then
35 msg_already_running "lxd"
40 daemon --fork --waitforname lxd /usr/sbin/lxd daemon $OPTIONS
42 # lxd does not write pidfile, so create one
43 show "Checking lxd daemon status"
47 while [ -z "$pid" -a $ntry -lt 5 ]; do
48 [ -z "$pid" ] && sleep 1
49 pid=$(lxc info | awk '/serverpid:/{print $2}')
50 [ -n "$pid" ] && echo $pid > $pidfile
54 if [ -n "$pid" ]; then
55 touch /var/lock/subsys/lxd
65 if [ ! -f /var/lock/subsys/lxd ]; then
72 /usr/sbin/lxd shutdown
75 if status --pidfile $pidfile lxd lxd >/dev/null; then
76 killproc --pidfile $pidfile lxd
80 rm -f /var/lock/subsys/lxd
84 if [ ! -f /var/lock/subsys/lxd ]; then
95 # See how we were called.
114 status --pidfile $pidfile lxd lxd
118 msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"