#!/bin/bash #set -x error=0 ; trap "error=$((error|1))" ERR # apt-get: be quiet! APTOPTIONS="-q=2" # check whether the environment is still valid if [ x${FAI} = x ] ; then echo "ERROR: \$FAI is empty!" exit 10 fi if [ x${target} = x ] ; then echo "ERROR: \$target is empty!" exit 11 fi # Safeguard: test whether /home/_ablage exists and is usable if [ ! -e ${target}/home/_ablage ] ; then mkdir -p ${target}/home/_ablage fi if [ ! -d ${target}/home/_ablage ] && [ -w ${target}/home/_ablage ] ; then echo "ERROR: ${target}/home/_ablage is not a directory or is not writeable! Exiting with error." exit 1 fi ARCH=$(${ROOTCMD} uname -m) # transform old style arch definitions case ${ARCH} in "i686") ARCH="x86_32" XENVERS="i386" ;; "amd64") ARCH="x86_64" XENVERS="amd64" ;; "x86_32") XENVERS="i386" ;; "x86_64") XENVERS="amd64" ;; *) echo "ERROR: this is not a x86 compliant architecture!" exit 1 ;; esac # copy XenTools software package cp -a ${FAI}/software/xentools ${target}/home/_ablage/ # actually I just want to use the xen-guest-utilities package # XenSource provides a 32bit kernel image, but their update strategy seems rather lacking XENUTILSPKG=$(${ROOTCMD} find /home/_ablage/xentools/ -name "xe-guest*${XENVERS}.deb") if [ -r ${target}/${XENUTILSPKG} ] ; then ${ROOTCMD} dpkg -i ${XENUTILSPKG} # somehow this causes errors ("unary operation expected") else echo "WARNING: I didn't find a suitable xe-guest-utilities package or couldn't access it!" fi cat > ${target}/etc/apt/sources.list.d/xensource.list << EOT deb http://abelia.infrastruktur.aul.t-online.de:9999/xensource/debian/ etch main deb-src http://abelia.infrastruktur.aul.t-online.de:9999/xensource/debian/ etch main EOT # XenTools adds a new apt-source -> update, but be quiet about it ${ROOTCMD} apt-get update ${APTOPTIONS} # Attention: XenSource and Debian use a slightly different kernel naming scheme! # vmlinuz-xenu-2.6.18.xs4.1.0.1168.6013 vs vmlinuz-2.6.18-6-xen-amd64 # XenSource doesn't provide 64 bit kernels case $(lsb_release -i|cut -f 2) in "Debian") # no special kernel parameters necessary (yet) XENKERNELOPTS="" ;; "Ubuntu") # we need to append this to the kernelparamaters or else there's no login possible @ Xen Console XENKERNELOPTS=" xencons=tty" # don't remove the leading whitespace! # anyone assuming /bin/sh to be a bash deserves to get bitten! for SCRIPT in $(find $target/usr/sbin/ -name "xe-*") ; do TMPFILE="/tmp/$(basename ${SCRIPT}).tmp" cp ${SCRIPT} ${TMPFILE} sed -e "s'^#! */bin/sh'#! /bin/bash'" ${TMPFILE} > ${SCRIPT} done ;; "Suse Linux") echo "90_xentools: SuSE found. No action defined (yet)." ;; *) # undefined. maybe SUSE Linux ;; esac # identify installed xen kernel (there should be only one kernel available), ignore XenSource Kernels XENKERNELFILE=$(find ${target}/boot -name "vmlinuz-2*xen*") # /target/boot/vmlinuz-xenu-2.6.18.xs4.1.0.1168.6013 | /target/boot/vmlinuz-2.6.18-6-xen-amd64 XENKERNEL=$(basename ${XENKERNELFILE}) # vmlinuz-xenu-2.6.18.xs4.1.0.1168.6013 | vmlinuz-2.6.18-6-xen-amd64 XENKERNELVERS=$(echo ${XENKERNEL}|sed -e "s/vmlinuz-//") # xenu-2.6.18.xs4.1.0.1168.6013 | 2.6.18-6-xen-amd64 # !! WARNING !! # make sure everything is peachy! # Make. Sure. Everything. Is. Peachy. ! # We do NOT want grub_update to be run after this point! # If your menu.lst does not contain the xen kernels then # grub_update has been run and overwritten the config file! # Check /tmp/fai/error.log for grub- and kernelimage-related # errors! # !! WARNING !! # save the old config file cp -p ${target}/boot/grub/menu.lst ${target}/boot/grub/menu.lst_novirt # rewrite grub config accordingly (XenSource Xen kernel => without initrd) sed -e "s/XENKERNELVERS/${XENKERNELVERS}/g" ${FAI}/files/menu.lst|sed -e "s/XENKERNEL/${XENKERNEL}${XENKERNELOPTS}/g" | sed -e "s/DISTRIB/$(lsb_release -i|cut -f2)/g"|grep -v "savedefault" > ${target}/boot/grub/menu.lst ## if in doubt enable this command to check whether a correct config has been written #cp ${target}/boot/grub/menu.lst ${target}/boot/grub/menu.lst_checkme # harddisks change from hd[abcd] to xvd[abcd], change /etc/fstab accordingly # ToDo: consider UUIDs/labels for mounting cp -p ${target}/etc/fstab ${target}/etc/fstab.orig # preserve ownership and permissions sed -e "s'^/dev/hd'/dev/xvd'g" ${target}/etc/fstab.orig > ${target}/etc/fstab exit $error