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 if [ -n "$BRIDGE_DEV" ]; then
41 if ! ip link show $BRIDGE_DEV 2>/dev/null | grep -q ",UP,"; then
42 nls "lxd bridge %s is down, start lxdbr service first" "$BRIDGE_DEV"
49 daemon --fork --waitforname lxd /usr/sbin/lxd daemon $OPTIONS
51 # lxd does not write pidfile, so create one
52 show "Checking lxd daemon status"
56 while [ -z "$pid" -a $ntry -lt 5 ]; do
57 [ -z "$pid" ] && sleep 1
58 pid=$(lxc info 2>/dev/null | awk '/serverpid:/{print $2}')
59 [ -n "$pid" ] && echo $pid > $pidfile
63 if [ -n "$pid" ]; then
64 touch /var/lock/subsys/lxd
74 if [ ! -f /var/lock/subsys/lxd ]; then
81 /usr/sbin/lxd shutdown
84 if status --pidfile $pidfile lxd lxd >/dev/null; then
85 killproc --pidfile $pidfile lxd
89 rm -f /var/lock/subsys/lxd
93 if [ ! -f /var/lock/subsys/lxd ]; then
104 # See how we were called.
123 status --pidfile $pidfile lxd lxd
127 msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"