summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8140694)
raw | patch | inline | side by side (parent: 8140694)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 24 Nov 2005 13:28:25 +0000 (13:28 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 24 Nov 2005 13:28:25 +0000 (13:28 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2047 594d385d-05f5-0310-b6e9-bd551577e9d8
contrib/fai/get-debconf.sh | [new file with mode: 0755] | patch | blob |
contrib/fai/get-packages.pl | [new file with mode: 0755] | patch | blob |
contrib/fai/goto-fai/diversions/fai | [deleted file] | patch | blob | history |
contrib/fai/goto-fai/diversions/subroutines | [deleted file] | patch | blob | history |
diff --git a/contrib/fai/get-debconf.sh b/contrib/fai/get-debconf.sh
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash
+# Call with:
+# find /path/to/your/debmirror -name \*.deb | xargs ./get-debconf
+# Move result to /etc/gosa/fai/server/debconf.d
+
+[ -d /tmp/debconf.d ] && mkdir /tmp/debconf.d
+for i in $@; do
+ dpkg -e $i /tmp/debconf.d/DEBIAN
+ if [ -f /tmp/debconf.d/DEBIAN/templates ]; then
+ pp=$(basename $i)
+ p=${pp%%_*}
+ echo $p has debconf template
+ mv /tmp/debconf.d/DEBIAN/templates /tmp/debconf.d/$p.templates
+ fi
+done
+
+
diff --git a/contrib/fai/get-packages.pl b/contrib/fai/get-packages.pl
--- /dev/null
@@ -0,0 +1,140 @@
+#!/usr/bin/perl
+
+use strict;
+use File::Path;
+use File::Basename;
+
+# Check for parameters
+if ($ARGV[0] eq ""){
+ die ("Usage: parse-pkg <config-file>\n");
+}
+
+# Generate cache
+gen_cache($ARGV[0]);
+exit 0;
+
+#-----------------------------------------------------------------------------
+
+sub gen_cache
+{
+ my ($conffile)= @_;
+ my $line;
+
+ print "Generating GOsa package cache - this may take some time\n";
+ open(CONFIG, "<$conffile") or die("Failed to open '$conffile' - aborted\n");
+
+ # Read lines
+ while ($line = <CONFIG>){
+ # Unify
+ chop($line);
+ $line =~ s/^\s+//;
+ $line =~ s/^\s+/ /;
+
+ # Strip comments
+ $line =~ s/#.*$//g;
+
+ # Skip empty lines
+ if ($line =~ /^\s*$/){
+ next;
+ }
+
+ # Interpret deb line
+ if ($line =~ /^deb [^\s]+\s[^\s]+\s[^\s]+/){
+ my ($baseurl) = ($line =~ /^deb\s([^\s]+)/);
+ my ($dist) = ($line =~ /^deb\s[^\s]+\s([^\s]+)/);
+ my ($sections) = ($line =~ /^deb\s[^\s]+\s[^\s]+\s(.*)$/);
+
+ my $section;
+ foreach $section (split(" ", $sections)){
+ parse_package_info ("$baseurl", "$dist", "$section");
+ }
+ }
+ }
+
+ close (CONFIG);
+}
+
+#-----------------------------------------------------------------------------
+
+sub parse_package_info
+{
+ my ($baseurl, $dist, $section)= @_;
+ my ($package, $server);
+
+ foreach $package ("Packages.gz"){
+ print ("* trying to retrieve $baseurl/dists/$dist/$section/binary-i386/$package\n");
+
+ ($server)= ($baseurl =~ /^[^\/]+\/\/([^\/]+)\/.*$/);
+ get_package("$baseurl/dists/$dist/$section/binary-i386/$package", "/etc/gosa/fai/$server/$dist/$section");
+ parse_package("/etc/gosa/fai/$server/$dist/$section");
+ last;
+ }
+}
+
+#-----------------------------------------------------------------------------
+
+sub get_package
+{
+ my ($url, $dest)= @_;
+
+ # This is ugly, but I've no time to take a look at "how it works in perl"
+ system("wget '$url' -O '$dest'");
+ system("gzip -cd '$dest' > '$dest.in'");
+ system("rm -f '$dest'");
+
+ return 0;
+}
+
+#-----------------------------------------------------------------------------
+
+sub parse_package
+{
+ my ($path)= @_;
+ my ($name, $desc, $vers, $sect, $line);
+
+ my $tpath= dirname($path);
+ -d "$tpath" || mkpath "$tpath";
+
+ open(PACKAGES, "<$path.in") or die("Failed to open '$path.in' - aborted\n");
+ open(OUT, ">$path") or die("Failed to open '$path' - aborted\n");
+
+ # Read lines
+ while ($line = <PACKAGES>){
+ # Unify
+ chop($line);
+
+ # Use empty lines as a trigger
+ if ($line =~ /^\s*$/){
+ print OUT "$name|$vers|$sect|$desc\n";
+ next;
+ }
+
+ # Trigger for package name
+ if ($line =~ /^Package:\s/){
+ ($name)= ($line =~ /^Package: (.*)$/);
+ next;
+ }
+
+ # Trigger for version
+ if ($line =~ /^Version:\s/){
+ ($vers)= ($line =~ /^Version: (.*)$/);
+ next;
+ }
+
+ # Trigger for description
+ if ($line =~ /^Description:\s/){
+ ($desc)= ($line =~ /^Description: (.*)$/);
+ next;
+ }
+
+ # Trigger for description
+ if ($line =~ /^Section:\s/){
+ ($sect)= ($line =~ /^Section: (.*)$/);
+ next;
+ }
+ }
+
+ close (OUT);
+ close (PACKAGES);
+}
+
diff --git a/contrib/fai/goto-fai/diversions/fai b/contrib/fai/goto-fai/diversions/fai
+++ /dev/null
@@ -1,272 +0,0 @@
-#!/bin/bash
-# $Id: fai,v 1.9 2005/05/05 21:56:24 lange Exp $
-#*********************************************************************
-#
-# fai -- main installation script executed after booting
-#
-# This script is part of FAI (Fully Automatic Installation)
-# (c) 1999-2005 by Thomas Lange, lange@informatik.uni-koeln.de
-# Universitaet zu Koeln
-#
-#*********************************************************************
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# A copy of the GNU General Public License is available as
-# `/usr/share/common-licences/GPL' in the Debian GNU/Linux distribution
-# or on the World Wide Web at http://www.gnu.org/copyleft/gpl.html. You
-# can also obtain it by writing to the Free Software Foundation, Inc.,
-# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#*********************************************************************
-
-#set -xv # for full debugging
-
-export PATH=/usr/local/sbin:/usr/local/bin:/usr/lib/fai:/bin:/sbin:/usr/bin:/usr/sbin:
-# some variables
-export FAI_VERSION="FAI 2.8.4, 25 May 2005"
-rundir=/var/run/fai
-stamp=$rundir/FAI_INSTALLATION_IN_PROGRESS
-romountopt="-o async,noatime,nolock,ro,actimeo=1800"
-fstab=fstab # Solaris uses vfstab
-
-# the type of operating system (linux, sunos)
-oclass=$(uname -s | tr /a-z/ /A-Z/)
-# $classes is now set so we can call hooks before fai-class defines the classes
-classes="DEFAULT $oclass $HOSTNAME LAST"
-faimond=0
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-prcopyleft() {
-
- cat <<-EOF
- -----------------------------------------------------
- Fully Automatic Installation for $osname
- $FAI_VERSION Copyright (c) 1999-2005
-
- Thomas Lange <lange@informatik.uni-koeln.de>
- -----------------------------------------------------
-EOF
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-fai_init() {
-
- local sub osname
- set -a # now export all variables
-
- umask 022
- # read fai.conf
- # linux dir
- [ -f /etc/fai/fai.conf ] && . /etc/fai/fai.conf
- # solaris dir
- [ -f /tmp/install_config/fai/fai.conf ] && . /tmp/install_config/fai/fai.conf
-
- if [ -f /boot/RUNNING_FROM_FAICD ]; then # we are booting from fai cd
- umount /initrd
- romountopt=
- FAI_DEBMIRROR="--bind /media/mirror"
- MNTPOINT=/media/mirror
- FAI_LOCATION=
- fi
-
- # some variables from are not needed any more
- unset NFSROOT FAI_CONFIGDIR installserver
-
- # read subroutine definitions
- sub=/usr/share/fai/subroutines
- [ -f $sub ] && . $sub
- [ -f $sub-$OS_TYPE ] && . $sub-$OS_TYPE
-
- [ -f "$stamp" ] && {
- echo "$0 already running, aborting"
- exit 1
- }
-
- # HG: are we called as an init substitute ?
- DO_INIT_TASKS=0
- [ "$0" = "/etc/init.d/rcS" ] && DO_INIT_TASKS=1
- [ $DO_INIT_TASKS -eq 1 ] && renewclass=1 # always renew class list when installing
-
- # color logo only if initial install
- COLOR_FAI_LOGO=$DO_INIT_TASKS
-
- DEBIAN_FRONTEND=noninteractive
- # local disks are mounted to $FAI_ROOT
- if [ -z "$FAI_ROOT" ] ; then
- [ $DO_INIT_TASKS -eq 1 ] && FAI_ROOT=/tmp/target || FAI_ROOT=/
- fi
- # executed command in the environment of the new system
- ROOTCMD="chroot $FAI_ROOT"
- # no chroot needed
- [ "$FAI_ROOT" = '/' ] && ROOTCMD=
-
- # Solaris has already a writable /tmp directory
- [ "$oclass" = LINUX -a $DO_INIT_TASKS -eq 1 ] && create_ramdisk
- unset oclass
-
- # directory where temporary log files are stored
- # set default value if nothing is set in fai.conf
- if [ -z "$LOGDIR" -a $DO_INIT_TASKS -eq 1 ]; then
- LOGDIR=/tmp/fai
- mkdir -p $LOGDIR
- fi
- [ $DO_INIT_TASKS -eq 0 ] && LOGDIR=$(mktemp -t -d fai.XXXXXX)
- ln -s $LOGDIR $rundir/current_log
-
- # several log files
- diskvar=$LOGDIR/disk_var.sh
- moduleslog=$LOGDIR/modules.log
- rcslog=$LOGDIR/fai.log
-
- # variables for cfengine
- files=$FAI/files
- target=$FAI_ROOT
-
- if [ $DO_INIT_TASKS -eq 1 ]; then
-# trap 'echo "Now rebooting";faireboot' INT QUIT ;
- trap 'echo "Now rebooting";/bin/bash' INT QUIT ;
- else
- trap "echo 'Aborted';rm -f $stamp" INT QUIT ;
- fi
-
- # if HOST was specified on the commandline, set hostname to it
- eval_cmdline
- if [ -n "$HOST" ]; then
- HOSTNAME=$HOST
- hostname $HOST
- echo "Hostname set to $HOST" | tee -a $rcslog
- sleep 3
- fi
- export HOSTNAME
-
- if [ X$OS_TYPE = Xlinux ]; then
- osname='Debian GNU/Linux'
- if [ $DO_INIT_TASKS -eq 1 ]; then
- grep -q '[[:space:]]sysfs' /proc/filesystems && mount -t sysfs sysfs /sys
- ifup lo
- [ -x /sbin/portmap ] && /sbin/portmap
- mount -t devpts devpts /dev/pts
- # add other options for nfs mount of /dev/root to root-path in dhcpd.conf
- mount -o remount,noatime,ro /dev/root /
- cat /proc/kmsg >/dev/tty4 &
- fi
- fi
- if [ X$OS_TYPE = Xsunos ]; then
- osname='Sun Solaris'
- fi
-
- # set red color, but not on some archs
- [ -e /.nocolorlogo ] && COLOR_FAI_LOGO=0
- case $HOSTTYPE in
- sparc*|powerpc*) COLOR_FAI_LOGO=0 ;;
- esac
-
- [ $COLOR_FAI_LOGO -eq 1 ] && echo -ne "\ec\e[1;31m"
-
- prcopyleft | tee -a $rcslog
-
- if [ $COLOR_FAI_LOGO -eq 1 ]; then
- echo -ne "\e[7;0r"
- echo -ne "\e[9B\e[1;m"
- fi
- save_dmesg
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-usage() {
- cat <<-EOF
- fai $FAI_VERSION. Copyright (C) 1999-2005 Thomas Lange
- Usage: $0 [options] [action]
-
- Options:
- -v|--verbose display more information during the update
- -h|--help display this help message
- -N|--new renew list of classes
-EOF
- exit 0
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-fstart() {
-
- # these tasks can define variables, that are needed later
- task confdir
- task setup
- task defclass
- set_disk_info
- task defvar
- [ $DO_INIT_TASKS -eq 1 ] && load_keymap_consolechars
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-# Main routine
-
-export renewclass=0
-# Parse commandline options
-TEMP=$(getopt -o Nhv --long new,help,verbose -n "$0" -- "$@")
-if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
-# Note the quotes around `$TEMP': they are essential!
-eval set -- "$TEMP"
-
-while true ; do
- case "$1" in
- -h|--help)
- shift
- usage
- ;;
- -v|--verbose)
- shift
- verbose=1
- ;;
- -N|--new)
- shift
- renewclass=1
- ;;
- --)
- shift
- break
- ;;
- *)
- echo "$0: command line parsing error ! $@"
- exit 1
- ;;
- esac
-done
-
-fai_init
-
-lpipe=$LOGDIR/logfifo
-mkfifo $lpipe
-tee -a $rcslog < $lpipe &
-# in bash &> redirect stdout and stderr to file
-fstart &> $lpipe
-rm $lpipe
-unset lpipe
-sleep 1 # wait for tee to complete. One second should be ok
-
-# old code
-# {
-# # a bash group command with { does not work on sparc
-# task confdir
-# task setup
-# task defclass
-# task defvar
-# load_keymap_consolechars
-# set_disk_info
-# } > >( tee -a $rcslog ) 2>&1
-
-# override FAI_ACTION if a command line argument is given
-[ "$1" ] && FAI_ACTION=$1
-
-task action 2>&1 | tee -a $rcslog
-
-# not quiet happy with it
-[ "$FAI_CVSROOT" ] && rm -rf $FAI
-rm -rf $LOGDIR
-
-[ -L "$rundir/current_log" ] && rm -f "$rundir/current_log"
-[ -L "$rundir/current_config" ] && rm -f "$rundir/current_config"
-
-echo "End of $0"
diff --git a/contrib/fai/goto-fai/diversions/subroutines b/contrib/fai/goto-fai/diversions/subroutines
+++ /dev/null
@@ -1,449 +0,0 @@
-#! /bin/bash
-
-# $Id: subroutines,v 1.65 2005/04/06 19:03:46 lange Exp $
-#*********************************************************************
-#
-# subroutines -- useful subroutines for FAI
-#
-# This script is part of FAI (Fully Automatic Installation)
-# (c) 2000-2005 by Thomas Lange, lange@informatik.uni-koeln.de
-# Universitaet zu Koeln
-#
-#*********************************************************************
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# A copy of the GNU General Public License is available as
-# `/usr/share/common-licences/GPL' in the Debian GNU/Linux distribution
-# or on the World Wide Web at http://www.gnu.org/copyleft/gpl.html. You
-# can also obtain it by writing to the Free Software Foundation, Inc.,
-# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#*********************************************************************
-
-# source this file, then you have these function available in the shell
-
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-die() {
-
- # echo comment and exit installation
- task_savelog
- echo "$@"
- exec bash
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-defnop() {
-
- # define given list of subroutine names as dummy function;
- # this will fake unknown commands
-
- local name
- for name in "$@";do
- eval "$name () { :;}"
- done
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-ifclass() {
-
- [ "$debug" ] && echo "Test if class $1 is in $classes"
- # test if a class is defined
- local cl
- local ret=1
-
- for cl in $classes; do
- [ x$cl = x$1 ] && ret=0 && break
- done
- [ "$debug" ] && echo "ifclass returns $ret"
- return $ret
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-rwmount() {
-
- # remount partition read/write
- mount -o rw,remount $1
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-save_dmesg() {
-
- dmesg > $LOGDIR/dmesg.log
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-wait_for_jobs() {
-
- # can be an extern script
- # wait for running (background) jobs to finish (e.g. update-auctex-elisp)
- local i=0
- while jobsrunning; do
- [ $(($i % 3)) -eq 0 ] && echo "Waiting for background jobs to finish."
- i=$(($i+1))
- sleep 10
- done
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-task() {
-
- # hooks are called before a task is called
- # if a task is skipped, also its hooks are skipped
- # a hook can set the flag, so the accociated task is skipped
-
- local taskname=$1
-
- [ -f $LOGDIR/skip.$taskname ] || call_hook $taskname
-
- if [ -f $LOGDIR/skip.$taskname ]; then
- # skip task
- rm $LOGDIR/skip.$taskname
- [ "$verbose" ] && echo "Skiping task_$taskname"
- sndmon "TASKSKIP $taskname"
- else
- echo "Calling task_$taskname"
- sndmon "TASKBEGIN $taskname"
- terror=0 # task can set this variable to indicate an error
- task_$taskname
- sndmon "TASKEND $taskname $terror"
- fi
- # since the subroutine is not needed any more, we can undefine it
- unset task_$taskname
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-call_hook() {
-
- local hook=$1
- local cl dflag hfile
- [ "$debug" ] && dflag="-d"
-
- for cl in $classes; do
- hfile=$FAI/hooks/$hook.$cl
- if [ -x $hfile ]; then
- echo "Calling hook: $hook.$cl"
- sndmon "HOOK $hook.$cl"
- # execute the hook
- $hfile $dflag
- check_status $hook.$cl $?
- fi
- if [ -x $hfile.source ]; then
- echo "Source hook: $hook.$cl.source"
- sndmon "HOOK $hook.$cl.source"
- # source this hook
- . $hfile.source $dflag
- check_status $hook.$cl.source $?
- fi
- done
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-skiptask() {
-
- # mark all given tasks, so they will be skipped
- local tasklist="$@"
- local task
-
- for task in $tasklist; do
- > $LOGDIR/skip.$task
- done
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-get_fai_dir() {
-
- /usr/sbin/get_fai_dir
- ln -s $FAI $rundir/current_config
- if [ ! -d $FAI/class ]; then
- echo "WARNING: directory $FAI/class not found."
- fi
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-get_fai_cvs() {
-
- # subroutine which gets $FAI (/fai) configuration directory from
- # a cvs repository. You can redefine this subroutine if you need
- # access via ftp, http, or from a database
-
- if [ "$FAI_CVSROOT" ] ; then
- local TAG=""
- [ -n "$FAI_CVSTAG" ] && TAG="-r $FAI_CVSTAG"
- export FAI_CONFIG_AREA=$FAI_ROOT$FAI
- export FAI=$(mktemp -t -d fai-config.XXXXXX)
-
- [ "$debug" ] && echo "\$FAI now points to $FAI"
-
- if [ -d "$FAI_CONFIG_AREA/CVS" -a -z "$FORCE" ] ; then
- echo "Config found at $FAI_CONFIG_AREA: Copying"
- cp -a $FAI_CONFIG_AREA/. $FAI
- echo "Updating CVS"
- cd $FAI
- cvs -q -d"$FAI_CVSROOT" up -P $TAG -d -C > $LOGDIR/cvs.log
- else
- echo "Checking out CVS"
- cd /tmp
- cvs -q -d"$FAI_CVSROOT" co -P -d $(basename "$FAI") \
- $TAG $FAI_CVSMODULE > $LOGDIR/cvs.log
- fi
- else
- echo "Warning $0: Neither \$FAI_LOCATION nor \$FAI_CVSROOT are defined."
- fi
- cd /
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-define_fai_flags() {
-
- local flag
- # FAI_FLAGS are comma separated, define all flags
- FAI_FLAGS=${FAI_FLAGS//,/ }
- [ "$verbose" ] && echo "FAI_FLAGS: $FAI_FLAGS"
- for flag in $FAI_FLAGS; do
- # define this flag as 1
- eval "$flag=1"
- done
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-task_setup() {
-
- # source user specific subroutines
- [ -f $FAI/hooks/subroutines ] && . $FAI/hooks/subroutines
- if [ $DO_INIT_TASKS -eq 1 ]; then
- # set the system time and date using rdate or/and ntpdate
- [ "$TIMESRVS_1" ] && rdate $TIMESRVS_1
- [ "$NTPSRVS_1" ] && ntpdate -b -v $NTPSRVS
- fi
-
- define_fai_flags
- DNSDOMAIN=$DOMAIN # cfengine 1.5.3 can't use $DOMAIN
-
- if [ $DO_INIT_TASKS -eq 1 ] ; then
- [ "$createvt" ] && {
- # create two virtual terminals; acces via alt-F2 and alt-F3
- echo "Press ctrl-c to interrupt FAI and to get a shell"
- openvt -c2 /bin/bash ; openvt -c3 /bin/bash
- trap 'echo "You can reboot with faireboot";bash' INT QUIT
- }
-
- # start secure shell daemon for remote access
- [ "$sshd" -a -x /usr/sbin/sshd ] && /usr/sbin/sshd
- fi
-
- # when did FAI start, using localtime
- FAI_RUNDATE=$(date +'%Y%m%d_%H%M%S')
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-task_action() {
-
- if [ -z "$FAI_ACTION" ]; then
- echo "No action in \$FAI_ACTION defined."
- sndmon "TASKERROR action 21"
- task_faiend
- exit
- fi
- echo "FAI_ACTION: $FAI_ACTION"
- case $FAI_ACTION in
-
- install)
- if [ $DO_INIT_TASKS -eq 0 ]; then
- echo "Cowardly refusing to run a FAI installation on a running system."
- return
- fi
- echo Performing FAI installation. All data may be overwritten!
- echo -ne "\a"; sleep 1
- echo -ne "\a"; sleep 1
- echo -e "\a"; sleep 5
- task install
- task faiend
- ;;
- softupdate)
- echo Performing FAI system update. All data may be overwritten!
- task softupdate
- ;;
- sysinfo)
- echo Showing system information.
- task sysinfo
- task_faiend
- die Now you have a shell.
- ;;
- *)
- if [ -f $FAI/hooks/$FAI_ACTION ]; then
- echo "Calling user defined action: $FAI_ACTION"
- $FAI/hooks/$FAI_ACTION
- else
- echo "ERROR: User defined action $FAI/hooks/$FAI_ACTION not found."
- sndmon "TASKERROR action 22"
- task_faiend
- fi
- ;;
- esac
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-task_defclass() {
-
- if [ ! -d $FAI/class ]; then
- sndmon "TASKERROR defclass 21"
- echo "Directory $FAI/class not found. Following subdirectories are found:"
- find $FAI -type d -maxdepth 1 -printf "%p\n"
- die "Aborting."
- fi
-
- # new script for defining classes; variables imported: $LOGDIR, $verbose, $debug
- if [ $renewclass -eq 1 ]; then
- # reevaluate new list of classes
- fai-class -T $FAI/class $LOGDIR/FAI_CLASSES
- classes=$(< $LOGDIR/FAI_CLASSES)
- else
- # use classes defined at installation time
- if [ ! -f /var/log/fai/FAI_CLASSES ]; then
- die "Try to read classes from /var/log/fai/FAI_CLASSES. Failed. Aborting."
- fi
- classes=$(< /var/log/fai/FAI_CLASSES)
- fi
-
- # 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_defvar() {
-
- cd $FAI/class
- for class in $classes ; do
- if [ -f $class.var ]; then
- [ "$verbose" ] && echo "Executing $class.var"
- [ "$debug" ] && set -vx
- . $class.var </dev/null
- [ "$debug" ] && set +vx
- fi
- done
-
- # /fai/class/S* scripts or hooks can write variable definitions
- # to additonal.var. now source these definitions
- [ "$debug" ] && set -vx
- [ -f $LOGDIR/additional.var ] && . $LOGDIR/additional.var
- [ "$debug" ] && set +vx
- unset class
- # now all variables are defined. Dump them to variables.sh
- set | perl -ne 'print if /^\w\w+=/' | egrep -v "^BASH_VERSINFO|^EUID|^PPID|^SHELLOPTS|^UID|^rootpw|^HOME|^PWD" > $LOGDIR/variables.sh
- cd /
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-task_mountdisks() {
-
- [ ! -f $LOGDIR/$fstab ] && die "No $LOGDIR/$fstab created."
- # mount swap space
- local sd
- for sd in $SWAPLIST; do
- swapon $sd && [ "$verbose" ] && echo "Enable swap device $sd"
- done
- mount2dir $FAI_ROOT $LOGDIR/$fstab
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-task_configure() {
-
- fai-do-scripts $FAI/scripts
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-task_savelog() {
-
- [ -d $target/var/log/fai ] || mkdir -p $target/var/log/fai
- [ -d $target/var/log/fai ] && fai-savelog -l
- cd $LOGDIR && cp -p FAI_CLASSES variables.sh $diskvar $target/var/log/fai
- fai-savelog -r
- cd /
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-task_faiend() {
-
- [ $DO_INIT_TASKS -eq 0 ] && exit 0
- wait_for_jobs
- echo "Press <RETURN> to reboot or ctrl-c to execute a shell"
- # reboot without prompting if FAI_FLAG reboot is set
- [ -z $reboot ] && read
- echo "Rebooting $HOSTNAME now"
- sndmon REBOOT
- cd /
- sync
-
- case $(uname -s) in
- Linux)
- killall -q sshd
- umount $target/proc
- umount -ar
- exec reboot -dfi
- ;;
- esac
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-task_backup() {
-
- die "Task backup not yet used. But you can use the hook backup."
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-task_install() {
-
- > $stamp
-
- save_dmesg
-
- task partition
- task mountdisks
- task extrbase
- task mirror
- task debconf
- task prepareapt
- task updatebase
- task instsoft
- task configure
- task finish
- task chboot
-
- rm -f $stamp
- # save again, because new messages could be created
- save_dmesg
- task savelog
-
- if [ -f $stamp ]; then
- echo "Error while executing commands in subshell."
- echo "$stamp was not removed."
- sndmon "TASKERROR install 21"
- die "Please look at the log files in $LOGDIR for errors."
- fi
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-task_softupdate() {
-
- > $stamp
-
- save_dmesg
-
- local start_seconds=$(cut -d . -f 1 /proc/uptime)
- task mirror
- task debconf
- task prepareapt
- task updatebase
- task instsoft
- task configure
- date
- echo "The update took $[$(cut -d . -f 1 /proc/uptime)-$start_seconds] seconds."
-
- rm -f $stamp
- # save again, because new messages could be created
- save_dmesg
- task savelog
-
- if [ -f $stamp ]; then
- echo "Error while executing commands in subshell."
- echo "$stamp was not removed."
- sndmon "TASKERROR softupdate 21"
- die "Please look at the log files in $LOGDIR for errors."
- fi
- umount $FAI_ROOT/fai
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-catnc() {
- # cat but no comment lines
- egrep -v "^#" $@
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -