summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Pereira2015-03-21 14:01:34 +0100
committerMichael Pereira2015-03-21 14:01:34 +0100
commitff1008b029c10a886f2fd299c6931700de69a069 (patch)
treeb78e5c0b2f653b6b11d42f3ff96ac11520f1fb94
parent[hdd-boot] some fixes and cleanup (diff)
downloadtm-scripts-hdd-boot.tar.gz
tm-scripts-hdd-boot.tar.xz
tm-scripts-hdd-boot.zip
[hdd-boot] Bug fixeshdd-boot
-rwxr-xr-xserver/modules/hdd-boot/opt/openslx/scripts/systemd-hdd_boot54
1 files changed, 29 insertions, 25 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 c1c19b78..f3f05a6c 100755
--- a/server/modules/hdd-boot/opt/openslx/scripts/systemd-hdd_boot
+++ b/server/modules/hdd-boot/opt/openslx/scripts/systemd-hdd_boot
@@ -34,9 +34,11 @@ if [ -d /cache/export/dnbd3 -a -d /mnt/vmstore ]; then
image_name=$(echo $(basename "$FILE") | cut -d "." -f1)
cd /mnt/vmstore
for XML in $(grep -rIl --include "*.xml" "$image_name" .); do
- cp $XML /boot/vmstore
+ xmldir=$(dirname $XML)
+ mkdir -p /boot/vmstore/${xmldir}
+ cp $XML /boot/vmstore/${xmldir}/
done
- cd -
+ cd - >/dev/null
done
fi
@@ -47,59 +49,61 @@ if ! grep -qs '/mnt/vmstore' /proc/mounts; then
fi
# 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
+[ -d /boot/$SLX_BASE_PATH ] && { boot_download; echo "$SLX_BASE_PATH updated"; } || { boot_download; echo "New base $SLX_BASE_PATH downloaded to HDD"; }
# Installing GRUB
#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]')
+BOOT_DISK=$(df | grep /boot$ | awk '{print $1}' | tr -d '[0-9]' | cut -c 6-)
+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; }
#Check if disk is msdos or GPT
-if sgdisk $BOOT_DISK | grep -qs 'invalid GPT'; then
+if sgdisk /dev/$BOOT_DISK | grep -qs 'invalid GPT'; then
BOOT_TYPE='msdos'
else
BOOT_TYPE='gpt'
fi
if [ ! -d /boot/grub ]; then
- # First, copy grub.cfg
- [ -e /opt/openslx/hdd-boot/grub.cfg ] && cp -r /opt/openslx/hdd-boot/grub.cfg /boot/grub/
- grub-install --boot-directory=/boot $BOOT_DISK
- update-grub-gfxpayload
+ grub-install --boot-directory=/boot /dev/$BOOT_DISK
+ #update-grub-gfxpayload
RET=$?
[ $RET != 0 ] && { echo "Could not install GRUB"; exit 1; } || echo "GRUB successfully installed"
+
+ # First, copy grub.cfg
+ [ -e /opt/openslx/hdd-boot/grub.cfg ] && cp -r /opt/openslx/hdd-boot/grub.cfg /boot/grub/
fi
-#GRUB ok, so lets make the menu
-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"
+#Add new base to grub.cfg
+if ! grep -qs "menuentry '$SLX_BASE_PATH'" /boot/grub/grub.cfg; then
+
+ #GRUB ok, so lets make the menu
+ echo "BOOT DISK is $BOOT_DISK" #Just for test
+ case $BOOT_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
+ esac
-[ -e /boot/grub/grub.cfg ] || { echo "Could not find grub.cfg"; exit 1; }
+ [ -e /boot/grub/grub.cfg ] || { echo "Could not find grub.cfg"; exit 1; }
cat <<EOF >> /boot/grub/grub.cfg
#########################
menuentry '$SLX_BASE_PATH' {
- linux ($GRUB_DISK,${BOOT_TYPE}$BOOT_PART)/$SLX_BASE_PATH/kernel hdd_boot=$BOOT_PART $KCL
+ linux ($GRUB_DISK,${BOOT_TYPE}$BOOT_PART)/$SLX_BASE_PATH/kernel hdd_boot=${BOOT_DISK}$BOOT_PART $KCL
initrd ($GRUB_DISK,${BOOT_TYPE}$BOOT_PART)/$SLX_BASE_PATH/initramfs-stage31
}
#########################
EOF
-echo "GRUB INSTALLED =) =)"
+fi
true