summaryrefslogtreecommitdiffstats
path: root/server/modules/hdd-boot/opt/openslx/scripts/systemd-hdd_boot
diff options
context:
space:
mode:
Diffstat (limited to 'server/modules/hdd-boot/opt/openslx/scripts/systemd-hdd_boot')
-rwxr-xr-xserver/modules/hdd-boot/opt/openslx/scripts/systemd-hdd_boot129
1 files changed, 46 insertions, 83 deletions
diff --git a/server/modules/hdd-boot/opt/openslx/scripts/systemd-hdd_boot b/server/modules/hdd-boot/opt/openslx/scripts/systemd-hdd_boot
index adf5f002..3696dc7b 100755
--- a/server/modules/hdd-boot/opt/openslx/scripts/systemd-hdd_boot
+++ b/server/modules/hdd-boot/opt/openslx/scripts/systemd-hdd_boot
@@ -1,110 +1,73 @@
-#!/bin/ash
+#!/bin/bash
+# Downloading all in SLX_BASE_PATH to /boot Example: Ubuntu_1404_x64
+# wget -N, update if the file has been changed
boot_download () {
-
- # Downloading all in SLX_BASE_PATH to /boot Example: Ubuntu_1404_x64
- # wget -N, update if the file has been changed
-
-
- cd /boot
- echo "Downloading $SLX_BASE_PATH ................."
- wget -N -r --tries=3 --timeout=5 --quiet -nH -l1 --no-parent --reject="index.html*" --reject="$SLX_BASE_PATH.*" $SLXSRV/$SLX_BASE_PATH #<---- ok =), but try with -nc too
+ echo "Downloading $SLX_BASE_PATH ................."
+ wget -P /boot -N -r --tries=3 --timeout=5 --quiet -nH -l1 --no-parent --reject="index.html*" --reject="$SLX_BASE_PATH.*" $SLXSRV/$SLX_BASE_PATH #<---- ok =), but try with -nc too
RET=$?
- [ $RET != 0 ] && { echo "Error - downloading 'http://$SLXSRV/$SLX_BASE_PATH/' via wget failed."; exit 1; } ||{ echo "Successfully downloaded 'http://$SLXSRV/$SLX_BASE_PATH' via wget."; return 0; }
-
+ [ $RET != 0 ] && { echo "Error - downloading 'http://$SLXSRV/$SLX_BASE_PATH/' via wget failed."; exit 1; } ||{ echo "Successfully downloaded 'http://$SLXSRV/$SLX_BASE_PATH' via wget."; return 0; }
}
# Getting informations from cmdline
read KCL < "/proc/cmdline"
for opts in ${KCL}; do
- case "${opts}" in
- slxbase=*) # BASE_PATH Example Ubuntu_1404_x64
- SLX_BASE_PATH=${opts#slxbase=} ;;
- slxsrv=*)
- #SLX IP server info
- SLXSRV=${opts#slxsrv=} ;;
-
- BOOT_IMAGE=*)
- BOOT_IMAGE=${opts} ;;
-
- initrd=*)
- initrd=${opts} ;;
-
-
- esac
+ case "${opts}" in
+ slxbase=*) # BASE_PATH Example Ubuntu_1404_x64
+ SLX_BASE_PATH=${opts#slxbase=} ;;
+ slxsrv=*)
+ #SLX IP server info
+ SLXSRV=${opts#slxsrv=} ;;
+ BOOT_IMAGE=*)
+ BOOT_IMAGE=${opts} ;;
+ initrd=*)
+ initrd=${opts} ;;
+ esac
done
-
KCL=$(echo "$KCL" | sed "s|SLX_BASE_PATH|$SLX_BASE_PATH|g;s|$BOOT_IMAGE||g;s|$initrd||g")
-
# if SLX_BASE_PATH already exists, just update. Does not make the menu again.
[ -d /boot/$SLX_BASE_PATH ] && { boot_download; echo "$SLX_BASE_PATH updated"; exit 0; } || boot_download
+# Installing GRUB
-# Getting informations about the disks and where is the boot partition
-CONFIG_PATH='/opt/openslx/config'
-. $CONFIG_PATH
-
-echo " SLX_CHOOSEN_DISK $SLX_CHOOSEN_DISK" #Just for test
-
- case $SLX_CHOOSEN_DISK in
-
- sda) GRUB_DISK=hd0 ;;
- sdb) GRUB_DISK=hd1 ;;
- sdc) GRUB_DISK=hd2 ;;
- sdd) GRUB_DISK=hd3 ;;
- sde) GRUB_DISK=hd4 ;;
- *) echo "GRUB_DISK was not found"
- exit 1 ;;
- esac
-
-echo "GRUB_DISK $GRUB_DISK" #Just for test
-
-
- case $SLX_PARTITION_TYPE in
+#Find disk of /boot
+BOOT_DISK=$(df | grep /boot | awk '{print $1}' | tr -d '[0-9]')
+BOOT_PART=$(df | grep /boot | awk '{print $1}' | tr -dc '[0-9]')
+[ -z "$BOOT_DISK" ] && { echo "BOOT DISK could not be found, exiting."; exit 1; }
- GPT) sgdisk -p /dev/$SLX_CHOOSEN_DISK | grep EF02 > /dev/null
- [ $? != 0 ] && { echo "Could not find a BIOS boot partition "; exit 1; }
+if [ ! -d /boot/grub ]; then
+ # First, copy from etc
+ [ -d /etc/grub ] || { echo "Could not find /grub directory"; exit 1; }
+ cp -r /etc/grub /boot/
- SLX_BOOT_ID=$(sgdisk -p /dev/$SLX_CHOOSEN_DISK | grep /boot | cut -c1-6 | sed -e 's/^ *//' -e 's/ *$//' ) # <------- is it working ? remove both trailing and leading spaces with sed
- echo " SLX_BOOT_ID $SLX_BOOT_ID" #Just for test
-
- SLX_BOOT_PARTITION=gpt$SLX_BOOT_ID
- echo " SLX_BOOT_PARTITION $SLX_BOOT_PARTITION" # Just for test
+ grub-install --boot-directory=/boot $BOOT_DISK
+ RET=$?
+ [ $RET != 0 ] && { echo "Could not install GRUB"; exit 1; } || echo "GRUB successfully installed"
+fi
- ;;
- MSDOS)
- SLX_BOOT_ID=$(grep boot $CONFIG_PATH |cut -f1 | tr '#' '\n' | cut -d, -f1)
- echo " SLX_BOOT_ID $SLX_BOOT_ID" #Just for test
+#GRUB ok, so lets make the menu
- SLX_BOOT_PARTITION=msdos$(grep $SLX_BOOT_ID disk.partition | cut -c9)
- echo " SLX_BOOT_PARTITION $SLX_BOOT_PARTITION" #Just for test
- ;;
- esac
+echo " BOOT DISK is $BOOT_DISK" #Just for test
+case $BOOT_DISK in
+ /dev/sda) GRUB_DISK=hd0 ;;
+ /dev/sdb) GRUB_DISK=hd1 ;;
+ /dev/sdc) GRUB_DISK=hd2 ;;
+ /dev/sdd) GRUB_DISK=hd3 ;;
+ /dev/sde) GRUB_DISK=hd4 ;;
+ *) echo "GRUB_DISK was not found"
+ exit 1 ;;
+esac
-# Installing GRUB
-# First, copy from etc
-
- if [ ! -d /boot/grub ]; then
-
- [ -d /etc/grub ] || { echo "Could not find /grub directory"; exit 1; }
- cp -r /etc/grub /boot/
- cd /
- grub-install --boot-directory=/boot /dev/$SLX_CHOOSEN_DISK
- RET=$?
- [ $RET != 0 ] && { echo "Could not install GRUB"; exit 1; } || echo "GRUB successfully installed"
- fi
+echo "GRUB_DISK $GRUB_DISK" #Just for test
-#GRUB ok, so lets make the menu
+[ -e /boot/grub/grub.cfg ] || { echo "Could not find grub.cfg"; exit 1; }
-cd /boot/grub/
-[ -e grub.cfg ] || { echo "Could not find grub.cfg"; exit 1; }
-
cat <<EOF >> grub.cfg
#########################
- menuentry '$SLX_BASE_PATH' {
- linux ($GRUB_DISK,$SLX_BOOT_PARTITION)/$SLX_BASE_PATH/kernel hdd_boot=$SLX_CHOOSEN_DISK$SLX_BOOT_ID $KCL
- initrd ($GRUB_DISK,$SLX_BOOT_PARTITION)/$SLX_BASE_PATH/initramfs-stage31
+ menuentry '$SLX_BASE_PATH' {
+ linux ($GRUB_DISK,msdos$BOOT_PART)/$SLX_BASE_PATH/kernel hdd_boot=$BOOT_DISK$BOOT_PART $KCL
+ initrd ($GRUB_DISK,msdos$BOOT_PART)/$SLX_BASE_PATH/initramfs-stage31
}
#########################
EOF