summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Pereira2015-03-02 02:45:28 +0100
committerMichael Pereira2015-03-02 02:45:28 +0100
commit9e07f5c6229556a5f17b5f0a550b0c9724b44919 (patch)
tree26b02b15de2f5a76d95daf9bd017906239c3049e
parent[hdd-boot] code review (diff)
downloadtm-scripts-9e07f5c6229556a5f17b5f0a550b0c9724b44919.tar.gz
tm-scripts-9e07f5c6229556a5f17b5f0a550b0c9724b44919.tar.xz
tm-scripts-9e07f5c6229556a5f17b5f0a550b0c9724b44919.zip
[hdd-boot] addons are now loaded from hdd and vm xml files copied to /boot
-rwxr-xr-xremote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons21
-rwxr-xr-xserver/modules/hdd-boot/opt/openslx/scripts/systemd-hdd_boot23
2 files changed, 36 insertions, 8 deletions
diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons
index 8d4d2d1a..71ed70a7 100755
--- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons
+++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons
@@ -14,7 +14,7 @@
#
#
######################################################################################
-
+set -x
# read global OpenSLX config
. /opt/openslx/config || { echo "Could not source config!"; exit 23; }
@@ -35,6 +35,9 @@ BASE_MOUNT_POINT="/opt/openslx/mnt"
DOWNLOAD_DEST="/tmp/addons"
mkdir -p "$DOWNLOAD_DEST" || { echo "Failed to create $DOWNLOAD_DEST"; exit 1; }
+# Check if HDD Boot is active
+if grep -qs 'hdd_boot' /proc/cmdline; then HDD="yes"; fi
+
######################################################################################
#
# NO ARGUMENTS -> LOOP OVER ALL ADDONS
@@ -54,13 +57,19 @@ fi
if [ $# -eq 1 ]; then
ADDON="$1"
-
- # download the addon from the given URL
ADDON_TARGET_PATH="${DOWNLOAD_DEST}/$(basename "$ADDON").sqfs"
- if ! download "${SLX_BASE_PATH}/${ADDON}.sqfs" "${ADDON_TARGET_PATH}"; then
- slxlog --echo "addon-download" "Download of '${HTTP_BASE_PATH}/${ADDON}.sqfs' failed."
- exit 1
+
+ if [ -z "$HDD" ]; then
+ # download the addon from the given URL
+ if ! download "${SLX_BASE_PATH}/${ADDON}.sqfs" "${ADDON_TARGET_PATH}"; then
+ slxlog --echo "addon-download" "Download of '${HTTP_BASE_PATH}/${ADDON}.sqfs' failed."
+ exit 1
+ fi
+ else
+ # copy from /boot
+ cp /boot/${SLX_BASE_PATH}/${ADDON}.sqfs ${ADDON_TARGET_PATH}
fi
+
# now mount it to $BASE_MOUNT_POINT/<addon-name>
ADDON_MOUNT_POINT="${BASE_MOUNT_POINT}/$(basename "$ADDON")"
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 3696dc7b..5e255d46 100755
--- a/server/modules/hdd-boot/opt/openslx/scripts/systemd-hdd_boot
+++ b/server/modules/hdd-boot/opt/openslx/scripts/systemd-hdd_boot
@@ -1,4 +1,5 @@
#!/bin/bash
+set -x
# Downloading all in SLX_BASE_PATH to /boot Example: Ubuntu_1404_x64
# wget -N, update if the file has been changed
@@ -26,6 +27,24 @@ for opts in ${KCL}; do
done
KCL=$(echo "$KCL" | sed "s|SLX_BASE_PATH|$SLX_BASE_PATH|g;s|$BOOT_IMAGE||g;s|$initrd||g")
+# Scan vm-store dir for vmware image xmls and copy
+if [ -d /cache/export/dnbd3 -a -d /mnt/vmstore ]; then
+ [ ! -d /boot/vmstore ] && mkdir /boot/vmstore
+ for FILE in $(find /cache/export/dnbd3 -iname "*.vmdk*" ! -iname "*map"); do
+ [ -e "${FILE}.map" ] && continue
+ image_name=$(echo $(basename "$FILE") | cut -d "." -f1)
+ for XML in $(grep -rIl --include "*.xml" "$image_name" /mnt/vmstore); do
+ cp $XML /boot/vmstore
+ done
+ done
+fi
+
+# Bind mount available vmstore in /boot to /mnt/vmstore if not already present
+if ! grep -qs '/mnt/vmstore' /proc/mounts; then
+ [ ! -d /mnt/vmstore ] && mkdir -p /mnt/vmstore
+ [ -d /boot/vmstore ] && mount --bind /boot/vmstore /mnt/vmstore
+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
@@ -63,10 +82,10 @@ echo "GRUB_DISK $GRUB_DISK" #Just for test
[ -e /boot/grub/grub.cfg ] || { echo "Could not find grub.cfg"; exit 1; }
-cat <<EOF >> grub.cfg
+cat <<EOF >> /boot/grub/grub.cfg
#########################
menuentry '$SLX_BASE_PATH' {
- linux ($GRUB_DISK,msdos$BOOT_PART)/$SLX_BASE_PATH/kernel hdd_boot=$BOOT_DISK$BOOT_PART $KCL
+ linux ($GRUB_DISK,msdos$BOOT_PART)/$SLX_BASE_PATH/kernel hdd_boot=$BOOT_PART $KCL
initrd ($GRUB_DISK,msdos$BOOT_PART)/$SLX_BASE_PATH/initramfs-stage31
}
#########################