Support grml-terminalserver from no boot medium present. [Closes: issue733]
authorUlrich Dangel <mru@grml.org>
Sun, 7 Nov 2010 21:15:27 +0000 (22:15 +0100)
committerUlrich Dangel <mru@grml.org>
Sun, 7 Nov 2010 22:44:09 +0000 (23:44 +0100)
Added fallback for kernel location to /boot. Always use initrd from /boot.
Copy syslinux config from grml-live template directory if no syslinux config is present.
Explicit set fsid to support {ram,tmp}fs.

default_config
grml-terminalserver
grml-terminalserver-config
templates/grub-pxelinux_config

index c6f88fc..cc1ef4b 100644 (file)
@@ -51,9 +51,16 @@ fi
 
 KERNEL_IMAGE_="$MULTIBOOT_PATH_/linux26"
 
+if [[ ! -f "$KERNEL_IMAGE_" ]] ; then
+  KERNEL_IMAGE_="/boot/vmlinuz-$KERNEL_VERSION_"
+fi
+
 ORIGINAL_INITRD_="$MULTIBOOT_PATH_/initrd.gz"
 
 MEMTEST_IMAGE_="$ADDONS_PATH_/memtest"
+if [ ! -f "$MEMTEST_IMAGE_" ] ; then
+  MEMTEST_IMAGE_=$(find /boot -name memtest*.bin | head -n1)
+fi
 
 PXE_BOOT_MSG_="$ISOLIN_PATH_/boot.msg"
 # grml2usb with grub doesn't provide boot.msg, so generate a default one
index 82656f2..d736a8c 100755 (executable)
@@ -211,9 +211,9 @@ function createTftpConf
   else
     execute "install -m 644 $KERNEL_IMAGE_ $TFTPD_DATA_DIR_/linux26" die
   fi
-  execute "install -m 644 $MEMTEST_IMAGE_ $TFTPD_DATA_DIR_/memtest" die
+  [ -f "$MEMTEST_IMAGE" ] && execute "install -m 644 $MEMTEST_IMAGE_ $TFTPD_DATA_DIR_/memtest" die
   execute "install -m 644 $PXE_BOOT_MSG_ $TFTPD_DATA_DIR_" die
-  execute "install -m 644 $PXE_BOOT_LOGO_ $TFTPD_DATA_DIR_" die
+  [ -f "$PXE_BOOT_LOGO_" ] && execute "install -m 644 $PXE_BOOT_LOGO_ $TFTPD_DATA_DIR_" die
 
   execute "source $TEMPLATE_CONFIG_DIR_/grub-pxelinux_config" die
 }
@@ -240,12 +240,12 @@ function runTftp
 # NFS  {{{
 function createNfsConfig
 {
-  execute "exportfs -o ro,no_root_squash,async,nohide $NETWORK_/$NETMASK_:$MOUNT_POINT_" warn
+  execute "exportfs -o ro,no_root_squash,async,nohide,fsid=42 $NETWORK_/$NETMASK_:$MOUNT_POINT_" warn
 }
 
 function removeNfsConfig
 {
-  execute "exportfs -u -o ro,no_root_squash,async,nohide $NETWORK_/$NETMASK_:$MOUNT_POINT_" warn
+  execute "exportfs -u -o ro,no_root_squash,async,nohide,fsid=42 $NETWORK_/$NETMASK_:$MOUNT_POINT_" warn
 }
 
 function startNfs
index 7e7bfb0..8aa0748 100755 (executable)
@@ -120,14 +120,8 @@ function actionMkInitrd
   echo "Installing initrd $PATH_/minirt26.gz:"
   # until we have a stable file location API let's use
   # an according heuristic
-  for file in "$(find /live/image/boot -name initrd.gz)"; do
-    dir="$(dirname $file)"
-    if file "$dir"/linux26 | grep -q "$(uname -r)" ; then
-      cp -u "$dir"/initrd.gz "$PATH_"/minirt26.gz
-      echo '... done'
-      return 0
-    fi
-  done
+  initrd_=initrd.img-"$(uname -r)"
+  cp /boot/"$initrd_" "$PATH_"/minirt26.gz || die "Could not copy /boot/$initrd_"
 }
 
 # }}}
index 6e0dc40..20be1b6 100644 (file)
@@ -97,13 +97,47 @@ ret_=$?
 ## create pxelinux config
 ###
 DEST_DIR=$(mktemp -d)
-grml2usb --bootloader-only \
-    --bootoptions="$pxe_def_boot_args_ $BOOT_ARGS_" /live/image "$DEST_DIR"
+if [ -d /live/image/boot ] ; then
+  grml2usb --bootloader-only \
+      --bootoptions="$pxe_def_boot_args_ $BOOT_ARGS_" /live/image "$DEST_DIR"
+
+  mv "$DEST_DIR"/boot/syslinux/* "$TFTPD_DATA_DIR_/"
+  rmdir "$DEST_DIR"/boot/syslinux
+
+  mv "$DEST_DIR"/boot/ "$TFTPD_DATA_DIR_"
+else # there is no kernel inside /live/image copy it from /boot
+  if [ ! -d /usr/share/grml-live/templates/boot/isolinux ] ; then
+    echo "E: Could not find isolinux template directory" >&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
 
-mv "$DEST_DIR"/boot/syslinux/* "$TFTPD_DATA_DIR_/"
-rmdir "$DEST_DIR"/boot/syslinux
+fi
 
-mv "$DEST_DIR"/boot/ "$TFTPD_DATA_DIR_"
 
 
 # cd is multi iso, grml2usb got it right ;0