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"
41 daemon --fork --waitforname lxd /usr/lib/lxd-wrapper daemon $OPTIONS
43 # lxd does not write pidfile, so create one
44 show "Checking lxd daemon status"
48 while [ -z "$pid" -a $ntry -lt 5 ]; do
49 [ -z "$pid" ] && sleep 1
50 pid=$(lxc info 2>/dev/null | awk '/server_pid:/{print $2}')
51 [ -n "$pid" ] && echo $pid > $pidfile
55 if [ -n "$pid" ]; then
56 touch /var/lock/subsys/lxd
66 if [ ! -f /var/lock/subsys/lxd ]; then
73 /usr/sbin/lxd shutdown
76 if status --pidfile $pidfile lxd lxd >/dev/null; then
77 killproc --pidfile $pidfile lxd
81 rm -f /var/lock/subsys/lxd
85 if [ ! -f /var/lock/subsys/lxd ]; then
96 # See how we were called.
115 status --pidfile $pidfile lxd lxd
119 msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"