"target" is also the name used in the debian installer for the installation target while "prefix" is too ambiguous.
82 lines
1.8 KiB
Bash
Executable File
82 lines
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# If the pygrub flag is set, this script will install the necessary
|
|
# packages to boot the VM from the dom0 via pygrub. This script installs
|
|
# the kernel and modules and generates a grub menu.lst in the newly
|
|
# created maschine.
|
|
#
|
|
# Dmitry Nedospasov
|
|
# --
|
|
# http://nedos.net
|
|
|
|
TARGET=$1
|
|
|
|
#
|
|
# Source our common functions
|
|
#
|
|
|
|
if [ -e /usr/share/xen-tools/common.sh ]; then
|
|
. /usr/share/xen-tools/common.sh
|
|
else
|
|
. ./hooks/common.sh
|
|
fi
|
|
|
|
#
|
|
# Log our start
|
|
#
|
|
|
|
logMessage Script $0 starting
|
|
|
|
if [ "${pygrub}" ]; then
|
|
|
|
#
|
|
# Attempt to install a xen kernel, if that fails, then install a normal one
|
|
#
|
|
|
|
KERNEL_PKG="linux-image-virtual"
|
|
|
|
logMessage Attempting to install the $KERNEL_PKG kernel image
|
|
logMessage WARNING: This kernel may not have pvops
|
|
if chroot ${TARGET} /usr/bin/apt-cache show $KERNEL_PKG > /dev/null 2>&1; then
|
|
logMessage Package $KERNEL_PKG is available - installing
|
|
installDebianPackage ${TARGET} initramfs-tools
|
|
installDebianPackage ${TARGET} $KERNEL_PKG
|
|
else
|
|
logMessage Package $KERNEL_PKG is not available
|
|
logMessage pygrub set, but kernel could not be installed
|
|
logMessage Script $0 failed
|
|
exit 1
|
|
fi
|
|
|
|
DOMU_KERNEL=$(basename $(ls -1 ${TARGET}/boot/vmlinuz* | tail -n 1))
|
|
KERNEL_REV=$(echo $DOMU_KERNEL | sed "s/vmlinuz-//g")
|
|
DOMU_RAMDISK="initrd.img-$KERNEL_REV"
|
|
DOMU_ISSUE=$(sed -re "s/ *\\\.*//g" -e1q < ${TARGET}/etc/issue)
|
|
|
|
#
|
|
# Generate initrd if it does not exist
|
|
#
|
|
|
|
if [ -f ${TARGET}/boot/$DOMU_RAMDISK ]; then
|
|
logMessage initrd exists, skipping generation
|
|
else
|
|
logMessage initrd missing, generating
|
|
chroot ${TARGET} update-initramfs -c -k $KERNEL_REV
|
|
fi
|
|
|
|
#
|
|
# Generate a menu.lst for pygrub
|
|
#
|
|
|
|
generateDebianGrubMenuLst "${TARGET}" "$DOMU_ISSUE" "$DOMU_KERNEL" "$DOMU_RAMDISK"
|
|
|
|
else
|
|
logMessage pygrub not set, skipping kernel install
|
|
fi # if pygrub
|
|
|
|
#
|
|
# Log our finish
|
|
#
|
|
|
|
logMessage Script $0 finished
|