[Fai-commit] r3475 - in people/mugwump/vserver: . examples/simple/class examples/simple/debconf examples/simple/files/etc examples/simple/hooks examples/simple/package_config examples/simple/scripts examples/simple/scripts/VSCHILD examples/simple/scripts/VSHOST

fai-commit at lists.alioth.debian.org fai-commit at lists.alioth.debian.org
Thu Jun 8 15:07:20 UTC 2006


Author: samv-guest
Date: 2006-05-02 20:57:18 +0000 (Tue, 02 May 2006)
New Revision: 3475

Added:
   people/mugwump/vserver/examples/simple/class/vschild1.var
   people/mugwump/vserver/examples/simple/class/vschild2.var
   people/mugwump/vserver/examples/simple/class/vschild3.var
   people/mugwump/vserver/examples/simple/class/vshost.var
   people/mugwump/vserver/examples/simple/debconf/VSCHILD
   people/mugwump/vserver/examples/simple/files/etc/resolv.conf/
   people/mugwump/vserver/examples/simple/hooks/finish.VSHOST
   people/mugwump/vserver/examples/simple/hooks/subroutines
   people/mugwump/vserver/examples/simple/package_config/VSCOMMON
   people/mugwump/vserver/examples/simple/package_config/VSHOST
   people/mugwump/vserver/examples/simple/scripts/VSCHILD/
   people/mugwump/vserver/examples/simple/scripts/VSCHILD/10-misc
   people/mugwump/vserver/examples/simple/scripts/VSCHILD/20-misc
   people/mugwump/vserver/examples/simple/scripts/VSHOST/
   people/mugwump/vserver/examples/simple/scripts/VSHOST/10-misc
Modified:
   people/mugwump/vserver/
   people/mugwump/vserver/examples/simple/class/50-host-classes
Log:
Add base work of Brian Showalter's for vserver support



Property changes on: people/mugwump/vserver
___________________________________________________________________
Name: svk:merge
   - d29f7b36-84ff-0310-85ce-ba787dbd31ca:/local/fai/people/mugwump/vserver:8123
   + d29f7b36-84ff-0310-85ce-ba787dbd31ca:/local/fai/people/mugwump/vserver:8124

Modified: people/mugwump/vserver/examples/simple/class/50-host-classes
===================================================================
--- people/mugwump/vserver/examples/simple/class/50-host-classes	2006-05-02 20:56:55 UTC (rev 3474)
+++ people/mugwump/vserver/examples/simple/class/50-host-classes	2006-05-02 20:57:18 UTC (rev 3475)
@@ -12,6 +12,16 @@
 	echo "FAIBASE DHCPC DEMO XFREE GNOME";;
     atom*)
 	echo "FAIBASE DHCPC DEMO" ;;
+# from http://faiwiki.informatik.uni-koeln.de/index.php/User:BrianShowalter/Using_FAI_to_install_Linux-vservers
+    vshost)
+        echo "FAIBASE VSHOST VSCOMMON";;
+    vschild1)
+        echo "VSCHILD VSCOMMON APACHE" && exit 0;;
+    vschild2)
+        echo "VSCHILD VSCOMMON MYSQL" && exit 0;;
+    vschild3)
+        echo "VSCHILD VSCOMMON POSTFIX" && exit 0;;
+
     *)
 	echo "FAIBASE DHCPC" ;;
 esac

Added: people/mugwump/vserver/examples/simple/class/vschild1.var
===================================================================
--- people/mugwump/vserver/examples/simple/class/vschild1.var	2006-05-02 20:56:55 UTC (rev 3474)
+++ people/mugwump/vserver/examples/simple/class/vschild1.var	2006-05-02 20:57:18 UTC (rev 3475)
@@ -0,0 +1,4 @@
+vsname="vs1"
+childdev="eth0"
+childip="192.168.0.10"
+childprefix="24"

Added: people/mugwump/vserver/examples/simple/class/vschild2.var
===================================================================
--- people/mugwump/vserver/examples/simple/class/vschild2.var	2006-05-02 20:56:55 UTC (rev 3474)
+++ people/mugwump/vserver/examples/simple/class/vschild2.var	2006-05-02 20:57:18 UTC (rev 3475)
@@ -0,0 +1,4 @@
+vsname="vs2"
+childdev="eth0"
+childip="192.168.0.11"
+childprefix="24"

Added: people/mugwump/vserver/examples/simple/class/vschild3.var
===================================================================
--- people/mugwump/vserver/examples/simple/class/vschild3.var	2006-05-02 20:56:55 UTC (rev 3474)
+++ people/mugwump/vserver/examples/simple/class/vschild3.var	2006-05-02 20:57:18 UTC (rev 3475)
@@ -0,0 +1,4 @@
+vsname="vs3"
+childdev="eth0"
+childip="192.168.0.12"
+childprefix="24"

Added: people/mugwump/vserver/examples/simple/class/vshost.var
===================================================================
--- people/mugwump/vserver/examples/simple/class/vshost.var	2006-05-02 20:56:55 UTC (rev 3474)
+++ people/mugwump/vserver/examples/simple/class/vshost.var	2006-05-02 20:57:18 UTC (rev 3475)
@@ -0,0 +1 @@
+vschildren="vschild1 vschild2 vschild3"

Added: people/mugwump/vserver/examples/simple/debconf/VSCHILD
===================================================================
--- people/mugwump/vserver/examples/simple/debconf/VSCHILD	2006-05-02 20:56:55 UTC (rev 3474)
+++ people/mugwump/vserver/examples/simple/debconf/VSCHILD	2006-05-02 20:57:18 UTC (rev 3475)
@@ -0,0 +1,2 @@
+passwd  passwd/shadow   boolean true
+exim4-config    exim4/dc_eximconfig_configtype  select  local delivery only; not on a network

Added: people/mugwump/vserver/examples/simple/hooks/finish.VSHOST
===================================================================
--- people/mugwump/vserver/examples/simple/hooks/finish.VSHOST	2006-05-02 20:56:55 UTC (rev 3474)
+++ people/mugwump/vserver/examples/simple/hooks/finish.VSHOST	2006-05-02 20:57:18 UTC (rev 3475)
@@ -0,0 +1,54 @@
+#!/bin/sh
+#
+# $FAI_CONFIGDIR/hooks/finish.VSHOST
+#
+# From http://faiwiki.informatik.uni-koeln.de/index.php/User:BrianShowalter/Using_FAI_to_install_Linux-vservers
+#
+# Save hostname and root directory of vserver base
+VSHOST=$HOSTNAME
+VSHOST_IPADDR=$IPADDR
+VSHOST_FAI_ROOT=$FAI_ROOT
+
+# Create vserver base directories
+[ -e $FAI_ROOT/vservers ] || mkdir $FAI_ROOT/vservers
+rm -f $FAI_ROOT/etc/vservers/.defaults/vdirbase
+chroot $FAI_ROOT ln -s /vservers /etc/vservers/.defaults/vdirbase
+chroot $FAI_ROOT setattr --barrier /vservers
+
+mkdir -p $FAI_ROOT/etc/vservers/.defaults/apps/debootstrap
+echo "http://$mirrorhost/debian" >$FAI_ROOT/etc/vservers/.defaults/apps/debootstrap/mirror
+
+# Check whether any vserver children need to be installed
+if [ -n "$vschildren" ]; then
+        for childhost in $vschildren; do
+                HOSTNAME=$childhost
+                hostname $childhost
+                echo "vserver child hostname set to $childhost"
+                sleep 3
+            export HOSTNAME
+
+                task vschild_defclass
+                task defvar
+
+                # Set up FAI_ROOT to point to vserver child root
+                export FAI_ROOT="$VSHOST_FAI_ROOT/vservers/$vsname"
+                export ROOTCMD="chroot $FAI_ROOT"
+                export IPADDR=$childip
+
+                # Variables for cfengine
+                target=$FAI_ROOT
+
+                # Create child vserver
+                task vschild_create
+
+                # Install & configure vserver packages
+                task vschild_install
+        done
+fi
+
+# Restore hostname, IP address and root directory of vserver base
+export HOSTNAME=$VSHOST
+hostname $VSHOST
+export IPADDR=$VSHOST_IPADDR
+export FAI_ROOT=$VSHOST_FAI_ROOT
+export ROOTCMD="chroot $FAI_ROOT"

Added: people/mugwump/vserver/examples/simple/hooks/subroutines
===================================================================
--- people/mugwump/vserver/examples/simple/hooks/subroutines	2006-05-02 20:56:55 UTC (rev 3474)
+++ people/mugwump/vserver/examples/simple/hooks/subroutines	2006-05-02 20:57:18 UTC (rev 3475)
@@ -0,0 +1,71 @@
+#! /bin/bash
+#
+# $FAI_CONFIGDIR/hooks/subroutines
+
+# Custom FAI subroutines to install vserver children
+
+# from http://faiwiki.informatik.uni-koeln.de/index.php/User:BrianShowalter/Using_FAI_to_install_Linux-vservers
+#
+# Written by Brian Showalter
+# 11 Feb 2006
+
+task_vschild_defclass() {
+        # Reevaluate classes
+        fai-class -T $FAI/class $LOGDIR/FAI_CLASSES
+        classes=$(< $LOGDIR/FAI_CLASSES)
+
+    # define classes as: a.b.c.d for cfengine -D
+    # this doesn't work without echo
+    cfclasses=$(echo $classes)
+    cfclasses=${cfclasses// /.}
+    [ "$debug" ] && echo "cfclasses: $cfclasses"
+}
+
+task_vschild_create() {
+        echo "Creating vserver $vsname"
+        local removepkgs="sparc-utils,dhcp-client,lilo,makedev,pcmcia-cs,ppp,pppconfig,pppoe"
+        removepkgs="${removepkgs},pppoeconf,setserial,syslinux,fdutils,libpcap0"
+        removepkgs="${removepkgs},pciutils,ipchains,iptables,jove,nano"
+
+        chroot $VSHOST_FAI_ROOT /usr/sbin/vserver $vsname build -m debootstrap \
+                --hostname $childhost --interface $childdev:$childip/$childprefix -- \
+                -d sarge -m http://$mirrorhost/debian -- --exclude="$removepkgs"
+}
+
+task_vschild_updatebase() {
+        if [ "$FAI_ACTION" = "install" ]; then
+                # Some packages must access /proc even in chroot environment
+                mount -t proc proc $FAI_ROOT/proc
+
+            # if libc is upgraded init u is called in chroot environment and
+            # then init will eat up much cpu time
+            fai-divert -a /sbin/init /usr/sbin/liloconfig /usr/sbin/invoke-rc.d
+            # fake some more programs
+#           fai-divert -a /etc/init.d/nis /sbin/start-stop-daemon
+#           cp /sbin/start-stop-daemon $FAI_ROOT/sbin/start-stop-daemon
+        fi
+
+        # update the apt-get information inside the nfsroot
+        export aptopt='-y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"'
+        $ROOTCMD apt-get $aptopt update
+        $ROOTCMD apt-get $aptopt check
+        [ $? -ne 0 ] && $ROOTCMD apt-get $aptopt -f install </dev/null
+        $ROOTCMD dpkg -C
+        [ $? -ne 0 ] && yes '' | $ROOTCMD dpkg --configure -a
+        # using the above value, causes an error: "dpkg need action"
+        export aptopt=
+        $ROOTCMD apt-get $aptopt -f -y dist-upgrade </dev/null
+        # update dpkg info which packages are available
+        tmp=$($ROOTCMD mktemp)
+        $ROOTCMD apt-cache dumpavail > $FAI_ROOT/$tmp
+        $ROOTCMD dpkg --update-avail $tmp
+        rm -f $FAI_ROOT/$tmp
+}
+
+task_vschild_install() {
+        task debconf
+        task prepareapt
+        task vschild_updatebase
+        task instsoft
+        task configure
+}

Added: people/mugwump/vserver/examples/simple/package_config/VSCOMMON
===================================================================
--- people/mugwump/vserver/examples/simple/package_config/VSCOMMON	2006-05-02 20:56:55 UTC (rev 3474)
+++ people/mugwump/vserver/examples/simple/package_config/VSCOMMON	2006-05-02 20:57:18 UTC (rev 3475)
@@ -0,0 +1,12 @@
+PACKAGES aptitude
+bzip2
+cfengine
+cron
+debconf-utils
+file
+less
+linuxlogo
+rsync
+ssh
+sysutils
+time

Added: people/mugwump/vserver/examples/simple/package_config/VSHOST
===================================================================
--- people/mugwump/vserver/examples/simple/package_config/VSHOST	2006-05-02 20:56:55 UTC (rev 3474)
+++ people/mugwump/vserver/examples/simple/package_config/VSHOST	2006-05-02 20:57:18 UTC (rev 3475)
@@ -0,0 +1,3 @@
+PACKAGES aptitude
+util-vserver
+vserver-debiantools

Added: people/mugwump/vserver/examples/simple/scripts/VSCHILD/10-misc
===================================================================
--- people/mugwump/vserver/examples/simple/scripts/VSCHILD/10-misc	2006-05-02 20:56:55 UTC (rev 3474)
+++ people/mugwump/vserver/examples/simple/scripts/VSCHILD/10-misc	2006-05-02 20:57:18 UTC (rev 3475)
@@ -0,0 +1,35 @@
+#! /bin/sh
+
+# (c) Thomas Lange, 2001-2005, lange at debian.org
+# from http://faiwiki.informatik.uni-koeln.de/index.php/User:BrianShowalter/Using_FAI_to_install_Linux-vservers
+
+error=0 ; trap "error=$((error|1))" ERR
+
+# assuming that make-fai-nfsroot.conf sets
+# FAI_LOCAL_REPOSITORY="deb file:/fai/files packages/"
+# install additional packags that are located in /fai/files/packages/
+if [ -d /fai/files/packages ] && [ ! -f /fai/files/packages/Packages.gz ]; then
+    # Mm. It seems not to be a simple repository. I assume it's configured in sources.list
+    echo "WARNING! Index file Packages.gz is missing in /fai/files/packages."
+fi
+
+fcopy /etc/hostname || echo $HOSTNAME     > $target/etc/hostname
+echo $time_zone    > $target/etc/timezone
+ln -fs /usr/share/zoneinfo/${time_zone} $target/etc/localtime
+
+fcopy -iM /etc/hosts /etc/motd
+
+# set root password
+echo "root:$rootpw" | $ROOTCMD chpasswd --encrypted
+# make /root accessable only by root
+chmod 0700 $target/root
+chown root:root $target/root
+# copy default dotfiles for root account
+fcopy -ir /root
+
+# create keyboard layput table
+$ROOTCMD bash -c "echo 'console-data console-data/keymap/full select $FAI_KEYMAP' | debconf-set-selections"
+$ROOTCMD install-keymap $FAI_KEYMAP || true
+# dumpkeys | gzip -9f >$target/etc/console/boottime.kmap.gz
+
+exit $error

Added: people/mugwump/vserver/examples/simple/scripts/VSCHILD/20-misc
===================================================================
--- people/mugwump/vserver/examples/simple/scripts/VSCHILD/20-misc	2006-05-02 20:56:55 UTC (rev 3474)
+++ people/mugwump/vserver/examples/simple/scripts/VSCHILD/20-misc	2006-05-02 20:57:18 UTC (rev 3475)
@@ -0,0 +1,16 @@
+#! /usr/bin/cfengine
+
+control:
+      OutputPrefix = ("cfengine")
+      actionsequence = ( tidy )
+      EditFileSize = ( 30000 )
+
+tidy:
+      any::
+            ${target}/etc/rc?.d pattern=S??exim4 R=0 age=0
+            ${target}/etc/rc?.d pattern=S??klogd R=0 age=0
+            ${target}/etc/rc?.d pattern=S??makedev R=0 age=0
+            ${target}/etc/rc?.d pattern=S??nfs-common R=0 age=0
+            ${target}/etc/rc?.d pattern=S??portmap R=0 age=0
+            ${target}/etc/rc?.d pattern=S??postfix R=0 age=0
+            ${target}/etc/rc?.d pattern=S??rsync R=0 age=0


Property changes on: people/mugwump/vserver/examples/simple/scripts/VSCHILD/20-misc
___________________________________________________________________
Name: svn:mime-type
   + text/script

Added: people/mugwump/vserver/examples/simple/scripts/VSHOST/10-misc
===================================================================
--- people/mugwump/vserver/examples/simple/scripts/VSHOST/10-misc	2006-05-02 20:56:55 UTC (rev 3474)
+++ people/mugwump/vserver/examples/simple/scripts/VSHOST/10-misc	2006-05-02 20:57:18 UTC (rev 3475)
@@ -0,0 +1,17 @@
+#! /usr/bin/cfengine
+
+control:
+      OutputPrefix = ("cfengine")
+      actionsequence = ( directories editfiles )
+      EditFileSize = ( 30000 )
+
+directories:
+      any::
+            ${target}/vservers mode=1000 owner=0 group=0
+
+editfiles:
+      any::
+            { ${target}/etc/ssh/sshd_config
+                LocateLineMatching "#ListenAddress 0.0.0.0"
+                ReplaceLineWith "ListenAddress ${IPADDR}"
+            }


Property changes on: people/mugwump/vserver/examples/simple/scripts/VSHOST/10-misc
___________________________________________________________________
Name: svn:mime-type
   + text/script




More information about the Fai-commit mailing list