1 # the following variables are available in the template:
3 # $INTERFACE_ (interface for the terminalserver)
4 # $IP_ (ip for the terminalserver to bind)
5 # $NETMASK_ (network mask)
7 # $NAMESERVERS_ (nameservers for the nodes)
8 # $IPRANGE_FROM_ (user configured iprange, first ip)
9 # $IPRANGE_TO_ (user configured iprange, last ip)
10 # $NETWORK_ (first ip in this subnet)
11 # $OPTIONS_ (options for grml-terminalserver)
12 # $BOOT_ARGS_ (boot arguments for the nodes)
15 # templates are shellscript fragments and will be sourced from the
20 if grep -q live-media-path= /proc/cmdline 2>/dev/null ; then
21 live_media_path_="live-media-path=$(awk -F live-media-path= '{print $2}' /proc/cmdline | awk '{print $1}')"
23 if [ ! -d /live/image/boot ] ; then
24 live_media_path_="live-media-path=/"
27 # default boot arguments used for both grub and pxelinux
28 if [ -e "$MOUNT_POINT_" ]; then
29 default_boot_args_="root=/dev/nfs rw nfsroot=$IP_:$MOUNT_POINT_ \
32 default_boot_args_="ramdisk_size=24000 root=/dev/ram0 rw \
33 init=/etc/init nfsdir=$IP_:$MOUNT_POINT_ nodhcp noprompt noeject \
37 # special boot arguments required by grub
38 grub_def_boot_args_="/vmlinuz $default_boot_args_ $live_media_path_"
40 # special boot arguments required by pxelinux
41 pxe_def_boot_args_="$default_boot_args_"
43 # default arguments for framebuffer console
44 def_fb_args_="vga=791"
45 no_fb_args_="vga=normal"
51 cat >"$TFTPD_DATA_DIR_/menu.lst" <<EOT
56 kernel $grub_def_boot_args_ $def_fb_args_ $BOOT_ARGS_
59 title GRML no framebuffer
61 kernel $grub_def_boot_args_ $no_fb_args_ $BOOT_ARGS_
65 kernel $grub_def_boot_args_ small $def_fb_args_ $BOOT_ARGS_
70 kernel $grub_def_boot_args_ small $no_fb_args_ $BOOT_ARGS_
75 kernel $grub_def_boot_args_ debuginitrd $def_fb_args_ $BOOT_ARGS_
78 title GRML debuginit nofb
80 kernel $grub_def_boot_args_ debuginitrd $no_fb_args_ $BOOT_ARGS_
85 kernel $grub_def_boot_args_ $no_fb_args_
93 configfile (nd)/menu.lst
100 ## create pxelinux config
102 DEST_DIR=$(mktemp -d)
103 if [ -d /live/image/boot ] ; then
104 grml2usb --bootloader-only \
105 --bootoptions="$pxe_def_boot_args_ $BOOT_ARGS_" \
106 --remove-bootoption=nodhcp \
107 /live/image "$DEST_DIR"
109 mv "$DEST_DIR"/boot/syslinux/* "$TFTPD_DATA_DIR_/"
110 rmdir "$DEST_DIR"/boot/syslinux
112 mv "$DEST_DIR"/boot/ "$TFTPD_DATA_DIR_"
113 else # there is no kernel inside /live/image copy it from /boot
114 if [ ! -d /usr/share/grml-live/templates/boot/isolinux ] ; then
115 echo "E: Could not find isolinux directory, can not operate without.
117 Did you boot the system with the toram=... boot option? If so please
118 either do not use the toram boot option at all or use boot option toram
119 without any arguments (just \"toram\" instead of \"toram=...\")." >&2
123 array=( $(cat /etc/grml_version) )
124 grml_name_=${array[0]}
125 grml_version_=${array[1]}
127 cp /usr/share/grml-live/templates/boot/isolinux/* "$TFTPD_DATA_DIR_/"
129 config_files_=$(find "$TFTPD_DATA_DIR_/" -name "*.cfg" -type f)
130 sed -i "s/%ARCH%/$(uname -m)/" $config_files_
131 sed -i "s/%BOOTID%/$RANDOM/" $config_files_
132 sed -i "s/%SHORT_NAME%/dummy/" $config_files_
133 sed -i "s/%VERSION%/$grml_version_/" $config_files_
134 sed -i "s/%GRML_NAME%/$grml_name_/" $config_files_
135 sed -i "s/%DISTRI_SPLASH%/grml.png/" $config_files_
136 sed -i "s/%DISTRI_INFO%/Grml/" $config_files_
137 sed -i "s#\(^.*append.*initrd.*$\)#\1 $pxe_def_boot_args_ $BOOT_ARGS_#" $config_files_
138 cat > "$TFTPD_DATA_DIR_/grmlmain.cfg"<<EOT
140 include menuoptions.cfg
143 include isoprompt.cfg
151 config_files_=$(find "$TFTPD_DATA_DIR_/" -name "*.cfg" -type f)
153 # cd is multi iso, grml2usb got it right ;0
154 if [ -d "$MOUNT_POINT_"/boot/release ] ; then
155 sed -i -e 's#\(.*\)/boot/\(.*\)#\1\2#' $config_files_
157 # remove normal kernel path and use our image
158 sed -i -e 's/.*kernel.*vmlinuz/ kernel vmlinuz/' $config_files_
159 sed -i -e 's/\(initrd\)=[[:alnum:]/._-]*/\1=initrd.img/' $config_files_
160 # remove live-media-path per default
161 sed -i -e 's#live-media-path=[[:alnum:]/._-]*##' $config_files_
163 # append live-media-path if needed
164 if [ ! -z "$live_media_path_" ] ; then
165 sed -i -e "s#\(^.*append.*initrd.*$\)#\1 $live_media_path_#" $config_files_
169 # adjust ldbsd.com bootline
170 sed -i -e 's#\(.*kernel .*/ldbsd.com\)#\1 set image /boot/addons/bsd4grml/bsd.rd`echo Type "boot" to load MirOS bsd4grml via keeppxe#' "$TFTPD_DATA_DIR_/"addon_*_bsd.cfg
172 # remove grub entries
173 rm -f "$TFTPD_DATA_DIR_/"addon_*grub*.cfg
175 mv "$TFTPD_DATA_DIR_/syslinux.cfg" "$TFTPD_DATA_DIR_/pxelinux.cfg/default"