summaryrefslogtreecommitdiffstats
path: root/boot-env/preboot/preboot.sh
blob: 4a05847f988ff5bcfbf07cc5e690bdea49aa337d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/ash
# Copyright (c) 2009 - OpenSLX GmbH
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
#
# If you have any feedback please consult http://openslx.org/feedback and
# send your feedback to feedback@openslx.org
#
# General information about OpenSLX can be found at http://openslx.org
#
# preboot script for user interaction with OpenSLX preloading environment for
# Linux stateless clients

# get configuration
. /etc/initramfs-setup

# we expect to have a system selection dialog file in /preboot/bootmenu.dialog
while [ "x$(cat result)" = "x" ] ; do
  dialog --file bootmenu.dialog 2>result
done
# source the system to boot configuration ($kernel, $initramfs, $append,
# $label)
sysname=$(cat result)
. ./$sysname
sysname=$(readlink $sysname)

echo "0" >result
dialog --no-cancel --menu "Choose Debug Level:" 20 65 10 \
   "0" "no debug output"  \
   "3" "standard debug output" 2>result
   
debuglevel=$(cat result)
if [ x$debuglevel != x0 ]; then
	debug="debug=$debuglevel"
else
    debug=""
fi 

# bring the mac address into the standard format 01-<MAC>
client=$(echo 01-$macaddr|sed "s/:/-/g")
chvt 4
w3m -o confirm_qq=no \
  "$boot_uri/cgi-bin/user_settings.pl?system=${sysname}&preboot_id=${preboot_id}&client=${client}"
chvt 1

# fetch kernel and initramfs of selected system 
wget -O /tmp/kernel $boot_uri/$kernel
wget -O /tmp/initramfs $boot_uri/$initramfs

# read primary IP configuration to pass it on
. /tmp/ipstuff

clear
ash

# start the new kernel with initialramfs and composed cmdline
echo "Booting OpenSLX client $label ..."
kexec -l /tmp/kernel --initrd=/tmp/initramfs \
  --append="$append file=$boot_uri/${preboot_id}/client-config/${sysname}/${client}.tgz $quiet ip=$ip:$siaddr:$router:$subnet:$dnssrv $debug"
kexec -e