| 1 |
lange |
1370 |
#! /bin/sh |
| 2 |
|
|
|
| 3 |
lange |
1300 |
# $Id$ |
| 4 |
|
|
#********************************************************************* |
| 5 |
|
|
# |
| 6 |
|
|
# subroutines -- useful subroutines for FAI |
| 7 |
|
|
# |
| 8 |
|
|
# This script is part of FAI (Fully Automatic Installation) |
| 9 |
|
|
# (c) 2000-2002 by Thomas Lange, lange@informatik.uni-koeln.de |
| 10 |
|
|
# Universitaet zu Koeln |
| 11 |
|
|
# |
| 12 |
|
|
#********************************************************************* |
| 13 |
|
|
# This program is free software; you can redistribute it and/or modify |
| 14 |
|
|
# it under the terms of the GNU General Public License as published by |
| 15 |
|
|
# the Free Software Foundation; either version 2 of the License, or |
| 16 |
|
|
# (at your option) any later version. |
| 17 |
|
|
# |
| 18 |
|
|
# This program is distributed in the hope that it will be useful, but |
| 19 |
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 |
|
|
# General Public License for more details. |
| 22 |
|
|
# |
| 23 |
|
|
# A copy of the GNU General Public License is available as |
| 24 |
|
|
# `/usr/share/common-licences/GPL' in the Debian GNU/Linux distribution |
| 25 |
|
|
# or on the World Wide Web at http://www.gnu.org/copyleft/gpl.html. You |
| 26 |
|
|
# can also obtain it by writing to the Free Software Foundation, Inc., |
| 27 |
|
|
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 28 |
|
|
#********************************************************************* |
| 29 |
|
|
|
| 30 |
|
|
# source this file, then you have these function available in the shell |
| 31 |
|
|
|
| 32 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 33 |
|
|
die() { |
| 34 |
|
|
|
| 35 |
|
|
# echo comment and exit installation |
| 36 |
|
|
echo "$@" |
| 37 |
|
|
exec bash |
| 38 |
|
|
} |
| 39 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 40 |
|
|
defnop() { |
| 41 |
|
|
|
| 42 |
|
|
# define given list of subroutine names as dummy function; |
| 43 |
|
|
# this will fake unknown commands |
| 44 |
|
|
|
| 45 |
|
|
local name |
| 46 |
|
|
for name in "$@";do |
| 47 |
|
|
eval "$name () { :;}" |
| 48 |
|
|
done |
| 49 |
|
|
} |
| 50 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 51 |
|
|
islinux() { |
| 52 |
|
|
|
| 53 |
|
|
# test is we are running on Linux |
| 54 |
|
|
# [ X$OS_TYPE = X ] && OS_TYPE=`uname -s | tr '[A-Z]' '[a-z]' |
| 55 |
|
|
if [ X$OS_TYPE = Xlinux ]; then |
| 56 |
|
|
return 0 |
| 57 |
|
|
else |
| 58 |
|
|
return 1 |
| 59 |
|
|
fi |
| 60 |
|
|
} |
| 61 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 62 |
|
|
ifclass() { |
| 63 |
|
|
|
| 64 |
lange |
1401 |
[ "$debug" ] && set +vx |
| 65 |
lange |
1300 |
# test if a class is defined |
| 66 |
|
|
local cl |
| 67 |
lange |
1401 |
local ret=1 |
| 68 |
|
|
|
| 69 |
lange |
1300 |
for cl in $classes; do |
| 70 |
lange |
1401 |
[ x$cl = x$1 ] && ret=0 && break |
| 71 |
lange |
1300 |
done |
| 72 |
lange |
1401 |
[ "$debug" ] && set -vx |
| 73 |
|
|
return $ret |
| 74 |
lange |
1300 |
} |
| 75 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 76 |
|
|
create_resolv_conf() { |
| 77 |
|
|
|
| 78 |
lange |
1329 |
# can be an extern script |
| 79 |
lange |
1300 |
# create a resolv.conf using the DHCP or BOOTP information |
| 80 |
|
|
if [ "$DNSSRVS" ]; then |
| 81 |
|
|
[ "$DOMAIN" ] && echo "domain $DOMAIN" >/tmp/etc/resolv.conf |
| 82 |
|
|
for dnshost in $DNSSRVS ; do |
| 83 |
|
|
echo "nameserver $dnshost" >>/tmp/etc/resolv.conf |
| 84 |
|
|
done |
| 85 |
|
|
fi |
| 86 |
|
|
} |
| 87 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 88 |
|
|
rwmount() { |
| 89 |
|
|
|
| 90 |
|
|
# remount partition read/write |
| 91 |
|
|
mount -o rw,remount $1 |
| 92 |
|
|
} |
| 93 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 94 |
|
|
save_dmesg() { |
| 95 |
|
|
|
| 96 |
|
|
dmesg > $LOGDIR/dmesg.log |
| 97 |
|
|
} |
| 98 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 99 |
|
|
wait_for_jobs() { |
| 100 |
|
|
|
| 101 |
lange |
1329 |
# can be an extern script |
| 102 |
lange |
1300 |
# wait for running (background) jobs to finish (e.g. update-auctex-elisp) |
| 103 |
|
|
local i=0 |
| 104 |
|
|
while (jobsrunning); do |
| 105 |
|
|
[ $(($i % 3)) -eq 0 ] && echo "Waiting for background jobs to finish." |
| 106 |
|
|
i=$(($i+1)) |
| 107 |
|
|
sleep 10 |
| 108 |
|
|
done |
| 109 |
|
|
} |
| 110 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 111 |
|
|
task() { |
| 112 |
|
|
|
| 113 |
|
|
# hooks are called before a task is called |
| 114 |
|
|
# if a task is skipped, also its hooks are skipped |
| 115 |
|
|
# a hook can set the flag, so the accociated task is skipped |
| 116 |
|
|
|
| 117 |
|
|
local taskname=$1 |
| 118 |
|
|
|
| 119 |
|
|
[ -f $LOGDIR/skip.$taskname ] || call_hook $taskname |
| 120 |
|
|
|
| 121 |
|
|
if [ -f $LOGDIR/skip.$taskname ]; then |
| 122 |
|
|
# skip task |
| 123 |
|
|
rm $LOGDIR/skip.$taskname |
| 124 |
|
|
[ "$verbose" ] && echo "Skiping task_$taskname" |
| 125 |
|
|
else |
| 126 |
|
|
echo "Calling task_$taskname" |
| 127 |
|
|
task_$taskname |
| 128 |
|
|
fi |
| 129 |
|
|
} |
| 130 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 131 |
|
|
call_hook() { |
| 132 |
|
|
|
| 133 |
|
|
local hook=$1 |
| 134 |
|
|
local cl dflag hfile |
| 135 |
|
|
[ "$debug" ] && dflag="-d" |
| 136 |
|
|
|
| 137 |
|
|
for cl in $classes; do |
| 138 |
|
|
hfile=$FAI/hooks/${hook}.$cl |
| 139 |
|
|
if [ -x $hfile ]; then |
| 140 |
lange |
1415 |
echo -n "Call hook: $hook.$cl" |
| 141 |
lange |
1300 |
# execute the hook |
| 142 |
|
|
$hfile $dflag |
| 143 |
lange |
1415 |
check_status $hfile $? |
| 144 |
lange |
1300 |
fi |
| 145 |
|
|
if [ -x $hfile.source ]; then |
| 146 |
lange |
1415 |
echo -n "Source hook: $hook.$cl.source" |
| 147 |
lange |
1300 |
# source this hook |
| 148 |
|
|
. $hfile.source $dflag |
| 149 |
lange |
1415 |
check_status $hfile.source $? |
| 150 |
lange |
1300 |
fi |
| 151 |
|
|
done |
| 152 |
|
|
} |
| 153 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 154 |
|
|
skiptask() { |
| 155 |
|
|
|
| 156 |
|
|
# mark all given tasks, so they will be skipped |
| 157 |
|
|
local tasklist="$@" |
| 158 |
|
|
local task |
| 159 |
|
|
|
| 160 |
|
|
for task in $tasklist; do |
| 161 |
|
|
> $LOGDIR/skip.$task |
| 162 |
|
|
done |
| 163 |
|
|
} |
| 164 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 165 |
|
|
get_fai_dir() { |
| 166 |
|
|
|
| 167 |
|
|
# get /fai directory; mount it or get it from a cvs repository |
| 168 |
|
|
if [ -z "$FAI_LOCATION" ]; then |
| 169 |
|
|
[ "$debug" ] && echo "Warning $0: \$FAI_LOCATION not defined." |
| 170 |
|
|
get_fai_cvs |
| 171 |
|
|
else |
| 172 |
|
|
mount $romountopt $FAI_LOCATION $FAI && |
| 173 |
|
|
echo "$FAI mounted from $FAI_LOCATION" |
| 174 |
|
|
fi |
| 175 |
|
|
# source user specific subroutines |
| 176 |
|
|
[ -f $FAI/hooks/subroutines ] && . $FAI/hooks/subroutines |
| 177 |
|
|
} |
| 178 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 179 |
|
|
get_fai_cvs() { |
| 180 |
|
|
|
| 181 |
|
|
# subroutine which gets $FAI (/fai) configuration directory from |
| 182 |
|
|
# a cvs repository. You can redefine this subroutine if you need |
| 183 |
|
|
# access via ftp, http, or from a database |
| 184 |
|
|
|
| 185 |
|
|
if [ "$FAI_CVSROOT" ] ; then |
| 186 |
|
|
local TAG="" |
| 187 |
|
|
echo "Checking out CVS" |
| 188 |
|
|
[ -n "$FAI_CVSTAG" ] && TAG="-r $FAI_CVSTAG" |
| 189 |
|
|
export FAI_CONFIG_AREA=$FAI |
| 190 |
|
|
export FAI=/tmp/$(basename $FAI_CONFIG_AREA) |
| 191 |
|
|
|
| 192 |
|
|
[ "$debug" ] && echo "\$FAI now points to $FAI" |
| 193 |
|
|
|
| 194 |
|
|
if [ -d "$FAI_CONFIG_AREA" ] ; then |
| 195 |
|
|
echo "Config found at $FAI_CONFIG_AREA: Copying" |
| 196 |
|
|
cp -a $FAI_CONFIG_AREA $FAI |
| 197 |
|
|
fi |
| 198 |
|
|
cd /tmp |
| 199 |
|
|
cvs -q -d"$FAI_CVSROOT" co -P -d $(basename "$FAI") \ |
| 200 |
|
|
$TAG $FAI_CVSMODULE > $LOGDIR/cvs.log |
| 201 |
|
|
else |
| 202 |
|
|
echo "Warning $0: Neither \$FAI_LOCATION nor \$FAI_CVSROOT are defined." |
| 203 |
|
|
fi |
| 204 |
|
|
} |
| 205 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 206 |
|
|
define_fai_flags() { |
| 207 |
|
|
|
| 208 |
|
|
# FAI_FLAGS are now comma separated, define all flags |
| 209 |
|
|
FAI_FLAGS=`echo $FAI_FLAGS | sed -e 's/,/ /g'` |
| 210 |
|
|
for flag in $FAI_FLAGS; do |
| 211 |
|
|
# define this flag as 1 |
| 212 |
|
|
eval "$flag=1" |
| 213 |
|
|
[ "$verbose" ] && echo "FAI_FLAGS: $flag=1" |
| 214 |
|
|
done |
| 215 |
|
|
} |
| 216 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 217 |
|
|
task_setup() { |
| 218 |
|
|
|
| 219 |
|
|
local flag |
| 220 |
|
|
# set the system time and date using rdate or/and ntpdate |
| 221 |
|
|
[ "$TIMESRVS_1" ] && rdate $TIMESRVS_1 |
| 222 |
|
|
[ "$NTPSRVS_1" ] && ntpdate -b -v $NTPSRVS |
| 223 |
|
|
|
| 224 |
|
|
define_fai_flags |
| 225 |
|
|
|
| 226 |
|
|
DNSDOMAIN=$DOMAIN # cfengine 1.5.3 can't use $DOMAIN |
| 227 |
|
|
devnull=/dev/null |
| 228 |
|
|
[ "$debug" ] && devnull=/dev/console |
| 229 |
|
|
|
| 230 |
|
|
# not yet used, maybe use a hook for that |
| 231 |
|
|
# if [ "$FAI_EXTRA_MOUNT" ]; then |
| 232 |
|
|
# mount $romountopt -n $FAI_EXTRA_MOUNT && echo "$FAI_EXTRA_MOUNT mounted" |
| 233 |
|
|
# fi |
| 234 |
|
|
|
| 235 |
|
|
[ "$createvt" ] && { |
| 236 |
|
|
# create two virtual terminals; acces via alt-F2 and alt-F3 |
| 237 |
|
|
echo "Press ctrl-c to interrupt FAI and to get a shell" |
| 238 |
|
|
openvt -c2 /bin/bash ; openvt -c3 /bin/bash |
| 239 |
|
|
trap 'echo "You can reboot with faireboot";bash' INT QUIT |
| 240 |
|
|
} |
| 241 |
|
|
|
| 242 |
|
|
# start secure shell daemon for remote access |
| 243 |
|
|
[ "$sshd" -a -x /usr/sbin/sshd ] && /usr/sbin/sshd |
| 244 |
|
|
disk_info # get and define all information of local disks |
| 245 |
|
|
|
| 246 |
|
|
# when did FAI start, using localtime |
| 247 |
|
|
RUNDATE=$(date +'%Y%m%d_%H%M%S') |
| 248 |
|
|
|
| 249 |
|
|
cat >> $rcsfaivar <<-EOM |
| 250 |
|
|
RUNDATE=$RUNDATE |
| 251 |
|
|
FAI_ACTION=$FAI_ACTION |
| 252 |
|
|
LOGDIR=$LOGDIR |
| 253 |
|
|
EOM |
| 254 |
|
|
} |
| 255 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 256 |
|
|
task_action() { |
| 257 |
|
|
|
| 258 |
|
|
echo "FAI_ACTION: $FAI_ACTION" |
| 259 |
|
|
case $FAI_ACTION in |
| 260 |
|
|
|
| 261 |
|
|
install) |
| 262 |
|
|
echo Performing FAI installation. All data may be overwritten! |
| 263 |
|
|
task install |
| 264 |
|
|
;; |
| 265 |
|
|
sysinfo) |
| 266 |
|
|
echo Showing system information. |
| 267 |
|
|
task sysinfo |
| 268 |
|
|
die Now you have a shell. |
| 269 |
|
|
;; |
| 270 |
|
|
backup) |
| 271 |
|
|
echo Doing backup of multiple partitions. |
| 272 |
|
|
task backup |
| 273 |
|
|
;; |
| 274 |
|
|
*) |
| 275 |
|
|
if [ -f $FAI/hooks/$FAI_ACTION ]; then |
| 276 |
|
|
echo "Calling user defined action: $FAI_ACTION" |
| 277 |
|
|
$FAI/hooks/$FAI_ACTION |
| 278 |
|
|
else |
| 279 |
|
|
echo "ERROR: User defined action $FAI/hooks/$FAI_ACTION not found." |
| 280 |
|
|
task_faiend |
| 281 |
|
|
fi |
| 282 |
|
|
;; |
| 283 |
|
|
esac |
| 284 |
|
|
} |
| 285 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 286 |
|
|
task_defclass() { |
| 287 |
|
|
|
| 288 |
lange |
1347 |
local class |
| 289 |
lange |
1300 |
|
| 290 |
lange |
1347 |
# new script for defining classes; variables imported: $LOGDIR, $verbose, $debug |
| 291 |
|
|
fai-class $FAI/class $LOGDIR/FAI_CLASSES |
| 292 |
lange |
1300 |
|
| 293 |
lange |
1347 |
classes=`cat $LOGDIR/FAI_CLASSES` |
| 294 |
lange |
1300 |
|
| 295 |
|
|
# also define all classes in reverse order ($revclasses) |
| 296 |
|
|
for class in $classes ; do |
| 297 |
|
|
revclasses="$class $revclasses" |
| 298 |
|
|
done |
| 299 |
|
|
|
| 300 |
|
|
# define classes as: a.b.c.d for cfengine -D |
| 301 |
|
|
# this doesn't work without echo |
| 302 |
|
|
cfclasses=`echo $classes` |
| 303 |
|
|
cfclasses=${cfclasses// /.} |
| 304 |
|
|
[ "$debug" ] && echo "cfclasses: $cfclasses" |
| 305 |
|
|
} |
| 306 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 307 |
|
|
task_defvar() { |
| 308 |
|
|
|
| 309 |
|
|
local class |
| 310 |
|
|
cd $FAI/class |
| 311 |
|
|
for class in $classes ; do |
| 312 |
|
|
if [ -f $class.var ]; then |
| 313 |
|
|
[ "$verbose" ] && echo "Executing $class.var" |
| 314 |
|
|
[ "$debug" ] && set -vx |
| 315 |
|
|
. $class.var </dev/null |
| 316 |
|
|
[ "$debug" ] && set +vx |
| 317 |
|
|
fi |
| 318 |
|
|
done |
| 319 |
|
|
|
| 320 |
|
|
# /fai/class/S* scripts or hooks can write variable definitions |
| 321 |
|
|
# to additonal.var. now source these definitions |
| 322 |
|
|
[ "$debug" ] && set -vx |
| 323 |
|
|
[ -f $LOGDIR/additional.var ] && . $LOGDIR/additional.var |
| 324 |
|
|
[ "$debug" ] && set +vx |
| 325 |
|
|
} |
| 326 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 327 |
|
|
task_mountdisks() { |
| 328 |
|
|
|
| 329 |
|
|
[ ! -f $LOGDIR/$fstab ] && die "No $LOGDIR/$fstab created." |
| 330 |
|
|
if islinux; then |
| 331 |
|
|
# mount swap space |
| 332 |
|
|
local sd vflag |
| 333 |
|
|
[ "$verbose" ] && vflag=-v |
| 334 |
|
|
for sd in $SWAPLIST; do |
| 335 |
|
|
swapon $vflag $sd |
| 336 |
|
|
done |
| 337 |
|
|
fi |
| 338 |
|
|
mount2dir $FAI_ROOT $LOGDIR/$fstab |
| 339 |
|
|
} |
| 340 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 341 |
|
|
task_configure() { |
| 342 |
|
|
|
| 343 |
|
|
# execute all scripts that match the name of a class. |
| 344 |
|
|
# If class is a directory, execute all $class/S[0-9]* scripts in |
| 345 |
|
|
# it, but do not execute files ending in ~ |
| 346 |
|
|
|
| 347 |
|
|
local class f |
| 348 |
|
|
|
| 349 |
|
|
cd $FAI/scripts |
| 350 |
|
|
for class in $classes ; do |
| 351 |
|
|
[ -x $class -a -f $class ] && do_script $class |
| 352 |
|
|
if [ -d $class ]; then |
| 353 |
|
|
for f in `ls $class/S[0-9]*[^~]` ; do |
| 354 |
|
|
[ -x $f -a -f $f ] && do_script $f |
| 355 |
|
|
done |
| 356 |
|
|
fi |
| 357 |
|
|
done |
| 358 |
|
|
} |
| 359 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 360 |
|
|
do_script() { |
| 361 |
|
|
|
| 362 |
|
|
# execute scripts and save their outpu in log files |
| 363 |
|
|
# cfengine, shell, perl and expect scripts are known types |
| 364 |
|
|
local shelldebug file filetype |
| 365 |
|
|
|
| 366 |
|
|
file=$1 |
| 367 |
|
|
|
| 368 |
|
|
cd $FAI/scripts |
| 369 |
|
|
filetype=`file $file` |
| 370 |
|
|
shelldebug= |
| 371 |
|
|
case $filetype in |
| 372 |
|
|
*"Bourne shell script"*) |
| 373 |
|
|
[ "$debug" ] && shelldebug="sh -x" ;; |
| 374 |
|
|
*"Bourne-Again shell script"*) |
| 375 |
|
|
[ "$debug" ] && shelldebug="bash -x" ;; |
| 376 |
|
|
esac |
| 377 |
|
|
|
| 378 |
|
|
case $filetype in |
| 379 |
|
|
|
| 380 |
|
|
*"executable shell script"*|*"/bash script"*|*"Bourne shell script"*|*"Bourne-Again shell script"*) |
| 381 |
lange |
1374 |
echo "Executing $shelldebug shell: $file" |
| 382 |
lange |
1300 |
echo "===== shell: $file =====" >> $LOGDIR/shell.log 2>&1 |
| 383 |
|
|
$shelldebug ./$file >> $LOGDIR/shell.log 2>&1 |
| 384 |
lange |
1415 |
check_status $file $? |
| 385 |
lange |
1300 |
;; |
| 386 |
|
|
|
| 387 |
|
|
*"cfengine script"*) |
| 388 |
|
|
echo "Executing cfengine: $file" |
| 389 |
|
|
echo "===== cfengine: $file =====" >> $LOGDIR/cfengine.log 2>&1 |
| 390 |
|
|
./$file --no-lock -v -f $file -D${cfclasses} >> $LOGDIR/cfengine.log 2>&1 |
| 391 |
lange |
1415 |
check_status $file $? |
| 392 |
lange |
1300 |
;; |
| 393 |
|
|
|
| 394 |
|
|
*"perl script"*) |
| 395 |
lange |
1374 |
echo "Executing perl: $file" |
| 396 |
lange |
1300 |
echo "===== perl: $file =====" >> $LOGDIR/perl.log 2>&1 |
| 397 |
|
|
./$file >> $LOGDIR/perl.log 2>&1 |
| 398 |
lange |
1415 |
check_status $file $? |
| 399 |
lange |
1300 |
;; |
| 400 |
|
|
|
| 401 |
|
|
*"expect script"*) |
| 402 |
lange |
1374 |
echo "Executing expect: $file" |
| 403 |
lange |
1300 |
echo "===== expect: $file =====" >> $LOGDIR/expect.log 2>&1 |
| 404 |
|
|
./$file >> $LOGDIR/expect.log 2>&1 |
| 405 |
lange |
1415 |
check_status $file $? |
| 406 |
lange |
1300 |
;; |
| 407 |
|
|
|
| 408 |
|
|
*) echo "File $file has unsupported type $filetype." ;; |
| 409 |
|
|
esac |
| 410 |
|
|
} |
| 411 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 412 |
|
|
task_savelog() { |
| 413 |
|
|
|
| 414 |
lange |
1369 |
fai-savelog -l |
| 415 |
|
|
fai-savelog -r |
| 416 |
lange |
1300 |
} |
| 417 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 418 |
|
|
task_faiend() { |
| 419 |
|
|
|
| 420 |
|
|
wait_for_jobs |
| 421 |
|
|
echo "Press <RETURN> to reboot or ctrl-c to execute a shell" |
| 422 |
|
|
# reboot without prompting if FAI_FLAG reboot is set |
| 423 |
|
|
[ -z $reboot ] && read |
| 424 |
|
|
echo "Rebooting $HOSTNAME now" |
| 425 |
|
|
cd / |
| 426 |
|
|
sync |
| 427 |
|
|
umount -ar |
| 428 |
|
|
exec reboot -dfi |
| 429 |
|
|
} |
| 430 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 431 |
|
|
task_backup() { |
| 432 |
|
|
|
| 433 |
lange |
1365 |
die "Task backup not yet used. But you can use the hook backup." |
| 434 |
lange |
1300 |
# NOT YET USED. IT'S ONLY AN IDEA |
| 435 |
|
|
|
| 436 |
|
|
# FAI_BACKUP_LIST contains backup options |
| 437 |
|
|
# proposed format: "hda1 hda3 hda12 sda2 '0 0 1 1'" |
| 438 |
|
|
# list of devices list of backup levels |
| 439 |
|
|
# this subroutine is not yet tested, not yet used |
| 440 |
|
|
# It's only an idea how a backup could be made |
| 441 |
lange |
1365 |
# local partition |
| 442 |
lange |
1383 |
# fai-mount-disk |
| 443 |
lange |
1365 |
# for partition in $SAVE_DEVICES ; do |
| 444 |
lange |
1300 |
# tar cf - $FAI_ROOT/$partition | $FAI_REMOTESH -l $LOGUSER $SERVER dd if= of=$HOSTNAME.$partition.tar |
| 445 |
lange |
1365 |
# dump 0f $LOGUSER@$SERVER:backup/$HOSTNAME/$partition.dmp $FAI_ROOT/$partition |
| 446 |
|
|
# done |
| 447 |
lange |
1300 |
} |
| 448 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 449 |
|
|
task_install() { |
| 450 |
|
|
|
| 451 |
|
|
> $stamp |
| 452 |
|
|
|
| 453 |
|
|
save_dmesg |
| 454 |
|
|
load_keymap_consolechars |
| 455 |
|
|
|
| 456 |
|
|
task partition |
| 457 |
|
|
task mountdisks |
| 458 |
|
|
task extrbase |
| 459 |
|
|
task mirror |
| 460 |
|
|
task updatebase |
| 461 |
|
|
task instsoft |
| 462 |
|
|
task configure |
| 463 |
|
|
task finish |
| 464 |
|
|
date |
| 465 |
|
|
echo -e "FAI finished.\a" |
| 466 |
|
|
task chboot |
| 467 |
|
|
|
| 468 |
|
|
rm -f $stamp |
| 469 |
|
|
# save again, because new messages could be created |
| 470 |
|
|
save_dmesg |
| 471 |
|
|
task savelog |
| 472 |
|
|
|
| 473 |
|
|
if [ -f $stamp ]; then |
| 474 |
|
|
echo "Error while executing commands in subshell." |
| 475 |
|
|
echo "$stamp was not removed." |
| 476 |
|
|
die "Please look at the log files in $LOGDIR for errors." |
| 477 |
|
|
fi |
| 478 |
|
|
task faiend |
| 479 |
|
|
} |
| 480 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |