Commits

M0E-lnx  committed 2d1b74f

Merged changes to init system into the template to avoid dependency on external files. Added flexibility to create 7.0 and 7.1 containers with the same template

  • Participants
  • Parent commits 06e496a

Comments (0)

Files changed (6)

File src/inittab

-#/etc/inittab
-# inittab	This file describes how the INIT process should set up
-#		the system in a certain run-level.
-#
-# Version:	@(#)inittab		2.04	17/05/93	MvS
-#                                       2.10    02/10/95        PV
-#                                       3.00    02/06/1999      PV
-#                                       4.00    04/10/2002      PV
-#                                      13.37    2011-03-25      PJV
-#
-# Author:	Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
-# Modified by:	Patrick J. Volkerding, <volkerdi@slackware.com>
-#
-
-# These are the default runlevels in Slackware:
-#   0 = halt
-#   1 = single user mode
-#   2 = unused (but configured the same as runlevel 3)
-#   3 = multiuser mode (default Slackware runlevel)
-#   4 = X11 with KDM/GDM/XDM (session managers)
-#   5 = unused (but configured the same as runlevel 3)
-#   6 = reboot
-
-# Default runlevel. (Do not set to 0 or 6)
-id:3:initdefault:
-
-# System initialization (runs when system boots).
-si:S:sysinit:/etc/rc.d/rc.S
-
-# Script to run when going single user (runlevel 1).
-su:1S:wait:/etc/rc.d/rc.K
-
-# Script to run when going multi user.
-rc:2345:wait:/etc/rc.d/rc.M
-
-# Runlevel 0 halts the system.
-l0:0:wait:/etc/rc.d/rc.0
-
-# Runlevel 6 reboots the system.
-l6:6:wait:/etc/rc.d/rc.6
-
-
-# These are the standard console login getties in multiuser mode:
-c1:12345:respawn:/sbin/mingetty tty1
-c2:12345:respawn:/sbin/mingetty tty2
-
-
-# End of /etc/inittab

File src/lxc-vector

 #!/bin/bash
 
 VL_ARCH=${VL_ARCH:-"i586"}
-VL_VERSION=${VL_VERSION:-"7.0"}
-SYSFILES="file:///home/vluser/lxc-vectorlinux"
+VL_VERSION=${VL_VERSION:-"7.1"}
+VL_CACHE=${VL_CACHE:-"/var/lib/lxc/cache"}
 
-if [ "$VL_ARCH"=="i?86" ]; then
-	REPO_RELDIR="veclinux-$VL_VERSION"
-elif [ "$VL_ARCH"=="x86_64" ]; then
-	REPO_RELDIR="VL64-$VL_VERSION"
+
+function test_host {
+	# Run some tests on the host to make sure we can create a VL container there
+	SLAPTGET=$(which slapt-get)
+	INSTALLPKG=$(which installpkg)
+	if [ -z $SLAPTGET ]; then
+		echo "NO"
+		return
+	elif [ -z $INSTALLPKG ]; then
+		echo "NO"
+		return
+	else
+		echo "YES"
+		return
+}	
+
+function slaptconfig {
+    header=$(cat <<EOF
+WORKINGDIR=$VL_CACHE/veclinux/packages
+EXCLUDE=kernel,kernel-ide,kernel-source,kernel-src,kernel-headers,kernel-modules
+EOF
+)
+    case $VL_ARCH in
+	i?86)
+		case $VL_VERSION in 
+			"7.0")
+				cat <<EOF
+$header
+SOURCE=http://vectorlinux.osuosl.org/veclinux-7.0/packages
+SOURCE=http://vectorlinux.osuosl.org/veclinux-7.0/extra
+SOURCE=http://vectorlinux.osuosl.org/veclinux-7.0/patches
+EOF
+			;;
+			"7.1")
+				cat <<EOF
+$header
+SOURCE=http://vlcore.vectorlinux.com/pkg/untested/veclinux-7.1/x86
+EOF
+			;;
+		esac
+		;;
+	x86_64)
+		case $VL_VERSION in
+			"7.0")
+				cat <<EOF
+$header
+SOURCE=http://vectorlinux.osuosl.org/VL64-7.0/packages
+SOURCE=http://vectorlinux.osuosl.org/VL64-7.0/extra
+SOURCE=http://vectorlinux.osuosl.org/VL64-7.0/patches
+EOF
+			;;
+			"7.1")
+				cat <<EOF
+$header
+SOURCE=http://vlcore.vectorlinux.com/pkg/untested/veclinux-7.1/x86_64
+EOF
+			;;
+		esac
+		;;
+esac
+}
+
+function write_rcfile_patches {
+	# patch some init files
+	rootfs=$1
+	name=$1
+	# patch rc.6
+	echo "writing patches"
+	cat >$rootfs/tmp/initsys.patch <<EOPATCH
+diff -Naur 7.0-init/etc/rc.d/rc.6 7.0-init.patched/etc/rc.d/rc.6
+--- 7.0-init/etc/rc.d/rc.6	2011-04-01 11:57:16.000000000 -0500
++++ 7.0-init.patched/etc/rc.d/rc.6	2013-08-29 13:55:22.000000000 -0500
+@@ -10,6 +10,10 @@
+ # Modified by:  Patrick J. Volkerding, <volkerdi@slackware.com>
+ #
+ 
++# Minor tweaks for lxc container compatibility by Moises Henriquez
++# Basically just a check for a container variable to jump over some areas.
++container="lxc"
++
+ # Set the path.
+ PATH=/sbin:/etc:/bin:/usr/bin
+ 
+@@ -37,6 +41,9 @@
+ 		;;
+ esac
+ 
++# container check
++if [ ! \$container = "lxc" ]; then
++
+ # Save the system time to the hardware clock using hwclock --systohc.
+ if [ -x /sbin/hwclock ]; then
+   # Check for a broken motherboard RTC clock (where ioports for rtc are
+@@ -52,7 +59,7 @@
+     /sbin/hwclock  \$CLOCK_OPT --localtime --systohc
+   fi
+ fi
+-
++fi # End container check
+ # Stop the Apache web server:
+ if [ -x /etc/rc.d/rc.httpd ]; then
+   /etc/rc.d/rc.httpd stop
+@@ -114,12 +121,15 @@
+   /sbin/dhcpcd -k 1> /dev/null 2> /dev/null
+ fi
+ 
++# container check
++if [ ! \$container = "lxc" ]; then
+ # Shut down PCMCIA devices:
+ if [ -x /etc/rc.d/rc.pcmcia ] ; then
+   . /etc/rc.d/rc.pcmcia stop
+   # The cards might need a little extra time here to initialize.
+   sleep 5
+ fi
++fi # End container check
+ 
+ # Turn off process accounting:
+ if [ -x /sbin/accton -a -r /var/log/pacct ]; then
+@@ -138,6 +148,8 @@
+   killall5 -9
+ fi
+ 
++# Container check
++if [ ! \$container = "lxc" ]; then
+ # Try to turn off quota.
+ if grep -q quota /etc/fstab ; then
+   if [ -x /sbin/quotaoff ]; then
+@@ -145,6 +157,7 @@
+     /sbin/quotaoff -a
+   fi
+ fi
++fi # end container check
+ 
+ # Carry a randlibrtmp.so.0:om seed between reboots.
+ echo "Saving random seed from /dev/urandom in /etc/random-seed."
+@@ -177,6 +190,8 @@
+   fi
+ }
+ 
++# Container check
++if [ ! \$container = "lxc" ]; then
+ # Turn off swap, then unmount local file systems.
+ echo "Turning off swap."
+ swapoff -a
+@@ -199,6 +214,7 @@
+ fi
+ 
+ # This never hurts:
++fi #End container check
+ sync
+ 
+ # sleep 1 fixes problems with some hard drives that don't
+@@ -208,6 +224,8 @@
+ # This is to ensure all processes have completed on SMP machines:
+ wait
+ 
++# container check
++if [ ! \$container = "lxc" ]; then
+ if [ -x /sbin/genpowerd ]; then
+   # See if this is a powerfail situation:
+   if egrep -q "FAIL|SCRAM" /etc/upsstatus 2> /dev/null ; then
+@@ -223,6 +241,10 @@
+     fi
+   fi
+ fi
++else
++# Confirm that the container has stopped."
++echo ; echo "* Container stopped. *" ; echo
++fi # End container check
+ 
+ # Now halt (poweroff with APM or ACPI enabled kernels) or reboot.
+ if [ "$command" = "reboot" ]; then
+diff -Naur 7.0-init/etc/rc.d/rc.M 7.0-init.patched/etc/rc.d/rc.M
+--- 7.0-init/etc/rc.d/rc.M	2011-04-01 11:57:16.000000000 -0500
++++ 7.0-init.patched/etc/rc.d/rc.M	2013-08-29 14:04:44.000000000 -0500
+@@ -10,6 +10,10 @@
+ #
+ 
+ # load functions
++
++# Minor tweaks for lxc container compatibility by Moises Henriquez
++# Basically just a check for a container variable to jump over some sections
++container="lxc"
+ . /etc/rc.d/functions-display
+ 
+ PATH="/bin:/sbin:/usr/bin:/usr/sbin:\$PATH"
+@@ -36,8 +40,17 @@
+ fi
+ 
+ ## Hardware initialization
++if [ ! \$container = "lxc" ]; then
++for RC in acpid api; do
++	if [ -x /etc/rc.d/rc.\$RC ]; then
++		/etc/rc.d/rc.text 14 "Setting up \$RC "
++		/etc/rc.d/rc.\$RC start > /dev/null 2>&1
++		evaluate_retvall
++	fi
++done
++fi # End container check
+ echocl "Initializing hardware" cyan
+-for RC in modules pnp acpid serial parallel alsa cdrom samba messagebus hald; do
++for RC in modules pnp serial parallel alsa cdrom samba messagebus hald; do
+    if [ -x /etc/rc.d/rc.\$RC ]; then
+       /etc/rc.d/rc.text 14 "Setting up \$RC"  
+ # bootsplash
+@@ -45,17 +58,6 @@
+       echonl "Setting up \$RC"
+       /etc/rc.d/rc.\$RC start > /dev/null 2>&1
+       evaluate_retvall
+-   fi
+-done
+-
+-for RC in apm; do
+-   if [ -x /etc/rc.d/rc.\$RC ]; then
+-      /etc/rc.d/rc.text 15 "Setting up \$RC" 
+-# bootsplash
+-progressbar 75
+-      echonl "Setting up \$RC"
+-      /etc/rc.d/rc.\$RC start > /dev/null 2>&1
+-      evaluate_retvall
+    fi
+ done
+ 
+diff -Naur 7.0-init/etc/rc.d/rc.S 7.0-init.patched/etc/rc.d/rc.S
+--- 7.0-init/etc/rc.d/rc.S	2011-04-01 11:57:17.000000000 -0500
++++ 7.0-init.patched/etc/rc.d/rc.S	2013-08-29 13:48:48.000000000 -0500
+@@ -9,6 +9,10 @@
+ # Eko M. Budi, Robert S. Lange, Tony Brijeski, Uel Archuletta(bootsplash-text)
+ #
+ 
++# Small tweaks for lxc container compatibility by Moises Henriquez
++# Basically just a check for a container variable to jump over some areas
++
++container="lxc"
+ . /etc/rc.d/functions-display
+ 
+ PATH=/sbin:/usr/sbin:/bin:/usr/bin
+@@ -26,6 +30,8 @@
+ echoc "==> rc.S  Setting up the base system configuration" yellow
+ echoc "Initializing kernel file systems" cyan
+ 
++# Container check
++if [ ! \$container = "lxc" ]; then 
+ # Mount /proc right away:
+ echo "Mounting /proc file system" 
+ /sbin/mount -v proc /proc -n -t proc
+@@ -198,6 +204,7 @@
+ 
+ # Any /etc/mtab that exists here is old, so we delete it to start over:
+ /bin/rm -f /etc/mtab*
++fi # End container check
+ # Remounting the / partition will initialize the new /etc/mtab:
+ /sbin/mount -w -o remount /
+ 
+	
+EOPATCH
+	cat >$rootfs/tmp/rc6.patch <<EOP
+diff -Naur /etc/rc.d/rc.6 rc.6 
+--- /etc/rc.d/rc.6	2013-05-25 10:21:30.000000000 -0500
++++ rc.6	2013-08-29 09:04:15.000000000 -0500
+@@ -10,6 +10,12 @@
+ # Modified by:  Patrick J. Volkerding, <volkerdi@slackware.com>
+ #
+ 
++# Minor tweaks for lxc container by Moises Henriquez
++# based on Chris Willing's modifications
++# http://www.vislab.uq.edu.au/howto/lxc/rc.6
++# basically, just checks for a variable to jump over some sections
++container="lxc"
++
+ # Set the path.
+ PATH=/sbin:/etc:/bin:/usr/bin
+ 
+@@ -37,6 +43,8 @@
+ 		;;
+ esac
+ 
++# Check if we are running inside a container.
++if [ ! \$container = "lxc" ]; then
+ # Save the system time to the hardware clock using hwclock --systohc.
+ if [ -x /sbin/hwclock ]; then
+   # Check for a broken motherboard RTC clock (where ioports for rtc are
+@@ -53,8 +61,9 @@
+   fi
+ fi
+ 
+-
+ /usr/sbin/alsactl store
++fi # End of LXC container check
++
+ # Stop the Apache web server:
+ if [ -x /etc/rc.d/rc.httpd ]; then
+   /etc/rc.d/rc.httpd stop
+@@ -116,12 +125,15 @@
+   /sbin/dhcpcd -k 1> /dev/null 2> /dev/null
+ fi
+ 
++# Only run this if not in a lxc container
++if [ ! \$container = "lxc" ]; then
+ # Shut down PCMCIA devices:
+ if [ -x /etc/rc.d/rc.pcmcia ] ; then
+   . /etc/rc.d/rc.pcmcia stop
+   # The cards might need a little extra time here to initialize.
+   sleep 5
+ fi
++fi # End of container check
+ 
+ # Turn off process accounting:
+ if [ -x /sbin/accton -a -r /var/log/pacct ]; then
+@@ -140,6 +152,8 @@
+   killall5 -9
+ fi
+ 
++# Run this only if not in a lxc container
++if [ ! \$container = "lxc" ]; then
+ # Try to turn off quota.
+ if grep -q quota /etc/fstab ; then
+   if [ -x /sbin/quotaoff ]; then
+@@ -147,7 +161,7 @@
+     /sbin/quotaoff -a
+   fi
+ fi
+-
++fi # End of container check
+ # Carry a random seed between reboots.
+ echo "Saving random seed from /dev/urandom in /etc/random-seed."
+ # Use the pool size from /proc, or 512 bytes:
+@@ -168,6 +182,7 @@
+ 
+ # A function to deactivate LVM volume groups:
+ deactivate_lvm() {
++if [ ! \$container = "lxc" ]; then
+   if [ -r /etc/lvmtab -o -d /etc/lvm/backup ]; then
+     echo "Deactivating LVM volume groups:"
+     if cat /proc/sys/kernel/osrelease | cut -f 1,2 -d . | grep -q -w 2.4 2> /dev/null ; then
+@@ -177,8 +192,11 @@
+     fi
+     sleep 10
+   fi
++fi
+ }
+ 
++# Skip this if in an lxc container
++if [ ! \$container = "lxc" ]; then
+ # Turn off swap, then unmount local file systems.
+ echo "Turning off swap."
+ swapoff -a
+@@ -199,7 +217,7 @@
+ else
+   umount -a -r -t nonfs,noproc,nosysfs,noumsdos
+ fi
+-
++fi # End of container check
+ # This never hurts:
+ sync
+ 
+@@ -209,7 +227,7 @@
+ 
+ # This is to ensure all processes have completed on SMP machines:
+ wait
+-
++if [ ! \$container = "lxc" ]; then
+ if [ -x /sbin/genpowerd ]; then
+   # See if this is a powerfail situation:
+   if egrep -q "FAIL|SCRAM" /etc/upsstatus 2> /dev/null ; then
+@@ -225,6 +243,10 @@
+     fi
+   fi
+ fi
++else
++# Confirm container has stopped"
++echo ; echo "* Container stopped. *" ; echo
++fi
+ 
+ # Now halt (poweroff with APM or ACPI enabled kernels) or reboot.
+ if [ "$command" = "reboot" ]; then
+EOP
+
+# Patch rc.S
+cat >$rootfs/tmp/rcs.patch <<EOP
+diff -Naur /etc/rc.d/rc.S rc.S 
+--- /etc/rc.d/rc.S	2013-05-25 10:21:30.000000000 -0500
++++ rc.S	2013-08-29 09:28:52.000000000 -0500
+@@ -9,6 +9,12 @@
+ # Eko M. Budi, Robert S. Lange, Tony Brijeski, Uel Archuletta
+ #
+ 
++# Minor tweaks for an lxc container by Moises Henriquez
++# based on the Chris Willing's modifications
++# http://www.vislab.uq.edu.au/howto/lxc/rc.S
++# Basically, a check for a container variable is made to jump over some sections
++container="lxc"
++
+ . /etc/rc.d/functions-display
+ 
+ PATH=/sbin:/usr/sbin:/bin:/usr/bin
+@@ -19,6 +25,8 @@
+ mkdir -p /dev/pts
+ mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts
+ 
++# container check
++if [ ! \$container = "lxc" ]; then
+ # Mount /proc right away:
+ echo "Mounting /proc file system" 
+ /sbin/mount -v proc /proc -n -t proc
+@@ -204,6 +212,8 @@
+ # Any /etc/mtab that exists here is old, so we delete it to start over:
+ /bin/rm -f /etc/mtab{,~,.tmp} && /bin/touch /etc/mtab
+ 
++fi # End of container check
++
+ # Add entry for / to /etc/mtab:
+ /sbin/mount -f -w /
+
+EOP	
+
+# patch rc.M
+cat > $rootfs/tmp/rcm.patch <<EOP
+diff /etc/rc.d/rc.M rc.M
+2c2
+< # rc.M		
+---
+> # rc.M
+12a13,17
+> 
+> # Minor tweaks for an lxc container by Moises Henriquez
+> # Basically, just checks for a container variable and jumps over some sections
+> container = "lxc"
+> 
+37a43
+> if [ ! \$container = "lxc" ]; then
+44a51
+> fi # End container check
+57c64
+< 
+---
+> if [ ! \$container = "lxc" ]; then
+65a73
+> fi # End container check
+EOP
+
+cat >$rootfs/tmp/inittab <<EOF
+#/etc/inittab
+# inittab	This file describes how the INIT process should set up
+#		the system in a certain run-level.
+#
+# Version:	@(#)inittab		2.04	17/05/93	MvS
+#                                       2.10    02/10/95        PV
+#                                       3.00    02/06/1999      PV
+#                                       4.00    04/10/2002      PV
+#                                      13.37    2011-03-25      PJV
+#
+# Author:	Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
+# Modified by:	Patrick J. Volkerding, <volkerdi@slackware.com>
+#
+
+# These are the default runlevels in Slackware:
+#   0 = halt
+#   1 = single user mode
+#   2 = unused (but configured the same as runlevel 3)
+#   3 = multiuser mode (default Slackware runlevel)
+#   4 = X11 with KDM/GDM/XDM (session managers)
+#   5 = unused (but configured the same as runlevel 3)
+#   6 = reboot
+
+# Default runlevel. (Do not set to 0 or 6)
+id:3:initdefault:
+
+# System initialization (runs when system boots).
+si:S:sysinit:/etc/rc.d/rc.S
+
+# Script to run when going single user (runlevel 1).
+su:1S:wait:/etc/rc.d/rc.K
+
+# Script to run when going multi user.
+rc:2345:wait:/etc/rc.d/rc.M
+
+# Runlevel 0 halts the system.
+l0:0:wait:/etc/rc.d/rc.0
+
+# Runlevel 6 reboots the system.
+l6:6:wait:/etc/rc.d/rc.6
+
+
+# These are the standard console login getties in multiuser mode:
+c1:12345:respawn:/sbin/mingetty tty1
+c2:12345:respawn:/sbin/mingetty tty2
+
+
+# End of /etc/inittab
+EOF
+}
+
+function configure_container_init {
+	rootfs=$1
+	name=$2
+	(
+	cd $rootfs/etc/rc.d || exit 1
+	# Disable some of the init scripts we dont need in an lxc container
+	for file in rc.{A,4,K,X,acpid,apm,autologin,bootsplash,inetd,keymap,modules,network,nfsd,pnp,scanluns,diamond,fc-cache,vlinit}; do
+		if [ -x $file ]; then
+			chmod -x $file
+		fi
+	done
+	
+	# Write modified rc.6
+	cat >rc.6 <<EOF
+#! /bin/sh
+#
+# rc.6		This file is executed by init when it goes into runlevel
+#		0 (halt) or runlevel 6 (reboot). It kills all processes,
+#		unmounts file systems and then either halts or reboots.
+#
+# Version:	@(#)/etc/rc.d/rc.6	2.47 Sat Jan 13 13:37:26 PST 2001
+#
+# Author:	Miquel van Smoorenburg <miquels@drinkel.nl.mugnet.org>
+# Modified by:  Patrick J. Volkerding, <volkerdi@slackware.com>
+#
+# Modified by M0E-lnx for lxc compatibility.
+# WARNING:  DO NOT use this script on a bare metal install
+
+# Set the path.
+PATH=/sbin:/etc:/bin:/usr/bin
+
+# If there are SystemV init scripts for this runlevel, run them.
+if [ -x /etc/rc.d/rc.sysvinit ]; then
+  . /etc/rc.d/rc.sysvinit
+fi
+
+# Set linefeed mode to avoid staircase effect.
+/bin/stty onlcr
+
+echo "Running shutdown script \$0:"
+
+# Find out how we were called.
+case "\$0" in
+	*0)
+		command="halt"
+		;;
+	*6)
+		command=reboot
+		;;
+	*)
+		echo "\$0: call me as \"rc.0\" or \"rc.6\" please!"
+		exit 1
+		;;
+esac
+
+## Save the system time to the hardware clock using hwclock --systohc.
+#if [ -x /sbin/hwclock ]; then
+#  # Check for a broken motherboard RTC clock (where ioports for rtc are
+#  # unknown) to prevent hwclock causing a hang:
+#  if ! grep -q -w rtc /proc/ioports ; then
+#    CLOCK_OPT="--directisa"
+#  fi
+#  if grep -q "^UTC" /etc/hardwareclock 2> /dev/null ; then
+#    echo "Saving system time to the hardware clock (UTC)."
+#    /sbin/hwclock \$CLOCK_OPT --utc --systohc
+#  else
+#    echo "Saving system time to the hardware clock (localtime)."
+#    /sbin/hwclock  \$CLOCK_OPT --localtime --systohc
+#  fi
+#fi
+
+# Run any local shutdown scripts:
+if [ -x /etc/rc.d/rc.local_shutdown ]; then
+  /etc/rc.d/rc.local_shutdown stop
+fi
+
+# Stop the Apache web server:
+if [ -x /etc/rc.d/rc.httpd ]; then
+  /etc/rc.d/rc.httpd stop
+fi
+
+# Stop the MySQL database:
+if [ -r /var/run/mysql/mysql.pid ]; then
+  . /etc/rc.d/rc.mysqld stop
+fi
+
+# Stop the Samba server:
+if [ -x /etc/rc.d/rc.samba ]; then
+  . /etc/rc.d/rc.samba stop
+fi
+
+# Shut down the NFS server:
+if [ -x /etc/rc.d/rc.nfsd ]; then
+  /etc/rc.d/rc.nfsd stop
+fi
+
+# Shut down the SSH server:
+if [ -x /etc/rc.d/rc.sshd ]; then
+  /etc/rc.d/rc.sshd stop
+fi
+
+# Shut down the SASL authentication daemon:
+if [ -x /etc/rc.d/rc.saslauthd ]; then
+  /etc/rc.d/rc.saslauthd stop
+fi
+
+# Shut down OpenLDAP:
+if [ -x /etc/rc.d/rc.openldap ]; then
+  /etc/rc.d/rc.openldap stop
+fi
+
+# Stop D-Bus:
+if [ -x /etc/rc.d/rc.messagebus ]; then
+  sh /etc/rc.d/rc.messagebus stop
+fi
+
+# Unmount any NFS, SMB, or CIFS filesystems:
+echo "Unmounting remote filesystems."
+/bin/umount -v -a -r -t nfs,smbfs,cifs
+
+# Try to shut down pppd:
+PS="\$(ps ax)"
+if echo "\$PS" | /bin/grep -q -w pppd ; then
+  if [ -x /usr/sbin/ppp-off ]; then
+    /usr/sbin/ppp-off
+  fi
+fi
+
+# Bring down the networking system, but first make sure that this
+# isn't a diskless client with the / partition mounted via NFS:
+if ! /bin/mount | /bin/grep -q 'on / type nfs' ; then
+  if [ -x /etc/rc.d/rc.inet1 ]; then
+    . /etc/rc.d/rc.inet1 stop
+  fi
+fi
+
+# In case dhcpcd might have been manually started on the command line,
+# look for the .pid file, and shut dhcpcd down if it's found:
+if /bin/ls /etc/dhcpc/*.pid 1> /dev/null 2> /dev/null ; then
+  /sbin/dhcpcd -k 1> /dev/null 2> /dev/null
+  # A little time for /etc/resolv.conf and/or other files to
+  # restore themselves.
+  sleep 2
+fi
+
+# Shut down PCMCIA devices:
+if [ -x /etc/rc.d/rc.pcmcia ]; then
+  . /etc/rc.d/rc.pcmcia stop
+  # The cards might need a little extra time here to deactivate:
+  /bin/sleep 5
+fi
+
+# Turn off process accounting:
+if [ -x /sbin/accton -a -r /var/log/pacct ]; then
+  /sbin/accton off
+fi
+
+# Terminate acpid before syslog:
+if [ -x /etc/rc.d/rc.acpid -a -r /var/run/acpid.pid ]; then # quit
+  . /etc/rc.d/rc.acpid stop
+fi
+
+# Kill all processes.
+# INIT is supposed to handle this entirely now, but this didn't always
+# work correctly without this second pass at killing off the processes.
+# Since INIT already notified the user that processes were being killed,
+# we'll avoid echoing this info this time around.
+if [ ! "\$1" = "fast" ]; then # shutdown did not already kill all processes
+  /sbin/killall5 -15 
+  /bin/sleep 5
+  /sbin/killall5 -9
+fi
+
+# Try to turn off quota.
+if /bin/grep -q quota /etc/fstab ; then
+  if [ -x /sbin/quotaoff ]; then
+    echo "Turning off filesystem quotas."
+    /sbin/quotaoff -a
+  fi
+fi
+
+# Carry a random seed between reboots.
+echo "Saving random seed from /dev/urandom in /etc/random-seed."
+# Use the pool size from /proc, or 512 bytes:
+if [ -r /proc/sys/kernel/random/poolsize ]; then
+  /bin/dd if=/dev/urandom of=/etc/random-seed count=1 bs=\$(cat /proc/sys/kernel/random/poolsize) 2> /dev/null
+else
+  /bin/dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2> /dev/null
+fi
+/bin/chmod 600 /etc/random-seed
+
+# Before unmounting file systems write a reboot or halt record to wtmp.
+\$command -w
+
+# Clear /var/lock/subsys.
+if [ -d /var/lock/subsys ]; then
+  rm -f /var/lock/subsys/*
+fi
+
+# Turn off swap:
+echo "Turning off swap."
+/sbin/swapoff -a
+/bin/sync
+
+# Umount any LVM volumes:
+if /bin/mount | /bin/grep -q '^/dev/mapper/' ; then
+  echo "Unmounting LVM volumes."
+  /bin/umount -v \$(/bin/mount | /bin/grep '^/dev/mapper/' | /bin/cut -d ' ' -f 3 | /bin/tac)
+fi
+
+echo "Unmounting local file systems."
+#/bin/umount -v -a -t no,proc,sysfs
+
+# We won't remount ro since we may want to edit from host system
+#
+#echo "Remounting root filesystem read-only."
+#/bin/mount -v -n -o remount,ro /
+
+# This never hurts:
+/bin/sync
+
+# Close any volumes opened by cryptsetup:
+if [ -f /etc/crypttab -a -x /sbin/cryptsetup ]; then
+  cat /etc/crypttab | grep -v "^#" | grep -v "^\$" | while read line; do
+    # NOTE: we only support LUKS formatted volumes (except for swap)!
+    LUKS=\$(echo \$line | tr '\t' ' ' | tr -s ' ' | cut -f1 -d' ')
+    DEV=\$(echo \$line | tr '\t' ' ' | tr -s ' ' | cut -f2 -d' ')
+    OPTS=\$(echo \$line | tr '\t' ' ' | tr -s ' ' | cut -f4 -d' ')
+    if /sbin/cryptsetup isLuks \$DEV 2>/dev/null ; then
+      echo "Locking LUKS crypt volume '\${LUKS}':"
+      /sbin/cryptsetup luksClose \${LUKS}
+    elif echo \$OPTS | grep -wq swap ; then
+      # If any of the volumes was used as encrypted swap,
+      # then run mkswap on the underlying device -
+      # in case other Linux installations on this computer should use it:
+      echo "Erasing encrypted swap '\${LUKS}' and restoring normal swap on \${DEV}:"
+      /sbin/cryptsetup remove \${LUKS}
+      mkswap \$DEV
+    fi
+  done
+fi
+
+# Deactivate LVM volume groups:
+if [ -r /etc/lvmtab -o -d /etc/lvm/backup ]; then
+  echo "Deactivating LVM volume groups:"
+  /sbin/vgchange -an --ignorelockingfailure
+fi
+
+# This never hurts again (especially since root-on-LVM always fails
+# to deactivate the / logical volume...  but at least it was
+# remounted as read-only first)
+/bin/sync
+
+# sleep 3 fixes problems with some hard drives that don't
+# otherwise finish syncing before reboot or poweroff
+/bin/sleep 3
+
+# This is to ensure all processes have completed on SMP machines:
+wait
+
+if [ -x /sbin/genpowerd ]; then
+  # See if this is a powerfail situation:
+  if /bin/egrep -q "FAIL|SCRAM" /etc/upsstatus 2> /dev/null ; then
+    # Signal UPS to shut off the inverter:
+    /sbin/genpowerd -k
+    if [ ! \$? = 0 ]; then
+      echo
+      echo "There was an error signaling the UPS."
+      echo "Perhaps you need to edit /etc/genpowerd.conf to configure"
+      echo "the serial line and UPS type."
+      # Wasting 15 seconds of precious power:
+      /bin/sleep 15
+    fi
+  fi
+fi
+
+# Now halt (poweroff with APM or ACPI enabled kernels) or reboot.
+if [ "\$command" = "reboot" ]; then
+  echo "Rebooting."
+  /sbin/reboot
+else
+  /sbin/poweroff
+fi
+
+EOF
+	
+	# Write modified rc.S
+	cat >rc.S <<EOF
+#!/bin/sh
+#
+# /etc/rc.d/rc.S:  System initialization script.
+#
+# Mostly written by:  Patrick J. Volkerding, <volkerdi@slackware.com>
+#
+# Modified by M0E-lnx for lxc compatibility.
+# WARNING:  DO NOT use this script on a bare metal install
+
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+
+# Try to mount /proc:
+/sbin/mount -v proc /proc -n -t proc 2> /dev/null
+
+# Mount sysfs next, if the kernel supports it:
+if [ -d /sys ]; then
+  if grep -wq sysfs /proc/filesystems ; then
+    if ! grep -wq sysfs /proc/mounts ; then
+      /sbin/mount -v sysfs /sys -n -t sysfs
+    fi
+  fi
+fi
+
+# Any /etc/mtab that exists here is old, so we delete it to start over:
+/bin/rm -f /etc/mtab*
+# Remounting the / partition will initialize the new /etc/mtab:
+/sbin/mount -w -o remount /
+
+# Read in the correct / filesystem complete with arguments so mount will
+# show them correctly. This does not stop those arguments from functioning
+# but does prevent a small bug with /etc/mtab.
+/bin/grep ' / ' /proc/mounts | grep -v "^rootfs" > /etc/mtab
+
+# Fix /etc/mtab to list sys and proc if they were not yet entered in
+# /etc/mtab because / was still mounted read-only:
+if [ -d /proc/sys ]; then
+  /sbin/mount -f proc /proc -t proc
+fi
+if [ -d /sys/bus ]; then
+  /sbin/mount -f sysfs /sys -t sysfs
+fi
+
+# Check all the non-root filesystems:
+if [ ! -r /etc/fastboot ]; then
+  echo "Checking non-root filesystems:"
+  /sbin/fsck \$FORCEFSCK -C -R -A -a
+fi
+
+# Mount usbfs:
+if grep -wq usbfs /proc/filesystems; then
+  if ! grep -wq usbfs /proc/mounts ; then
+    if ! grep -wq usbfs /etc/fstab; then
+      /sbin/mount -v usbfs /proc/bus/usb -t usbfs
+    else
+      /sbin/mount -v /proc/bus/usb
+    fi
+  fi
+fi
+
+# Mount non-root file systems in fstab, but not NFS or SMB 
+# because TCP/IP is not yet configured, and not proc or sysfs
+# because those have already been mounted.  Also check that
+# devpts is not already mounted before attempting to mount
+# it.  With a 2.6.x or newer kernel udev mounts devpts.
+# We also need to wait a little bit to let USB and other
+# hotplugged devices settle (sorry to slow down the boot):
+echo "Mounting non-root local filesystems:"
+sleep 3
+if /bin/grep -wq devpts /proc/mounts ; then
+  /sbin/mount -a -v -t nonfs,nosmbfs,nocifs,noproc,nosysfs,nodevpts
 else
-	REPO_RELDIR="unknown"
+  /sbin/mount -a -v -t nonfs,nosmbfs,nocifs,noproc,nosysfs
 fi
 
+# Clean up some temporary files:
+rm -f /var/run/* /var/run/*/* /var/run/*/*/* /etc/nologin \
+  /etc/dhcpc/*.pid /etc/forcefsck /etc/fastboot \
+  /var/state/saslauthd/saslauthd.pid \
+  /tmp/.Xauth* 1> /dev/null 2> /dev/null
+  ( cd /var/log/setup/tmp && rm -rf * )
+  ( cd /tmp && rm -rf kde-[a-zA-Z]* ksocket-[a-zA-Z]* hsperfdata_[a-zA-Z]* plugtmp* )
+
+# Create /tmp/{.ICE-unix,.X11-unix} if they are not present:
+if [ ! -e /tmp/.ICE-unix ]; then
+  mkdir -p /tmp/.ICE-unix
+  chmod 1777 /tmp/.ICE-unix
+fi
+if [ ! -e /tmp/.X11-unix ]; then
+  mkdir -p /tmp/.X11-unix
+  chmod 1777 /tmp/.X11-unix
+fi
+
+# Create a fresh utmp file:
+touch /var/run/utmp
+chown root:utmp /var/run/utmp
+chmod 664 /var/run/utmp
+
+# Update the current kernel level in the /etc/motd (Message Of The Day) file,
+# if the first line of that file begins with the word 'Linux'.
+# You are free to modify the rest of the file as you see fit.
+if [ -x /bin/sed ]; then
+  /bin/sed -i "{1s/^Linux.*/\$(/bin/uname -sr)\./}" /etc/motd
+fi
+
+# If there are SystemV init scripts for this runlevel, run them.
+if [ -x /etc/rc.d/rc.sysvinit ]; then
+  . /etc/rc.d/rc.sysvinit
+fi
+
+# Carry an entropy pool between reboots to improve randomness.
+if [ -f /etc/random-seed ]; then
+  echo "Using /etc/random-seed to initialize /dev/urandom."
+  cat /etc/random-seed > /dev/urandom
+fi
+# Use the pool size from /proc, or 512 bytes:
+if [ -r /proc/sys/kernel/random/poolsize ]; then
+  dd if=/dev/urandom of=/etc/random-seed count=1 bs=\$(cat /proc/sys/kernel/random/poolsize) 2> /dev/null
+else
+  dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2> /dev/null
+fi
+chmod 600 /etc/random-seed
+
+EOF
+
+	# Write modified rc.M
+	cat >rc.M <<EOF
+#!/bin/sh
+#
+# rc.M		This file is executed by init(8) when the system is being
+#		initialized for one of the "multi user" run levels (i.e.
+#		levels 1 through 6).  It usually does mounting of file
+#		systems et al.
+#
+# Version:	@(#)/etc/rc.d/rc.M	2.23	Wed Feb 26 19:20:58 PST 2003
+#
+# Author:	Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
+#		Heavily modified by Patrick Volkerding <volkerdi@slackware.com>
+#
+# minor tweaks for an lxc container
+# by Matteo Bernardini <ponce@slackbuilds.org>:
+# a check for a container variable is made to jump sections
+#
+# Modified by M0E-lnx for lxc compatibility.
+# WARNING:  DO NOT use this script on a bare metal install
+
+container="lxc"
+
+# Tell the viewers what's going to happen.
+echo "Going multiuser..."
+
+# Update all the shared library links:
+if [ -x /sbin/ldconfig ]; then
+  echo "Updating shared library links:  /sbin/ldconfig &"
+  /sbin/ldconfig &
+fi
+
+# lxc container check
+if [ ! \$container = "lxc" ]; then
+
+# Screen blanks after 15 minutes idle time, and powers down in one hour
+# if the kernel supports APM or ACPI power management:
+/bin/setterm -blank 15 -powersave powerdown -powerdown 60
+
+# Set the hostname.
+if [ -r /etc/HOSTNAME ]; then
+  /bin/hostname \$(cat /etc/HOSTNAME | cut -f1 -d .)
+else
+  # fall back on this old default:
+  echo "darkstar.example.net" > /etc/HOSTNAME
+  /bin/hostname darkstar
+fi
+
+fi # end container check
+
+# Set the permissions on /var/log/dmesg according to whether the kernel
+# permits non-root users to access kernel dmesg information:
+if [ -r /proc/sys/kernel/dmesg_restrict ]; then
+  if [ \$(cat /proc/sys/kernel/dmesg_restrict) = 1 ]; then
+    touch /var/log/dmesg
+    chmod 640 /var/log/dmesg
+  fi
+else
+  touch /var/log/dmesg
+  chmod 644 /var/log/dmesg
+fi
+# Save the contents of 'dmesg':
+/bin/dmesg -s 65536 > /var/log/dmesg
+
+# Initialize PCMCIA devices:
+#
+# NOTE: This used to be started near the top of rc.S so that PCMCIA devices
+# could be fsck'ed along with the other drives.  This had some unfortunate
+# side effects, however, since root isn't yet read-write, and /var might not
+# even be mounted the .pid files can't be correctly written in /var/run and
+# the pcmcia system can't be correctly shut down.  If you want some PCMCIA
+# partition to be mounted at boot (or when the card is inserted) then add
+# the appropriate lines to /etc/pcmcia/scsi.opts.
+#
+# Note that the stuff in /etc/pcmcia/ is only for 2.4.x kernels using
+# 16-bit PCMCIA cards (not 32-bit Cardbus cards!).  For example, with a
+# wireless card you might need to set options in /etc/pcmcia OR in
+# /etc/rc.d/rc.wireless.conf, or even in /etc/rc.d/rc.inet1.conf (with
+# extra options if needed for the encryption key, ESSID, etc.)
+#
+# Hopefully this situation will be unified in the future, but for now
+# that's how it is...
+#
+if [ -x /etc/rc.d/rc.pcmcia ]; then
+  . /etc/rc.d/rc.pcmcia start
+  # The cards might need a little extra time here to initialize.
+  sleep 5
+fi
+
+# Start the system logger.
+if [ -x /etc/rc.d/rc.syslog -a -x /usr/sbin/syslogd -a -d /var/log ]; then
+  . /etc/rc.d/rc.syslog start
+fi
+
+# Update the X font indexes:
+if [ -x /usr/bin/fc-cache ]; then
+  echo "Updating X font indexes:  /usr/bin/fc-cache -f &"
+  /usr/bin/fc-cache -f &
+fi
+
+# Run rc.udev again.  This will start udev if it is not already running
+# (for example, upon return from runlevel 1), otherwise it will trigger it
+# to look for device changes and to generate persistent rules if needed.
+if grep -wq sysfs /proc/mounts && grep -q tmpfs /proc/filesystems ; then
+  if ! grep -wq nohotplug /proc/cmdline ; then
+    if [ -x /etc/rc.d/rc.udev ]; then
+      /bin/sh /etc/rc.d/rc.udev start
+    fi
+  fi
+fi
+
+# Initialize the networking hardware.
+if [ -x /etc/rc.d/rc.inet1 ]; then
+  . /etc/rc.d/rc.inet1
+fi
+
+# Look for additional USB/SCSI/IEEE1394/etc devices on multiple LUNs:
+if [ -x /etc/rc.d/rc.scanluns ]; then
+  . /etc/rc.d/rc.scanluns
+fi
+
+# Start networking daemons:
+if [ -x /etc/rc.d/rc.inet2 ]; then
+  . /etc/rc.d/rc.inet2
+fi
+
+# Mount any additional filesystem types that haven't already been mounted:
+mount -a -v 2> /dev/null | grep -v "already mounted"
+
+# Start the Control Script for automounter:
+if [ -x /etc/rc.d/rc.autofs ]; then
+  sh /etc/rc.d/rc.autofs start
+fi
+
+# Start the Network Time Protocol daemon:
+if [ -x /etc/rc.d/rc.ntpd ]; then
+  sh /etc/rc.d/rc.ntpd start
+fi
+
+# Remove stale locks and junk files (must be done after mount -a!)
+/bin/rm -f /var/lock/* /var/spool/uucp/LCK..* /tmp/.X*lock /tmp/core /core 2> /dev/null
+
+# Remove stale hunt sockets so the game can start.
+if [ -r /tmp/hunt -o -r /tmp/hunt.stats ]; then
+  echo "Removing your stale hunt sockets from /tmp."
+  /bin/rm -f /tmp/hunt*
+fi
+
+# Ensure basic filesystem permissions sanity.
+chmod 755 / 2> /dev/null
+chmod 1777 /tmp /var/tmp
+
+# lxc container check
+if [ ! \$container = "lxc" ]; then
+
+# Start APM or ACPI daemon.
+# If APM is enabled in the kernel, start apmd:
+if [ -e /proc/apm ]; then
+  if [ -x /usr/sbin/apmd ]; then
+    echo "Starting APM daemon:  /usr/sbin/apmd"
+    /usr/sbin/apmd
+  fi
+elif [ -x /etc/rc.d/rc.acpid ]; then # otherwise, start acpid:
+  . /etc/rc.d/rc.acpid start
+fi
+
+fi # end container check
+
+# Update any existing icon cache files:
+if find /usr/share/icons 2> /dev/null | grep -q icon-theme.cache ; then
+  for theme_dir in /usr/share/icons/* ; do
+    if [ -r \${theme_dir}/icon-theme.cache ]; then
+      echo "Updating icon-theme.cache in \${theme_dir}..."
+      /usr/bin/gtk-update-icon-cache -t -f \${theme_dir} 1> /dev/null 2> /dev/null &
+    fi
+  done
+  # This would be a large file and probably shouldn't be there.
+  if [ -r /usr/share/icons/icon-theme.cache ]; then
+    echo "Deleting icon-theme.cache in /usr/share/icons..."
+    #/usr/bin/gtk-update-icon-cache -t -f /usr/share/icons 1> /dev/null 2> /dev/null &
+    rm -f /usr/share/icons/icon-theme.cache
+  fi
+fi
+
+# Update mime database:
+if [ -x /usr/bin/update-mime-database -a -d /usr/share/mime ]; then
+  echo "Updating MIME database:  /usr/bin/update-mime-database /usr/share/mime &"
+  /usr/bin/update-mime-database /usr/share/mime 1> /dev/null 2> /dev/null &
+fi
+
+# Start D-Bus:
+if [ -x /etc/rc.d/rc.messagebus ]; then
+  sh /etc/rc.d/rc.messagebus start
+fi
+
+# Start console-kit-daemon:
+if [ -x /etc/rc.d/rc.consolekit ]; then
+  sh /etc/rc.d/rc.consolekit start
+fi
+
+# Start HAL:
+if [ -x /etc/rc.d/rc.hald ]; then
+  sh /etc/rc.d/rc.hald start
+fi
+
+# Start Bluetooth:
+if [ -x /etc/rc.d/rc.bluetooth ]; then
+  sh /etc/rc.d/rc.bluetooth start
+fi
+
+# Start wicd or networkmanager:
+if [ -x /etc/rc.d/rc.wicd -a -x /usr/sbin/wicd ]; then
+  sh /etc/rc.d/rc.wicd start
+elif [ -x /etc/rc.d/rc.networkmanager ]; then
+  sh /etc/rc.d/rc.networkmanager start
+fi
+
+# These GTK+/pango files need to be kept up to date for
+# proper input method, pixbuf loaders, and font support.
+if [ -x /usr/bin/update-gtk-immodules ]; then
+  /usr/bin/update-gtk-immodules --verbose
+fi
+if [ -x /usr/bin/update-gdk-pixbuf-loaders ]; then
+  /usr/bin/update-gdk-pixbuf-loaders --verbose
+fi
+if [ -x /usr/bin/update-pango-querymodules ]; then
+  /usr/bin/update-pango-querymodules --verbose
+fi
+
+# Start dnsmasq, a simple DHCP/DNS server:
+if [ -x /etc/rc.d/rc.dnsmasq ]; then
+  /etc/rc.d/rc.dnsmasq start
+fi
+
+# Start snmpd:
+if [ -x /etc/rc.d/rc.snmpd ]; then
+  /etc/rc.d/rc.snmpd start
+fi
+
+# Start the print spooling system.  This will usually be LPRng (lpd) or CUPS.
+if [ -x /etc/rc.d/rc.cups ]; then
+  # Start CUPS:
+  /etc/rc.d/rc.cups start
+elif [ -x /etc/rc.d/rc.lprng ]; then
+  # Start LPRng (lpd):
+  . /etc/rc.d/rc.lprng start
+fi
+
+# Start netatalk. (a file/print server for Macs using Appletalk)
+if [ -x /etc/rc.d/rc.atalk ]; then
+  /etc/rc.d/rc.atalk start
+fi
+
+# Start smartd, which monitors the status of S.M.A.R.T. compatible
+# hard drives and reports any problems.  Note some devices (which aren't
+# smart, I guess ;) will hang if probed by smartd, so it's commented out
+# by default.
+#if [ -x /usr/sbin/smartd ]; then
+#  /usr/sbin/smartd
+#fi
+
+# If we're using udev, make /dev/cdrom and any other optical drive symlinks
+# if some udev rule hasn't made them already:
+if grep -wq sysfs /proc/mounts && grep -q tmpfs /proc/filesystems; then
+  if ! grep -wq nohotplug /proc/cmdline ; then
+    if [ -x /lib/udev/rc.optical-symlinks -a -x /etc/rc.d/rc.udev ]; then
+      /bin/sh /lib/udev/rc.optical-symlinks
+    fi
+  fi
+fi
+
+# Monitor the UPS with genpowerd.
+# To use this, uncomment this section and edit your settings in
+# /etc/genpowerd.conf (serial device, UPS type, etc).  For more information,
+# see "man genpowerd" or the extensive documentation in the
+# /usr/doc/genpower-*/ directory.
+# You'll also need to configure a similar block in /etc/rc.d/rc.6 if you want
+# support for stopping the UPS's inverter after the machine halts.
+#if [ -x /sbin/genpowerd ]; then
+#  echo "Starting genpowerd daemon..."
+#  /sbin/genpowerd
+#fi
+
+# Turn on process accounting.  To enable process accounting, make sure the
+# option for BSD process accounting is enabled in your kernel, and then
+# create the file /var/log/pacct (touch /var/log/pacct).  By default, process
+# accounting is not enabled (since /var/log/pacct does not exist).  This is
+# because the log file can get VERY large.
+if [ -x /sbin/accton -a -r /var/log/pacct ]; then
+  chmod 640 /var/log/pacct
+  /sbin/accton /var/log/pacct
+fi
+
+# Start crond (Dillon's crond):
+# If you want cron to actually log activity to /var/log/cron, then change
+# -l notice to -l info to increase the logging level.
+if [ -x /usr/sbin/crond ]; then
+  /usr/sbin/crond -l notice
+fi
+
+# Start atd (manages jobs scheduled with 'at'):
+if [ -x /usr/sbin/atd ]; then
+  /usr/sbin/atd -b 15 -l 1
+fi
+
+# Slackware-Mini-Quota-HOWTO:
+# To really activate quotas, you'll need to add 'usrquota' and/or 'grpquota' to
+# the appropriate partitions as listed in /etc/fstab.  Here's an example:
+#
+# /dev/hda2      /home      ext3     defaults,usrquota      1   1
+#
+# You'll then need to setup initial quota files at the top of the partitions
+# to support quota, like this:
+# touch /home/aquota.user /home/aquota.group
+# chmod 600 /home/aquota.user /home/aquota.group
+#
+# Then, reboot to activate the system.
+# To edit user quotas, use 'edquota'.  See 'man edquota'.  Also, the
+# official Quota Mini-HOWTO has lots of useful information.  That can be found
+# here:  /usr/doc/Linux-HOWTOs/Quota
+
+# Check quotas and then turn quota system on:
+if grep -q quota /etc/fstab ; then
+  for quotafs in \$(awk '/quota/ {print \$2}' /etc/fstab) ; do
+    /bin/rm -f \$quotafs/{a,}quota.{group,user}.new
+  done
+  if [ -x /sbin/quotacheck ]; then
+    echo "Checking filesystem quotas:  /sbin/quotacheck -avugm"
+    /sbin/quotacheck -avugm
+  fi
+  if [ -x /sbin/quotaon ]; then
+    echo "Activating filesystem quotas:  /sbin/quotaon -avug"
+    /sbin/quotaon -avug
+  fi
+fi
+
+# Start the SASL authentication server.  This provides SASL
+# authentication services for sendmail:
+if [ -x /etc/rc.d/rc.saslauthd ]; then
+  . /etc/rc.d/rc.saslauthd start
+fi
+
+# Start the sendmail daemon:
+if [ -x /etc/rc.d/rc.sendmail ]; then
+  . /etc/rc.d/rc.sendmail start
+fi
+
+# Load ALSA (sound) defaults:
+if [ -x /etc/rc.d/rc.alsa ]; then
+  . /etc/rc.d/rc.alsa
+fi
+
+# Load a custom screen font if the user has an rc.font script.
+if [ -x /etc/rc.d/rc.font ]; then
+  . /etc/rc.d/rc.font
+fi
+
+# Load a custom keymap if the user has an rc.keymap script.
+if [ -x /etc/rc.d/rc.keymap ]; then
+  . /etc/rc.d/rc.keymap
+fi
+
+# Start the MySQL database:
+if [ -x /etc/rc.d/rc.mysqld ]; then
+  . /etc/rc.d/rc.mysqld start
+fi
+
+# Start Apache web server:
+if [ -x /etc/rc.d/rc.httpd ]; then
+  . /etc/rc.d/rc.httpd start
+fi
+
+# Start OpenLDAP:
+if [ -x /etc/rc.d/rc.openldap ]; then
+  . /etc/rc.d/rc.openldap start
+fi
+
+# Start Samba (a file/print server for Win95/NT machines).
+# Samba can be started in /etc/inetd.conf instead.
+if [ -x /etc/rc.d/rc.samba ]; then
+  . /etc/rc.d/rc.samba start
+fi
+
+# Start the GPM mouse server:
+if [ -x /etc/rc.d/rc.gpm ]; then
+  . /etc/rc.d/rc.gpm start
+fi
+
+# If there are SystemV init scripts for this runlevel, run them.
+if [ -x /etc/rc.d/rc.sysvinit ]; then
+  . /etc/rc.d/rc.sysvinit
+fi
+
+# Start the local setup procedure.
+if [ -x /etc/rc.d/rc.local ]; then
+  . /etc/rc.d/rc.local
+fi
+
+# All done.
+
+EOF
+
+	# Overwrite the default inittab 
+	cat > $rootfs/etc/inittab <<EOF
+#/etc/inittab
+# inittab	This file describes how the INIT process should set up
+#		the system in a certain run-level.
+#
+# Version:	@(#)inittab		2.04	17/05/93	MvS
+#                                       2.10    02/10/95        PV
+#                                       3.00    02/06/1999      PV
+#                                       4.00    04/10/2002      PV
+#                                      13.37    2011-03-25      PJV
+#
+# Author:	Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
+# Modified by:	Patrick J. Volkerding, <volkerdi@slackware.com>
+#
+
+# These are the default runlevels in Slackware:
+#   0 = halt
+#   1 = single user mode
+#   2 = unused (but configured the same as runlevel 3)
+#   3 = multiuser mode (default Slackware runlevel)
+#   4 = X11 with KDM/GDM/XDM (session managers)
+#   5 = unused (but configured the same as runlevel 3)
+#   6 = reboot
+
+# Default runlevel. (Do not set to 0 or 6)
+id:3:initdefault:
+
+# System initialization (runs when system boots).
+si:S:sysinit:/etc/rc.d/rc.S
+
+# Script to run when going single user (runlevel 1).
+su:1S:wait:/etc/rc.d/rc.K
+
+# Script to run when going multi user.
+rc:2345:wait:/etc/rc.d/rc.M
+
+# Runlevel 0 halts the system.
+l0:0:wait:/etc/rc.d/rc.0
+
+# Runlevel 6 reboots the system.
+l6:6:wait:/etc/rc.d/rc.6
+
+
+# These are the standard console login getties in multiuser mode:
+c1:12345:respawn:/sbin/mingetty tty1
+c2:12345:respawn:/sbin/mingetty tty2
+
+
+# End of /etc/inittab
+EOF
+	
+	# Overwrite the default rc.local
+	cat > rc.local <<EOF
+#!/bin/sh
+# rc.local
+# This file is provided for custom initialisation because
+# Admin is not encouraged to touch rc.S or rc.M.
+#
+# This file is launched on the end of entering multi user mode (2-5)
+# load functions
+. /etc/rc.d/functions-display
+
+PATH="/bin:/sbin:/usr/bin:/usr/sbin:\$PATH"
+/etc/rc.d/rc.inet1 start >/dev/null 2>&1
+
+EOF
+
+	# Link rc.6 to rc.0
+	ln -sf rc.6 rc.0
+)
+}
+
+function pkglist() {
+	PKGLIST=""
+	case $VL_VERSION in
+		"7.0")
+		PKGLIST="aaa_base aaa_elflibs aaa_terminfo bash bin bzip2 coreutils \
+dhcpcd dialog diffutils e2fsprogs nano etc findutils gawk glibc-solibs gnupg grep \
+gzip iputils logrotate net-tools network-scripts ncurses openssh pkgtools-tukaani \
+procps sed shadow sharutils sysklogd sysvinit sysvinit-functions tar udev \
+util-linux wget which xz vlinit slapt-get file openssl curl gpgme libgpg-error libassuan \
+cyrus-sasl traceroute mingetty rtmpdump"
+		;;
+		"7.1")
+		PKGLIST="aaa_base aaa_elflibs aaa_terminfo bash bin bzip2 coreutils \
+dhcpcd dialog diffutils e2fsprogs nano etc findutils gawk glibc gnupg grep \
+gzip iputils logrotate net-tools network-scripts ncurses openssh pkgtools-tukaani \
+procps sed shadow sharutils sysklogd sysvinit sysvinit-functions tar udev \
+util-linux wget which xz vlinit slapt-get file openssl curl gpgme libgpg-error libassuan \
+cyrus-sasl traceroute mingetty zlib"
+		;;
+	esac
+	echo $PKGLIST
+}
+
 function install_vector() {
+	echo "Running some tests on the host ..."
+	res=$(echo $test_host)
+	if [ ! $res = "YES" ]; then
+		echo "This system cannot host a Vectorlinux or VLocity container."
+		echo "HINT:  slapt-get and/or installpkg is missing"
+		exit 1
+	fi
 	path=$1
 	name=$2
-	_CACHE=$path/cache 
+	_CACHE=$VL_CACHE #$path/cache 
 	mkdir -p $_CACHE || exit 1
 	_SLAPTGETRC=${_SLAPTGETRC:-"$_CACHE/slapt-getrc.lxc"}
 	_ROOT=$path/rootfs
 
-	# Download the system files we will need to replace
-	#if [ "$SYSFILES"=="file://*" ]; then
-#		echo "$SYSFILES" | sed -s "|file:\/\/||g"
-	for sfile in rc.S rc.6 rc.M rc.inet1 inittab; do
-		(cd $_CACHE
-		if [ "$SYSFILES"=="file:*" ]; then
-			fpath=$(echo "$SYSFILES" | cut -f 3- -d /)/$sfile
-			#fpath=$(sed 's "|file:\/\/||g" $SYSFILES) #$(echo $SYSFILES | sed -s '|file:||')
-			cp $fpath .
-		else
-			wget $SYSFILES/$file
-		fi
-		)
+	# WRITE SLAPT-GETRC
+	rm -f $_SLAPTGETRC # Remove old one just in case
+	for line in $(echo `slaptconfig`); do
+		echo $line >> $_SLAPTGETRC
 	done
 
-cat <<FIN > $_SLAPTGETRC
-WORKINGDIR=$_CACHE/veclinux/packages
-EXCLUDE=kernel,kernel-ide,kernel-source,kernel-headers,kernel-modules
-SOURCE=http://vectorlinux.osuosl.org/$REPO_RELDIR/packages
-FIN
-
-PKGLIST="aaa_base \
-aaa_elflibs \
-aaa_terminfo \
-bash \
-bin \
-bzip2 \
-coreutils \
-dhcpcd \
-dialog \
-diffutils \
-e2fsprogs \
-nano \
-etc \
-findutils \
-gawk \
-glibc-solibs \
-gnupg \
-grep \
-gzip \
-iputils \
-logrotate \
-net-tools \
-network-scripts \
-ncurses \
-openssh \
-pkgtools-tukaani \
-procps \
-sed \
-shadow \
-sharutils \
-sysklogd \
-sysvinit \
-sysvinit-functions \
-tar \
-udev \
-util-linux \
-wget \
-which \
-xz \
-slapt-get openssl curl gpgme libgpg-error libassuan \
-cyrus-sasl traceroute mingetty"
-
+# Get the package list for the desired version
+PKGLIST=$(echo `pkglist`)
 
 mkdir -p $_ROOT/rootfs
 # Clean out previous installs
 	slapt-get -c $_SLAPTGETRC -i -d --no-dep --reinstall $component || exit 1
 done
 
+# Find out what kind of structure we have in the cache dir
+if [ "x$(grep vlcore $_SLAPTGETRC)" = "x" ]; then
+	cache_base="$_CACHE/veclinux/packages/*"
+else
+	cache_base="$_CACHE/veclinux/packages"
+fi
 # Install the stuff
 for component in $PKGLIST; do
-	# find $_CACHE -name '$component-*.t?z' -exec installpkg -R $_ROOT {} || exit 1 \;
-	installpkg -R $_ROOT $_CACHE/veclinux/packages/*/$component-*.t?z || exit 1
+	installpkg -R $_ROOT $cache_base/$component-*.t?z || exit 1
 done
 
-# install the stuff from cache
-for file in rc.S rc.M rc.6 rc.inet1; do
-	cat $_CACHE/$file > $_ROOT/etc/rc.d/$file
-	chmod a+x $_ROOT/etc/rc.d/$file
-done
-cat $_CACHE/inittab > $_ROOT/etc/inittab
+# Write patches for rc scripts to $rootfs/tmp
+write_rcfile_patches $path/rootfs $name
+
+# Fix the init system in the container
+configure_container_init $_ROOT $name
+
+# Write the default /etc/passwd file
+cat > $_ROOT/etc/passwd <<EOF
+root:x:0:0:root:/root:/bin/bash
+sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
+EOF
+
+# Install the slapt-getrc used for install in the target
+cat $_SLAPTGETRC > $_ROOT/etc/slapt-get/slapt-getrc
+# Fix the working dir in the containers slapt-getrc
+sed -i "s|WORKINGDIR=.*|WORKINGDIR=/home/ftp/pub/veclinux/packages|g" $_ROOT/etc/slap-tget/slapt-getrc
+
+# Write a fake vector version
+echo "VectorLinux | VLocity $VL_VECTION $VL_ARCH LXC Container installed on $(date +%D)" > $_ROOT/etc/vector-version
+
+# Touch a fake vlconfig2 because packaging requires this
+if [ ! $VL_VERSION = "x86" ]; then
+	pkgarch="x86_64"
+else
+	pkgarch="i586"
+fi
+	
+touch $_ROOT/var/log/packages/vlconfig2-${VL_VERSION}-${pkgarch}-1vl$(echo $VL_VERSION |sed 's|\.||g')
 
 #cleanup the cache dir
-#rm -rf $_CACHE
+rm -rf $_CACHE
 }
 
 function configure_container() {
 none $rootfs/sys     sysfs  defaults 0 0
 none /dev/shm tmpfs  defaults 0 0
 EOF
-
-	# RC.S
-	# Install this RC.S file into the container
-	#mv $rootfs/etc/rc.d/rc.S $rootfs/etc/rc.d/rc.S.old
-	#chmod -x $rootfs/etc/rc.d/rc.S.old
-	#cat $CWD/rc.S $rootfs/etc/rc.d/rc.S
-	#chmod +x $rootfs/etc/rc.d/rc.S
-	# RC.6
-	# Install this RC.6 file in the container
-	#mv $rootfs/etc/rc.d/rc.6 $rootfs/etc/rc.d/rc.6.old
-	#chmod -x $rootfs/etc/rc.d/rc.6.old
-	#cat $CWD/rc.6 > /etc/rc.d/rc.6
-	#chmod +x $rootfs/etc/rc.d/rc.6
-
-	# RC.M
-	#mv $rootfs/etc/rc.d/rc.M $rootfs/etc/rc.d/rc.M.old
-	#chmod -x $rootfs/etc/rc.d/rc.M.old
-	#cat $CWD/rc.M > $rootfs/etc/rc.d/rc.M
-	#chmod +x $rootfs/etc/rc.d/rc.M
-	
-	#	mv $rootfs/etc/rc.d/rc.inet1 $rootfs/etc/rc.d/rc.inet1.old
-	#	chmod a-x $rootfs/etc/rc.d/rc.inet1.old
-	#cat $CWD/rc.inet1 > $rootfs/etc/rc.d/rc.inet1
-	#chmod a+x $rootfs/etc/rc.d/rc.inet1
-	
-	# install modified initttab
-	#cat $CWD/inittab > $rootfs/etc/inittab
-	# install the default container config file
 	
 		cat >$rootfs/../config <<CONTCONFIG
 lxc.network.type = veth
 lxc.network.flags = up
-lxc.network.link = br0
+lxc.network.link = virbr0
 lxc.network.hwaddr = 02:aa:11:bb:2c:1E
 
 lxc.utsname = @UTSNAME@
 	rootpath=$1
 	contname=$2
 	install_vector $rootpath $contname
-	configure_container $rootpath/rootfs vl7
+	configure_container $rootpath/rootfs "vector"
 	# fix the config file
 	conf=$rootpath/config
 	sed -i "s|@UTSNAME@|${contname}|g" $conf

File src/rc.6

-#! /bin/sh
-#
-# rc.6		This file is executed by init when it goes into runlevel
-#		0 (halt) or runlevel 6 (reboot). It kills all processes,
-#		unmounts file systems and then either halts or reboots.
-#
-# Version:	@(#)/etc/rc.d/rc.6	2.47 Sat Jan 13 13:37:26 PST 2001
-#
-# Author:	Miquel van Smoorenburg <miquels@drinkel.nl.mugnet.org>
-# Modified by:  Patrick J. Volkerding, <volkerdi@slackware.com>
-#
-
-# Set the path.
-PATH=/sbin:/etc:/bin:/usr/bin
-
-# If there are SystemV init scripts for this runlevel, run them.
-if [ -x /etc/rc.d/rc.sysvinit ]; then
-  . /etc/rc.d/rc.sysvinit
-fi
-
-# Set linefeed mode to avoid staircase effect.
-/bin/stty onlcr
-
-echo "Running shutdown script $0:"
-
-# Find out how we were called.
-case "$0" in
-	*0)
-		command="halt"
-		;;
-	*6)
-		command=reboot
-		;;
-	*)
-		echo "$0: call me as \"rc.0\" or \"rc.6\" please!"
-		exit 1
-		;;
-esac
-
-## Save the system time to the hardware clock using hwclock --systohc.
-#if [ -x /sbin/hwclock ]; then
-#  # Check for a broken motherboard RTC clock (where ioports for rtc are
-#  # unknown) to prevent hwclock causing a hang:
-#  if ! grep -q -w rtc /proc/ioports ; then
-#    CLOCK_OPT="--directisa"
-#  fi
-#  if grep -q "^UTC" /etc/hardwareclock 2> /dev/null ; then
-#    echo "Saving system time to the hardware clock (UTC)."
-#    /sbin/hwclock $CLOCK_OPT --utc --systohc
-#  else
-#    echo "Saving system time to the hardware clock (localtime)."
-#    /sbin/hwclock  $CLOCK_OPT --localtime --systohc
-#  fi
-#fi
-
-# Run any local shutdown scripts:
-if [ -x /etc/rc.d/rc.local_shutdown ]; then
-  /etc/rc.d/rc.local_shutdown stop
-fi
-
-# Stop the Apache web server:
-if [ -x /etc/rc.d/rc.httpd ]; then
-  /etc/rc.d/rc.httpd stop
-fi
-
-# Stop the MySQL database:
-if [ -r /var/run/mysql/mysql.pid ]; then
-  . /etc/rc.d/rc.mysqld stop
-fi
-
-# Stop the Samba server:
-if [ -x /etc/rc.d/rc.samba ]; then
-  . /etc/rc.d/rc.samba stop
-fi
-
-# Shut down the NFS server:
-if [ -x /etc/rc.d/rc.nfsd ]; then
-  /etc/rc.d/rc.nfsd stop
-fi
-
-# Shut down the SSH server:
-if [ -x /etc/rc.d/rc.sshd ]; then
-  /etc/rc.d/rc.sshd stop
-fi
-
-# Shut down the SASL authentication daemon:
-if [ -x /etc/rc.d/rc.saslauthd ]; then
-  /etc/rc.d/rc.saslauthd stop
-fi
-
-# Shut down OpenLDAP:
-if [ -x /etc/rc.d/rc.openldap ]; then
-  /etc/rc.d/rc.openldap stop
-fi
-
-# Stop D-Bus:
-if [ -x /etc/rc.d/rc.messagebus ]; then
-  sh /etc/rc.d/rc.messagebus stop
-fi
-
-# Unmount any NFS, SMB, or CIFS filesystems:
-echo "Unmounting remote filesystems."
-/bin/umount -v -a -r -t nfs,smbfs,cifs
-
-# Try to shut down pppd:
-PS="$(ps ax)"
-if echo "$PS" | /bin/grep -q -w pppd ; then
-  if [ -x /usr/sbin/ppp-off ]; then
-    /usr/sbin/ppp-off
-  fi
-fi
-
-# Bring down the networking system, but first make sure that this
-# isn't a diskless client with the / partition mounted via NFS:
-if ! /bin/mount | /bin/grep -q 'on / type nfs' ; then
-  if [ -x /etc/rc.d/rc.inet1 ]; then
-    . /etc/rc.d/rc.inet1 stop
-  fi
-fi
-
-# In case dhcpcd might have been manually started on the command line,
-# look for the .pid file, and shut dhcpcd down if it's found:
-if /bin/ls /etc/dhcpc/*.pid 1> /dev/null 2> /dev/null ; then
-  /sbin/dhcpcd -k 1> /dev/null 2> /dev/null
-  # A little time for /etc/resolv.conf and/or other files to
-  # restore themselves.
-  sleep 2
-fi
-
-# Shut down PCMCIA devices:
-if [ -x /etc/rc.d/rc.pcmcia ]; then
-  . /etc/rc.d/rc.pcmcia stop
-  # The cards might need a little extra time here to deactivate:
-  /bin/sleep 5
-fi
-
-# Turn off process accounting:
-if [ -x /sbin/accton -a -r /var/log/pacct ]; then
-  /sbin/accton off
-fi
-
-# Terminate acpid before syslog:
-if [ -x /etc/rc.d/rc.acpid -a -r /var/run/acpid.pid ]; then # quit
-  . /etc/rc.d/rc.acpid stop
-fi
-
-# Kill all processes.
-# INIT is supposed to handle this entirely now, but this didn't always
-# work correctly without this second pass at killing off the processes.
-# Since INIT already notified the user that processes were being killed,
-# we'll avoid echoing this info this time around.
-if [ ! "$1" = "fast" ]; then # shutdown did not already kill all processes
-  /sbin/killall5 -15 
-  /bin/sleep 5
-  /sbin/killall5 -9
-fi
-
-# Try to turn off quota.
-if /bin/grep -q quota /etc/fstab ; then
-  if [ -x /sbin/quotaoff ]; then
-    echo "Turning off filesystem quotas."
-    /sbin/quotaoff -a
-  fi
-fi
-
-# Carry a random seed between reboots.
-echo "Saving random seed from /dev/urandom in /etc/random-seed."
-# Use the pool size from /proc, or 512 bytes:
-if [ -r /proc/sys/kernel/random/poolsize ]; then
-  /bin/dd if=/dev/urandom of=/etc/random-seed count=1 bs=$(cat /proc/sys/kernel/random/poolsize) 2> /dev/null
-else
-  /bin/dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2> /dev/null
-fi
-/bin/chmod 600 /etc/random-seed
-
-# Before unmounting file systems write a reboot or halt record to wtmp.
-$command -w
-
-# Clear /var/lock/subsys.
-if [ -d /var/lock/subsys ]; then
-  rm -f /var/lock/subsys/*
-fi
-
-# Turn off swap:
-echo "Turning off swap."
-/sbin/swapoff -a
-/bin/sync
-
-# Umount any LVM volumes:
-if /bin/mount | /bin/grep -q '^/dev/mapper/' ; then
-  echo "Unmounting LVM volumes."
-  /bin/umount -v $(/bin/mount | /bin/grep '^/dev/mapper/' | /bin/cut -d ' ' -f 3 | /bin/tac)
-fi
-
-echo "Unmounting local file systems."
-#/bin/umount -v -a -t no,proc,sysfs
-
-# We won't remount ro since we may want to edit from host system
-#
-#echo "Remounting root filesystem read-only."
-#/bin/mount -v -n -o remount,ro /
-
-# This never hurts:
-/bin/sync
-
-# Close any volumes opened by cryptsetup:
-if [ -f /etc/crypttab -a -x /sbin/cryptsetup ]; then
-  cat /etc/crypttab | grep -v "^#" | grep -v "^$" | while read line; do
-    # NOTE: we only support LUKS formatted volumes (except for swap)!
-    LUKS=$(echo $line | tr '\t' ' ' | tr -s ' ' | cut -f1 -d' ')
-    DEV=$(echo $line | tr '\t' ' ' | tr -s ' ' | cut -f2 -d' ')
-    OPTS=$(echo $line | tr '\t' ' ' | tr -s ' ' | cut -f4 -d' ')
-    if /sbin/cryptsetup isLuks $DEV 2>/dev/null ; then
-      echo "Locking LUKS crypt volume '${LUKS}':"
-      /sbin/cryptsetup luksClose ${LUKS}
-    elif echo $OPTS | grep -wq swap ; then
-      # If any of the volumes was used as encrypted swap,
-      # then run mkswap on the underlying device -
-      # in case other Linux installations on this computer should use it:
-      echo "Erasing encrypted swap '${LUKS}' and restoring normal swap on ${DEV}:"
-      /sbin/cryptsetup remove ${LUKS}
-      mkswap $DEV
-    fi
-  done
-fi
-
-# Deactivate LVM volume groups:
-if [ -r /etc/lvmtab -o -d /etc/lvm/backup ]; then
-  echo "Deactivating LVM volume groups:"
-  /sbin/vgchange -an --ignorelockingfailure
-fi
-
-# This never hurts again (especially since root-on-LVM always fails
-# to deactivate the / logical volume...  but at least it was
-# remounted as read-only first)
-/bin/sync
-
-# sleep 3 fixes problems with some hard drives that don't
-# otherwise finish syncing before reboot or poweroff
-/bin/sleep 3
-
-# This is to ensure all processes have completed on SMP machines:
-wait
-
-if [ -x /sbin/genpowerd ]; then
-  # See if this is a powerfail situation:
-  if /bin/egrep -q "FAIL|SCRAM" /etc/upsstatus 2> /dev/null ; then
-    # Signal UPS to shut off the inverter:
-    /sbin/genpowerd -k
-    if [ ! $? = 0 ]; then
-      echo
-      echo "There was an error signaling the UPS."
-      echo "Perhaps you need to edit /etc/genpowerd.conf to configure"
-      echo "the serial line and UPS type."
-      # Wasting 15 seconds of precious power:
-      /bin/sleep 15
-    fi
-  fi
-fi
-
-# Now halt (poweroff with APM or ACPI enabled kernels) or reboot.
-if [ "$command" = "reboot" ]; then
-  echo "Rebooting."
-  /sbin/reboot
-else
-  /sbin/poweroff
-fi

File src/rc.M

-#!/bin/sh
-#
-# rc.M		This file is executed by init(8) when the system is being
-#		initialized for one of the "multi user" run levels (i.e.
-#		levels 1 through 6).  It usually does mounting of file
-#		systems et al.
-#
-# Version:	@(#)/etc/rc.d/rc.M	2.23	Wed Feb 26 19:20:58 PST 2003
-#
-# Author:	Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
-#		Heavily modified by Patrick Volkerding <volkerdi@slackware.com>
-#
-# minor tweaks for an lxc container
-# by Matteo Bernardini <ponce@slackbuilds.org>:
-# a check for a container variable is made to jump sections
-container="lxc"
-
-# Tell the viewers what's going to happen.
-echo "Going multiuser..."
-
-# Update all the shared library links:
-if [ -x /sbin/ldconfig ]; then
-  echo "Updating shared library links:  /sbin/ldconfig &"
-  /sbin/ldconfig &
-fi
-
-# lxc container check
-if [ ! $container = "lxc" ]; then
-
-# Screen blanks after 15 minutes idle time, and powers down in one hour
-# if the kernel supports APM or ACPI power management:
-/bin/setterm -blank 15 -powersave powerdown -powerdown 60
-
-# Set the hostname.
-if [ -r /etc/HOSTNAME ]; then
-  /bin/hostname $(cat /etc/HOSTNAME | cut -f1 -d .)
-else
-  # fall back on this old default:
-  echo "darkstar.example.net" > /etc/HOSTNAME
-  /bin/hostname darkstar
-fi
-
-fi # end container check
-
-# Set the permissions on /var/log/dmesg according to whether the kernel
-# permits non-root users to access kernel dmesg information:
-if [ -r /proc/sys/kernel/dmesg_restrict ]; then
-  if [ $(cat /proc/sys/kernel/dmesg_restrict) = 1 ]; then
-    touch /var/log/dmesg
-    chmod 640 /var/log/dmesg
-  fi
-else
-  touch /var/log/dmesg
-  chmod 644 /var/log/dmesg
-fi
-# Save the contents of 'dmesg':
-/bin/dmesg -s 65536 > /var/log/dmesg
-
-# Initialize PCMCIA devices:
-#
-# NOTE: This used to be started near the top of rc.S so that PCMCIA devices
-# could be fsck'ed along with the other drives.  This had some unfortunate
-# side effects, however, since root isn't yet read-write, and /var might not
-# even be mounted the .pid files can't be correctly written in /var/run and
-# the pcmcia system can't be correctly shut down.  If you want some PCMCIA
-# partition to be mounted at boot (or when the card is inserted) then add
-# the appropriate lines to /etc/pcmcia/scsi.opts.
-#
-# Note that the stuff in /etc/pcmcia/ is only for 2.4.x kernels using
-# 16-bit PCMCIA cards (not 32-bit Cardbus cards!).  For example, with a
-# wireless card you might need to set options in /etc/pcmcia OR in
-# /etc/rc.d/rc.wireless.conf, or even in /etc/rc.d/rc.inet1.conf (with
-# extra options if needed for the encryption key, ESSID, etc.)
-#
-# Hopefully this situation will be unified in the future, but for now
-# that's how it is...
-#
-if [ -x /etc/rc.d/rc.pcmcia ]; then
-  . /etc/rc.d/rc.pcmcia start
-  # The cards might need a little extra time here to initialize.
-  sleep 5
-fi
-
-# Start the system logger.
-if [ -x /etc/rc.d/rc.syslog -a -x /usr/sbin/syslogd -a -d /var/log ]; then
-  . /etc/rc.d/rc.syslog start
-fi
-
-# Update the X font indexes:
-if [ -x /usr/bin/fc-cache ]; then
-  echo "Updating X font indexes:  /usr/bin/fc-cache -f &"
-  /usr/bin/fc-cache -f &
-fi
-
-# Run rc.udev again.  This will start udev if it is not already running
-# (for example, upon return from runlevel 1), otherwise it will trigger it
-# to look for device changes and to generate persistent rules if needed.
-if grep -wq sysfs /proc/mounts && grep -q tmpfs /proc/filesystems ; then
-  if ! grep -wq nohotplug /proc/cmdline ; then
-    if [ -x /etc/rc.d/rc.udev ]; then
-      /bin/sh /etc/rc.d/rc.udev start
-    fi
-  fi
-fi
-
-# Initialize the networking hardware.
-if [ -x /etc/rc.d/rc.inet1 ]; then
-  . /etc/rc.d/rc.inet1
-fi
-
-# Look for additional USB/SCSI/IEEE1394/etc devices on multiple LUNs:
-if [ -x /etc/rc.d/rc.scanluns ]; then
-  . /etc/rc.d/rc.scanluns
-fi
-
-# Start networking daemons:
-if [ -x /etc/rc.d/rc.inet2 ]; then
-  . /etc/rc.d/rc.inet2
-fi
-
-# Mount any additional filesystem types that haven't already been mounted:
-mount -a -v 2> /dev/null | grep -v "already mounted"
-
-# Start the Control Script for automounter:
-if [ -x /etc/rc.d/rc.autofs ]; then
-  sh /etc/rc.d/rc.autofs start
-fi
-
-# Start the Network Time Protocol daemon:
-if [ -x /etc/rc.d/rc.ntpd ]; then
-  sh /etc/rc.d/rc.ntpd start
-fi
-
-# Remove stale locks and junk files (must be done after mount -a!)
-/bin/rm -f /var/lock/* /var/spool/uucp/LCK..* /tmp/.X*lock /tmp/core /core 2> /dev/null
-
-# Remove stale hunt sockets so the game can start.
-if [ -r /tmp/hunt -o -r /tmp/hunt.stats ]; then
-  echo "Removing your stale hunt sockets from /tmp."
-  /bin/rm -f /tmp/hunt*
-fi
-
-# Ensure basic filesystem permissions sanity.
-chmod 755 / 2> /dev/null
-chmod 1777 /tmp /var/tmp
-
-# lxc container check
-if [ ! $container = "lxc" ]; then
-
-# Start APM or ACPI daemon.
-# If APM is enabled in the kernel, start apmd:
-if [ -e /proc/apm ]; then
-  if [ -x /usr/sbin/apmd ]; then
-    echo "Starting APM daemon:  /usr/sbin/apmd"
-    /usr/sbin/apmd
-  fi
-elif [ -x /etc/rc.d/rc.acpid ]; then # otherwise, start acpid:
-  . /etc/rc.d/rc.acpid start
-fi
-
-fi # end container check
-
-# Update any existing icon cache files:
-if find /usr/share/icons 2> /dev/null | grep -q icon-theme.cache ; then
-  for theme_dir in /usr/share/icons/* ; do
-    if [ -r ${theme_dir}/icon-theme.cache ]; then
-      echo "Updating icon-theme.cache in ${theme_dir}..."
-      /usr/bin/gtk-update-icon-cache -t -f ${theme_dir} 1> /dev/null 2> /dev/null &
-    fi
-  done
-  # This would be a large file and probably shouldn't be there.
-  if [ -r /usr/share/icons/icon-theme.cache ]; then
-    echo "Deleting icon-theme.cache in /usr/share/icons..."
-    #/usr/bin/gtk-update-icon-cache -t -f /usr/share/icons 1> /dev/null 2> /dev/null &
-    rm -f /usr/share/icons/icon-theme.cache
-  fi
-fi
-
-# Update mime database:
-if [ -x /usr/bin/update-mime-database -a -d /usr/share/mime ]; then
-  echo "Updating MIME database:  /usr/bin/update-mime-database /usr/share/mime &"
-  /usr/bin/update-mime-database /usr/share/mime 1> /dev/null 2> /dev/null &
-fi
-
-# Start D-Bus:
-if [ -x /etc/rc.d/rc.messagebus ]; then
-  sh /etc/rc.d/rc.messagebus start
-fi
-
-# Start console-kit-daemon:
-if [ -x /etc/rc.d/rc.consolekit ]; then
-  sh /etc/rc.d/rc.consolekit start
-fi
-
-# Start HAL:
-if [ -x /etc/rc.d/rc.hald ]; then
-  sh /etc/rc.d/rc.hald start
-fi
-
-# Start Bluetooth:
-if [ -x /etc/rc.d/rc.bluetooth ]; then
-  sh /etc/rc.d/rc.bluetooth start
-fi
-
-# Start wicd or networkmanager:
-if [ -x /etc/rc.d/rc.wicd -a -x /usr/sbin/wicd ]; then
-  sh /etc/rc.d/rc.wicd start
-elif [ -x /etc/rc.d/rc.networkmanager ]; then
-  sh /etc/rc.d/rc.networkmanager start
-fi
-
-# These GTK+/pango files need to be kept up to date for
-# proper input method, pixbuf loaders, and font support.
-if [ -x /usr/bin/update-gtk-immodules ]; then
-  /usr/bin/update-gtk-immodules --verbose
-fi
-if [ -x /usr/bin/update-gdk-pixbuf-loaders ]; then
-  /usr/bin/update-gdk-pixbuf-loaders --verbose
-fi
-if [ -x /usr/bin/update-pango-querymodules ]; then
-  /usr/bin/update-pango-querymodules --verbose
-fi
-
-# Start dnsmasq, a simple DHCP/DNS server:
-if [ -x /etc/rc.d/rc.dnsmasq ]; then
-  /etc/rc.d/rc.dnsmasq start
-fi
-
-# Start snmpd:
-if [ -x /etc/rc.d/rc.snmpd ]; then
-  /etc/rc.d/rc.snmpd start
-fi
-
-# Start the print spooling system.  This will usually be LPRng (lpd) or CUPS.
-if [ -x /etc/rc.d/rc.cups ]; then
-  # Start CUPS:
-  /etc/rc.d/rc.cups start
-elif [ -x /etc/rc.d/rc.lprng ]; then
-  # Start LPRng (lpd):
-  . /etc/rc.d/rc.lprng start
-fi
-
-# Start netatalk. (a file/print server for Macs using Appletalk)
-if [ -x /etc/rc.d/rc.atalk ]; then
-  /etc/rc.d/rc.atalk start
-fi
-
-# Start smartd, which monitors the status of S.M.A.R.T. compatible
-# hard drives and reports any problems.  Note some devices (which aren't
-# smart, I guess ;) will hang if probed by smartd, so it's commented out
-# by default.
-#if [ -x /usr/sbin/smartd ]; then
-#  /usr/sbin/smartd
-#fi
-
-# If we're using udev, make /dev/cdrom and any other optical drive symlinks
-# if some udev rule hasn't made them already:
-if grep -wq sysfs /proc/mounts && grep -q tmpfs /proc/filesystems; then
-  if ! grep -wq nohotplug /proc/cmdline ; then
-    if [ -x /lib/udev/rc.optical-symlinks -a -x /etc/rc.d/rc.udev ]; then
-      /bin/sh /lib/udev/rc.optical-symlinks
-    fi
-  fi
-fi
-
-# Monitor the UPS with genpowerd.
-# To use this, uncomment this section and edit your settings in
-# /etc/genpowerd.conf (serial device, UPS type, etc).  For more information,
-# see "man genpowerd" or the extensive documentation in the
-# /usr/doc/genpower-*/ directory.
-# You'll also need to configure a similar block in /etc/rc.d/rc.6 if you want
-# support for stopping the UPS's inverter after the machine halts.
-#if [ -x /sbin/genpowerd ]; then
-#  echo "Starting genpowerd daemon..."
-#  /sbin/genpowerd
-#fi
-
-# Turn on process accounting.  To enable process accounting, make sure the
-# option for BSD process accounting is enabled in your kernel, and then
-# create the file /var/log/pacct (touch /var/log/pacct).  By default, process
-# accounting is not enabled (since /var/log/pacct does not exist).  This is
-# because the log file can get VERY large.
-if [ -x /sbin/accton -a -r /var/log/pacct ]; then
-  chmod 640 /var/log/pacct
-  /sbin/accton /var/log/pacct
-fi
-
-# Start crond (Dillon's crond):
-# If you want cron to actually log activity to /var/log/cron, then change
-# -l notice to -l info to increase the logging level.
-if [ -x /usr/sbin/crond ]; then
-  /usr/sbin/crond -l notice
-fi
-
-# Start atd (manages jobs scheduled with 'at'):
-if [ -x /usr/sbin/atd ]; then
-  /usr/sbin/atd -b 15 -l 1
-fi
-
-# Slackware-Mini-Quota-HOWTO:
-# To really activate quotas, you'll need to add 'usrquota' and/or 'grpquota' to
-# the appropriate partitions as listed in /etc/fstab.  Here's an example:
-#
-# /dev/hda2      /home      ext3     defaults,usrquota      1   1
-#
-# You'll then need to setup initial quota files at the top of the partitions
-# to support quota, like this:
-# touch /home/aquota.user /home/aquota.group
-# chmod 600 /home/aquota.user /home/aquota.group
-#
-# Then, reboot to activate the system.
-# To edit user quotas, use 'edquota'.  See 'man edquota'.  Also, the
-# official Quota Mini-HOWTO has lots of useful information.  That can be found
-# here:  /usr/doc/Linux-HOWTOs/Quota
-
-# Check quot