lxc-slackware.in revision 2c0f32e6432f24dcc698d8fe0bd84d83a3588bdc
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# lxc: linux Container library
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# Daniel Lezcano <daniel.lezcano@free.fr>
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# Template for slackware by Matteo Bernardini <ponce@slackbuilds.org>
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# some parts are taken from the debian one (used as model)
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# This library is free software; you can redistribute it and/or
300e4e43ed1ca46d0614459161ca2fb460ef661aTimo Sirainen# modify it under the terms of the GNU Lesser General Public
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# License as published by the Free Software Foundation; either
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# version 2.1 of the License, or (at your option) any later version.
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# This library is distributed in the hope that it will be useful,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# but WITHOUT ANY WARRANTY; without even the implied warranty of
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# Lesser General Public License for more details.
3f3ad16ff74d694796d22501250a9a29997c0729Timo Sirainen# You should have received a copy of the GNU Lesser General Public
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# License along with this library; if not, write to the Free Software
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# Detect use under userns (unsupported)
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen if [ "$arg" = "--mapped-uid" -o "$arg" = "--mapped-gid" ]; then
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen echo "This template can't be used for unprivileged containers." 1>&2
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen echo "You may want to try the \"download\" template instead." 1>&2
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# Add some directories to PATH in case we create containers with sudo
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# Use the primary Slackware site by default, but please consider changing
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# this to a closer mirror site.
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo SirainenMIRROR=${MIRROR:-http://ftp.slackware.com/pub/slackware}
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenif [ -z "$arch" ]; then
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# The next part contains excerpts taken from SeTconfig (written by
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# Patrick Volkerding) from the slackware setup disk.
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# But before pasting them just set a variable to use them as they are
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen( cd $T_PX ; chmod 755 ./ )
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen( cd $T_PX ; chmod 755 ./var )
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenif [ -d $T_PX/usr/src/linux ]; then
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenif [ ! -d $T_PX/proc ]; then
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenif [ ! -d $T_PX/sys ]; then
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenif [ ! -d $T_PX/var/spool/mail ]; then
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenecho "# Load the keyboard map. More maps are in /usr/share/kbd/keymaps." \
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenecho "if [ -x /usr/bin/loadkeys ]; then" >> $T_PX/etc/rc.d/rc.keymap
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenecho " /usr/bin/loadkeys us" >> $T_PX/etc/rc.d/rc.keymap
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# Network configuration is left to the user, that have to edit
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# /etc/rc.d/rc.inet1.conf and /etc/resolv.conf of the container
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# just set the hostname
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen$hostname.example.net
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# make needed devices, from Chris Willing's MAKEDEV.sh
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# http://www.vislab.uq.edu.au/howto/lxc/MAKEDEV.sh
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenmknod -m 666 ${DEV}/null c 1 3
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenmknod -m 666 ${DEV}/zero c 1 5
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenmknod -m 666 ${DEV}/random c 1 8
cf9d67e4a9bfee31cf3be05244555d51a3d1b9feTimo Sirainenmknod -m 666 ${DEV}/urandom c 1 9
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenmknod -m 666 ${DEV}/tty c 5 0
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenmknod -m 600 ${DEV}/console c 5 1
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenmknod -m 666 ${DEV}/tty0 c 4 0
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenmknod -m 666 ${DEV}/tty1 c 4 1
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenmknod -m 666 ${DEV}/tty2 c 4 2
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenmknod -m 666 ${DEV}/tty3 c 4 3
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenmknod -m 666 ${DEV}/tty4 c 4 4
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenmknod -m 666 ${DEV}/tty5 c 4 5
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenmknod -m 666 ${DEV}/full c 1 7
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenmknod -m 660 ${DEV}/loop0 b 7 0
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenmknod -m 660 ${DEV}/loop1 b 7 1
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainennone /run tmpfs defaults,mode=0755 0 0
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# simplify rc.6 and rc.S, http://www.vislab.uq.edu.au/howto/lxc/create_container.html
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# and some other small fixes for a clean boot
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen--- ./etc/rc.orig/rc.6 2012-08-15 01:03:12.000000000 +0200
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen+++ ./etc/rc.d/rc.6 2013-02-17 10:26:30.888839354 +0100
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen@@ -9,6 +9,12 @@
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen # Author: Miquel van Smoorenburg <miquels@drinkel.nl.mugnet.org>
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen # Modified by: Patrick J. Volkerding, <volkerdi@slackware.com>
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen+# by Matteo Bernardini <ponce@slackbuilds.org>,
cf9d67e4a9bfee31cf3be05244555d51a3d1b9feTimo Sirainen+# a check for a container variable is made to jump sections
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen@@ -37,6 +43,9 @@
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen # Save the system time to the hardware clock using hwclock --systohc.
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen if [ -x /sbin/hwclock ]; then
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen # Check for a broken motherboard RTC clock (where ioports for rtc are
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen@@ -53,6 +62,8 @@
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen if [ -x /etc/rc.d/rc.local_shutdown ]; then
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen@@ -148,6 +159,9 @@
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen if [ -x /etc/rc.d/rc.pcmcia ]; then
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen@@ -155,11 +169,16 @@
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen if [ -x /sbin/accton -a -r /var/log/pacct ]; then
read junk;
. /etc/rc.d/rc.sysvinit
if [ -f /etc/random-seed ]; then
if [ -r /proc/sys/kernel/dmesg_restrict ]; then
# restart rc.inet1 to have routing for the loop device
# add a message to rc.local that confirms successful container startup
rootfs=$1
rootfs=$1
flock -n -x 9
if [ $? -ne 0 ]; then
sed -i \
path=$1
rootfs=$2
name=$3
if [ $? -ne 0 ]; then
if [ ! -e $cache ]; then
flock -n -x 9
cat <<EOF
eval set -- "$options"
type installpkg
type slackpkg
if [ -z "$path" ]; then
if [ -z "$name" ]; then
if [ -z "$rootfs" ]; then
if [ ! -z $clean ]; then