aboutsummaryrefslogtreecommitdiffstats
path: root/main/lxc/lxc.initd
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2014-12-02 10:34:28 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2014-12-02 10:36:04 +0000
commit60f848e0d35df7c3dc69de560dbab69e71f9a71f (patch)
tree4def071b9f80062c6fb94a70099d485ee40317bf /main/lxc/lxc.initd
parent862c741a3ccc0936ce80840bad3937dec6a52c4d (diff)
downloadaports-60f848e0d35df7c3dc69de560dbab69e71f9a71f.tar.bz2
aports-60f848e0d35df7c3dc69de560dbab69e71f9a71f.tar.xz
main/lxc: add support for lxc's autostart feature
this makes it possible to mark which containers you want to be autostarted in the container config and then use /etc/init.d/lxc start to start them all same with stop/reboot.
Diffstat (limited to 'main/lxc/lxc.initd')
-rw-r--r--main/lxc/lxc.initd27
1 files changed, 24 insertions, 3 deletions
diff --git a/main/lxc/lxc.initd b/main/lxc/lxc.initd
index 1b348894d4..db4a149618 100644
--- a/main/lxc/lxc.initd
+++ b/main/lxc/lxc.initd
@@ -35,9 +35,8 @@ lxc_get_var() {
checkconfig() {
if [ ${CONTAINER} = ${SVCNAME} ]; then
- eerror "You have to create an init script for each container:"
- eerror " ln -s lxc /etc/init.d/lxc.container"
- return 1
+ CONTAINER=
+ return 0
fi
CONFIGFILE=${CONFIGFILE:-$(lxc_get_configfile)}
@@ -52,8 +51,20 @@ checkconfig() {
fi
}
+_autostart() {
+ ebegin "$1 LXC containers"
+ shift
+ lxc-autostart --group "${LXC_GROUP:-onboot,}" "$@"
+ eend $?
+}
+
start() {
checkconfig || return 1
+ if [ -z "$CONTAINER" ]; then
+ _autostart "Starting"
+ return
+ fi
+
rm -f /var/log/lxc/${CONTAINER}.log
rootpath=$(lxc_get_var lxc.rootfs)
@@ -75,6 +86,10 @@ start() {
stop() {
checkconfig || return 1
+ if [ -z "$CONTAINER" ]; then
+ _autostart "Stopping" --shutdown --timeout ${LXC_TIMEOUT:-30}
+ return
+ fi
ebegin "Stopping container ${CONTAINER}"
start-stop-daemon --stop --pidfile ${pidfile} \
@@ -85,8 +100,14 @@ stop() {
reboot() {
checkconfig || return 1
+ if [ -z "$CONTAINER" ]; then
+ _autostart "Rebooting" --reboot
+ return
+ fi
+
ebegin "Sending reboot signal to container $CONTAINER"
start-stop-daemon --signal ${RESTART_SIG:-SIGTERM} \
--pidfile ${pidfile}
eend $?
}
+