2017-07-03 03:01:04 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Boot from signed ISO
|
2017-07-12 04:17:45 +00:00
|
|
|
set -e -o pipefail
|
2017-07-03 03:01:04 +00:00
|
|
|
. /etc/functions
|
2018-12-06 23:24:28 +00:00
|
|
|
. /tmp/config
|
2017-07-03 03:01:04 +00:00
|
|
|
|
|
|
|
MOUNTED_ISO_PATH="$1"
|
|
|
|
ISO_PATH="$2"
|
|
|
|
DEV="$3"
|
|
|
|
|
|
|
|
echo '+++ Verifying ISO'
|
|
|
|
# Verify the signature on the hashes
|
|
|
|
ISOSIG="$MOUNTED_ISO_PATH.sig"
|
|
|
|
if ! [ -r "$ISOSIG" ]; then
|
|
|
|
ISOSIG="$MOUNTED_ISO_PATH.asc"
|
|
|
|
fi
|
|
|
|
|
2017-07-22 18:25:39 +00:00
|
|
|
ISO_PATH="${ISO_PATH##/}"
|
|
|
|
|
2018-05-18 02:52:11 +00:00
|
|
|
gpgv --homedir=/etc/distro/ "$ISOSIG" "$MOUNTED_ISO_PATH" \
|
2017-07-08 20:59:37 +00:00
|
|
|
|| die 'ISO signature failed'
|
2017-07-03 03:01:04 +00:00
|
|
|
|
|
|
|
echo '+++ Mounting ISO and booting'
|
|
|
|
mount -t iso9660 -o loop $MOUNTED_ISO_PATH /boot \
|
2017-07-08 20:59:37 +00:00
|
|
|
|| die '$MOUNTED_ISO_PATH: Unable to mount /boot'
|
2017-07-03 03:01:04 +00:00
|
|
|
|
|
|
|
DEV_UUID=`blkid $DEV | tail -1 | tr " " "\n" | grep UUID | cut -d\" -f2`
|
2018-05-19 17:52:49 +00:00
|
|
|
ADD="fromiso=/dev/disk/by-uuid/$DEV_UUID/$ISO_PATH iso-scan/filename=/${ISO_PATH}"
|
2017-07-03 03:01:04 +00:00
|
|
|
REMOVE=""
|
|
|
|
|
2017-07-22 18:25:39 +00:00
|
|
|
paramsdir="/media/kexec_iso/$ISO_PATH"
|
2017-07-08 20:59:37 +00:00
|
|
|
check_config $paramsdir
|
|
|
|
|
2017-07-03 03:01:04 +00:00
|
|
|
ADD_FILE=/tmp/kexec/kexec_iso_add.txt
|
|
|
|
if [ -r $ADD_FILE ]; then
|
|
|
|
NEW_ADD=`cat $ADD_FILE`
|
|
|
|
ADD=$(eval "echo \"$NEW_ADD\"")
|
|
|
|
echo "+++ Overriding standard ISO kernel add arguments: $ADD"
|
|
|
|
fi
|
|
|
|
REMOVE_FILE=/tmp/kexec/kexec_iso_remove.txt
|
|
|
|
if [ -r $REMOVE_FILE ]; then
|
|
|
|
NEW_REMOVE=`cat $REMOVE_FILE`
|
|
|
|
REMOVE=$(eval "echo \"$NEW_REMOVE\"")
|
2017-07-04 23:49:14 +00:00
|
|
|
echo "+++ Overriding standard ISO kernel remove arguments: $REMOVE"
|
2017-07-03 03:01:04 +00:00
|
|
|
fi
|
|
|
|
|
2017-07-04 23:49:14 +00:00
|
|
|
# Call kexec and indicate that hashes have been verified
|
2017-07-22 18:25:39 +00:00
|
|
|
kexec-select-boot -b /boot -d /media -p "$paramsdir" \
|
2017-07-08 20:59:37 +00:00
|
|
|
-a "$ADD" -r "$REMOVE" -c "*.cfg" -u -i
|
|
|
|
|
|
|
|
die "Something failed in selecting boot"
|