]> git.pld-linux.org Git - packages/lxd.git/commitdiff
- lxd bridge interface initialization script (FIXME: is it good way to do this?)
authormis <mistoo@gmail.com>
Sun, 21 Aug 2016 16:09:00 +0000 (18:09 +0200)
committermis <mistoo@gmail.com>
Sun, 21 Aug 2016 16:09:00 +0000 (18:09 +0200)
- added %libdir/lxd/rootfs empty dir as lxd refuses start container wihtout

lxdbr.init [new file with mode: 0755]

diff --git a/lxdbr.init b/lxdbr.init
new file mode 100755 (executable)
index 0000000..a0b2bf2
--- /dev/null
@@ -0,0 +1,116 @@
+#!/bin/sh
+#
+# Bridge interface setup for LXD
+#
+# chkconfig:   345 21 81
+#
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+# Get network config
+. /etc/sysconfig/network
+
+# Check that networking is up.
+if is_yes "${NETWORKING}"; then
+       if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+               msg_network_down "lxdbr"
+               exit 1
+       fi
+else
+       exit 0
+fi
+
+[ -f /etc/sysconfig/lxd ] && . /etc/sysconfig/lxd
+
+if [ -z "$BRIDGE_DEV" -o -z "$BRIDGE_IPADDR" ]; then
+       nls "Please configure BRIDGE_IPADDR in /etc/sysconfig/lxd"
+        exit 1
+fi
+
+is_bridge_up() {
+    ip addr show $BRIDGE_DEV 2>/dev/null | grep -q $BRIDGE_IPADDR
+}
+
+start() {
+        if is_bridge_up; then
+               nls "lxd bridge %s is already up" $BRIDGE_DEV
+               return
+       fi
+
+       msg_starting $BRIDGE_DEV
+        busy
+
+        ip link add dev lxdbr0 type bridge
+        ip a add $BRIDGE_IPADDR dev $BRIDGE_DEV
+        ip link set up dev $BRIDGE_DEV
+
+        if is_bridge_up; then
+               ok
+       else
+               fail
+        fi
+}
+
+stop() {
+        if ! is_bridge_up; then
+               nls "lxd bridge %s is already down" $BRIDGE_DEV
+               return
+        fi
+
+       if status --pidfile "/var/run/lxd.pid" lxd lxd >/dev/null; then
+               nls "lxd bridge cannot be down while lxd daemon is running"
+                RETVAL=1
+                return
+        fi
+
+       msg_stopping $BRIDGE_DEV
+        ip link set down dev $BRIDGE_DEV
+        ip link del dev $BRIDGE_DEV
+       ok
+}
+
+condrestart() {
+       if ! is_bridge_up; then
+               nls "lxd bridge %s is down" $BRIDGE_DEV
+               RETVAL=$1
+               return
+       fi
+
+       stop
+       start
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+       start
+       ;;
+  stop)
+       stop
+       ;;
+  restart)
+       stop
+       start
+       ;;
+  try-restart)
+       condrestart 0
+       ;;
+  force-reload)
+       condrestart 7
+       ;;
+  status)
+        st="down"
+        if ip link show $BRIDGE_DEV >/dev/null; then
+               st="up"
+               RETVAL=1
+        fi
+        nls "lxd bridge $BRIDGE_DEV is %s" $st
+       ;;
+  *)
+       msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
+       exit 3
+esac
+
+exit $RETVAL
This page took 0.195857 seconds and 4 git commands to generate.