slackware-current/source/ap/lxc/rc.lxc
Patrick J Volkerding d31c50870d Slackware 14.2
Thu Jun 30 20:26:57 UTC 2016
Slackware 14.2 x86_64 stable is released!

The long development cycle (the Linux community has lately been living in
"interesting times", as they say) is finally behind us, and we're proud to
announce the release of Slackware 14.2.  The new release brings many updates
and modern tools, has switched from udev to eudev (no systemd), and adds
well over a hundred new packages to the system.  Thanks to the team, the
upstream developers, the dedicated Slackware community, and everyone else
who pitched in to help make this release a reality.

The ISOs are off to be replicated, a 6 CD-ROM 32-bit set and a dual-sided
32-bit/64-bit x86/x86_64 DVD.  Please consider supporting the Slackware
project by picking up a copy from store.slackware.com.  We're taking
pre-orders now, and offer a discount if you sign up for a subscription.

Have fun!  :-)
2018-05-31 23:31:18 +02:00

63 lines
1.5 KiB
Bash

#!/bin/sh
# rc.lxc init script
# Written by Matteo Bernardini <ponce@slackbuilds.org>
#
# This script checks for the presence of the parameter lxc.start.auto
# in the available container configurations: if it's set to 1 the
# container is started (in an auto-detached screen session if
# screen is available) when rc.lxc is called with the "start" param.
#
# To stop the container it uses lxc-attach to execute /sbin/halt
# inside of it.
. /usr/share/lxc/lxc.functions
start_lxc() {
for CONTAIN in $(/usr/bin/lxc-ls); do
if [ "$(lxc-info -n $CONTAIN -c lxc.start.auto)" = "lxc.start.auto = 1" ]; then
if [ "$(/usr/bin/lxc-info -s -n $CONTAIN | grep STOPPED$)" ]; then
echo "Starting LXC container ${CONTAIN}."
if [ -x /usr/bin/screen ]; then
/usr/bin/screen -dmS init-${CONTAIN} /usr/bin/lxc-start -n $CONTAIN
else
/usr/bin/lxc-start -n $CONTAIN -d
fi
/usr/bin/lxc-wait -n $CONTAIN -s RUNNING
if [ $? -gt 0 ]; then
return 2
fi
fi
fi
done
}
stop_lxc() {
for CONTAIN in $(/usr/bin/lxc-ls --active); do
echo "Stopping LXC container ${CONTAIN}."
/usr/bin/lxc-stop -n $CONTAIN
/usr/bin/lxc-wait -n $CONTAIN -s STOPPED
if [ $? -gt 0 ]; then
return 2
fi
done
}
restart_lxc() {
stop_lxc
sleep 2
start_lxc
}
case "$1" in
'start')
start_lxc
;;
'stop')
stop_lxc
;;
restart)
restart_lxc
;;
*)
echo "usage $0 start|stop|restart"
esac