Switch default mount point from /lib/live/mount/medium to /run/live/medium
[grml-terminalserver.git] / templates / grub-pxelinux_config
index 3ecd48b..50fc1bd 100644 (file)
 #
 # GLOBAL_README_END
 
-
 # default boot arguments used for both grub and pxelinux
-default_boot_args_="ramdisk_size=16384 root=/dev/ram0 rw \
+if [ -e "$MOUNT_POINT_" ]; then
+    default_boot_args_="root=/dev/nfs rw nfsroot=$IP_:$MOUNT_POINT_ \
+noprompt noeject"
+else
+    default_boot_args_="ramdisk_size=24000 root=/dev/ram0 rw \
 init=/etc/init nfsdir=$IP_:$MOUNT_POINT_ nodhcp noprompt noeject \
 apm=power-off nomce"
-
-# special boot arguments required by grub
-grub_def_boot_args_="/linux26 $default_boot_args_"
+fi
 
 # special boot arguments required by pxelinux
-pxe_def_boot_args_="$default_boot_args_ initrd=minirt26.gz"
-
-# default arguments for framebuffer console
-def_fb_args_="vga=791"
-no_fb_args_="vga=normal"
+pxe_def_boot_args_="$default_boot_args_"
 
 ###
-## create grub config
+## create pxelinux config
 ###
-
-cat >"$TFTPD_DATA_DIR_/menu.lst" <<EOT
-default=0
-timeout=10
-title GRML
-  root (nd)
-  kernel $grub_def_boot_args_ $def_fb_args_ $BOOT_ARGS_
-  initrd /minirt26.gz
-
-title GRML no framebuffer
-  root (nd)
-  kernel $grub_def_boot_args_ $no_fb_args_ $BOOT_ARGS_
-
-title GRML small
-  root (nd)
-  kernel $grub_def_boot_args_ small $def_fb_args_ $BOOT_ARGS_
-  initrd /minirt26.gz
-
-title GRML small nofb
-  root (nd)
-  kernel $grub_def_boot_args_ small $no_fb_args_ $BOOT_ARGS_
-  initrd /minirt26.gz
-
-title GRML debuginit
-  root (nd)
-  kernel $grub_def_boot_args_ debuginitrd $def_fb_args_ $BOOT_ARGS_
-  initrd /minirt26.gz
-
-title GRML debuginit nofb
-  root (nd)
-  kernel $grub_def_boot_args_ debuginitrd $no_fb_args_ $BOOT_ARGS_
-  initrd /minirt26.gz
-
-title GRML rescue
-  root (nd)
-  kernel $grub_def_boot_args_ $no_fb_args_
-  initrd /minirt26.gz
-
-title memtest
-  root (nd)
-  kernel /memtest
-
-title Reload config
-  configfile (nd)/menu.lst
+DEST_DIR=$(mktemp -d)
+if [ -d /run/live/medium ] ; then # since December 2018
+  grml2usb --bootloader-only \
+      --bootoptions="$pxe_def_boot_args_ $BOOT_ARGS_" \
+      --remove-bootoption=nodhcp \
+      /run/live/medium "$DEST_DIR"
+
+  mv "$DEST_DIR"/boot/syslinux/* "$TFTPD_DATA_DIR_/"
+  rmdir "$DEST_DIR"/boot/syslinux
+
+  mv "$DEST_DIR"/boot/ "$TFTPD_DATA_DIR_"
+elif [ -d /lib/live/mount/medium ] ; then
+  grml2usb --bootloader-only \
+      --bootoptions="$pxe_def_boot_args_ $BOOT_ARGS_" \
+      --remove-bootoption=nodhcp \
+      /lib/live/mount/medium "$DEST_DIR"
+
+  mv "$DEST_DIR"/boot/syslinux/* "$TFTPD_DATA_DIR_/"
+  rmdir "$DEST_DIR"/boot/syslinux
+
+  mv "$DEST_DIR"/boot/ "$TFTPD_DATA_DIR_"
+else
+  if [ ! -d /usr/share/grml-live/templates/boot/isolinux ] ; then
+    echo "E: Could not find isolinux directory, can not operate without.
+
+Did you boot the system with the toram=... boot option? If so please
+either do not use the toram boot option at all or use boot option toram
+without any arguments (just \"toram\" instead of \"toram=...\")." >&2
+    exit 2
+  fi
+
+  array=( $(cat /etc/grml_version) )
+  grml_name_=${array[0]}
+  grml_version_=${array[1]}
+
+  cp /usr/share/grml-live/templates/boot/isolinux/* "$TFTPD_DATA_DIR_/"
+
+  config_files_=$(find "$TFTPD_DATA_DIR_/" -name "*.cfg" -type f)
+  sed -i "s/%ARCH%/$(uname -m)/" $config_files_
+  sed -i "s/%BOOTID%/$RANDOM/" $config_files_
+  sed -i "s/%SHORT_NAME%/dummy/" $config_files_
+  sed -i "s/%VERSION%/$grml_version_/" $config_files_
+  sed -i "s/%GRML_NAME%/$grml_name_/" $config_files_
+  sed -i "s/%DISTRI_SPLASH%/grml.png/" $config_files_
+  sed -i "s/%DISTRI_INFO%/Grml/" $config_files_
+  sed -i "s#\(^.*append.*initrd.*$\)#\1 $pxe_def_boot_args_ $BOOT_ARGS_#" $config_files_
+  cat > "$TFTPD_DATA_DIR_/grmlmain.cfg"<<EOT
+  include default.cfg
+include menuoptions.cfg
+include grml.cfg
+include options.cfg
+include isoprompt.cfg
+include hd.cfg
+include hidden.cfg
 EOT
 
-ret_=$?
+fi
 
+# Copy initrd.img and vmlinuz from all directories which name begins
+# with grml, e.g. grml32full and grml64full
+# This way we can boot multiple ISOs
+for filename in "${MULTIBOOT_PATH_}"/grml* ; do
+  [ -d "$filename" ] || continue
+  cp -r "${filename}" "${TFTPD_DATA_DIR_}/boot/"
+done
 
-###
-## create pxelinux config
-###
+config_files_=$(find "$TFTPD_DATA_DIR_/" -name "*.cfg" -type f)
 
-cat >"$TFTPD_DATA_DIR_/pxelinux.cfg/default" <<EOT
-DEFAULT linux26
-APPEND $pxe_def_boot_args_ $def_fb_args_ $BOOT_ARGS_
-TIMEOUT 100
-PROMPT 1
-DISPLAY boot.msg
-F1 boot.msg
-LABEL grml
-KERNEL linux26
-APPEND $pxe_def_boot_args_ $def_fb_args_ $BOOT_ARGS_
-LABEL grmlnofb
-KERNEL linux26
-APPEND $pxe_def_boot_args_ $no_fb_args_ $BOOT_ARGS_
-LABEL small
-KERNEL linux26
-APPEND $pxe_def_boot_args_ small $def_fb_args_ $BOOT_ARGS_
-LABEL smallnofb
-KERNEL linux26
-APPEND $pxe_def_boot_args_ small $no_fb_args_ $BOOT_ARGS_
-LABEL debuginit
-KERNEL linux26
-APPEND $pxe_def_boot_args_ debuginit $def_fb_args_ $BOOT_ARGS_
-LABEL debuginit
-KERNEL linux26
-APPEND $pxe_def_boot_args_ debuginit $no_fb_args_ $BOOT_ARGS_
-LABEL rescue
-KERNEL linux26
-APPEND $pxe_def_boot_args_ $no_fb_args_
-LABEL memtest
-KERNEL memtest
-APPEND initrd=
+# cd is multi iso, grml2usb got it right ;0
+if [ -d "$MOUNT_POINT_"/boot/release ] ; then
+   sed -i -e 's#\(.*\)/boot/\(.*\)#\1\2#' $config_files_
+fi
 
-EOT
+# adjust ldbsd.com bootline
+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
+
+# remove grub entries
+rm -f "$TFTPD_DATA_DIR_/"addon_*grub*.cfg
+
+mv "$TFTPD_DATA_DIR_/syslinux.cfg" "$TFTPD_DATA_DIR_/pxelinux.cfg/default"
+rm -rf "$DEST_DIR"
 
 let ret_=$ret_+$?
 return $ret_