diff --git a/hooks/centos-4/40-setup-networking b/hooks/centos-4/40-setup-networking deleted file mode 100755 index 992cd3d..0000000 --- a/hooks/centos-4/40-setup-networking +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/sh -# -# This script sets up the networking files for the new image. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - - -# -# Make sure we have an /etc/sysconfig/network-scripts directory. -# -mkdir -p ${prefix}/etc/sysconfig/network-scripts/ - - -# -# Test for static vs. DHCP -# -if [ -z "${dhcp}" ]; then - - # - # Setup the initial interface - # - cat <${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0 -DEVICE=eth0 -ONBOOT=yes -BOOTPROTO=static -IPADDR=${ip1} -NETMASK=${netmask} -GATEWAY=${gateway} -E_O_STATIC - - # - # Now setup any other ones. - # - interface=1 - count=2 - - while [ "${count}" -le "${ip_count}" ]; do - - value=\$ip${count} - value=`eval echo $value` - - logMessage Adding etho:${interface} - - cat <${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0:${interface} -DEVICE=eth0:${interface} -ONBOOT=yes -BOOTPROTO=static -IPADDR=${value} -NETMASK=${netmask} -E_O_STATIC - count=`expr $count + 1` - interface=`expr $interface + 1` - done - - # - # Hooks are run chrooted, hence the resolv.conf is moved - # temporarily to /etc/resolv.conf.old. Use that file, it - # will be restored after hooks are run. - # - if [ '' != "$nameserver" ]; then - rm -f ${prefix}/etc/resolv.conf.old - for ns in $nameserver; do - echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old - done - else - cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old - fi -else - cat <${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0 -DEVICE=eth0 -BOOTPROTO=dhcp -ONBOOT=yes -E_O_DHCP - chroot ${prefix} /usr/bin/yum -y install dhclient -fi - - -# -# Don't forget to setup the default route. -# -cat <${prefix}/etc/sysconfig/network -NETWORKING=yes -GATEWAY=${gateway} -HOSTNAME=${hostname} -EOF - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/centos-4/40-setup-networking b/hooks/centos-4/40-setup-networking new file mode 120000 index 0000000..22ecdae --- /dev/null +++ b/hooks/centos-4/40-setup-networking @@ -0,0 +1 @@ +../common/40-setup-networking-rpm \ No newline at end of file diff --git a/hooks/centos-4/70-install-ssh b/hooks/centos-4/70-install-ssh deleted file mode 100755 index 11dccfa..0000000 --- a/hooks/centos-4/70-install-ssh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# -# This script installs OpenSSH upon the new system. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - -# -# Install the OpenSSH server. -# -if [ ! -d ${prefix}/proc ]; then - mkdir -p ${prefix}/proc -fi -mount -o bind /proc ${prefix}/proc -chroot ${prefix} /usr/bin/yum -y install openssh-server passwd -umount ${prefix}/proc - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/centos-4/70-install-ssh b/hooks/centos-4/70-install-ssh new file mode 120000 index 0000000..bfbe615 --- /dev/null +++ b/hooks/centos-4/70-install-ssh @@ -0,0 +1 @@ +../common/70-install-ssh-rpm \ No newline at end of file diff --git a/hooks/centos-4/80-install-modules b/hooks/centos-4/80-install-modules deleted file mode 100755 index 11f83d5..0000000 --- a/hooks/centos-4/80-install-modules +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# -# Install modules from the host system into the new image. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - - - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - - -# -# Copy the modules from the host to the new system - we should only -# really copy the *correct* modules, but we don't know what they are. -# -mkdir -p ${prefix}/lib/modules -cp -au /lib/modules/*/ ${prefix}/lib/modules - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/centos-4/80-install-modules b/hooks/centos-4/80-install-modules new file mode 120000 index 0000000..12e39f0 --- /dev/null +++ b/hooks/centos-4/80-install-modules @@ -0,0 +1 @@ +../common/80-install-modules-rpm \ No newline at end of file diff --git a/hooks/centos-4/90-make-fstab b/hooks/centos-4/90-make-fstab deleted file mode 100755 index 278d1de..0000000 --- a/hooks/centos-4/90-make-fstab +++ /dev/null @@ -1,123 +0,0 @@ -#!/bin/sh -# -# This script is responsible for setting up /etc/fstab upon the -# new instance. -# -# This should be a simple job, but it is complicated by some of the -# differences between filesystems - some root filesystems will require -# the installation of new packages, and we have to handle that here. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - - -logMessage Filesystem options are ${options} - - -# -# Find the root device. -# -# 1. default to xvda. -# -# 2. If --ide is specified use hda. -# -# 3. If --scsi is specified use sda. -# -# 4. Otherwise use a named $disk_device -# -device=xvda -if [ "${ide}" ]; then - device=hda -elif [ "${scsi}" ]; then - device=sda -else - if [ ! -z "${disk_device}" ]; then - device=`basename $disk_device` - fi -fi - -logMessage "Root device is /dev/$device" - - -# -# Now we have the options we can create the fstab. -# -has_xfs=0 -has_reiserfs=0 -has_btrfs=0 -cat < ${prefix}/etc/fstab -# /etc/fstab: static file system information. -# -# -proc /proc proc defaults 0 0 -devpts /dev/pts devpts rw,noexec,nosuid,gid=5,mode=620 0 0 -E_O_FSTAB -for part in `seq 1 ${NUMPARTITIONS}`; do - eval "PARTITION=\"\${PARTITION${part}}\"" - OLDIFS="${IFS}" - IFS=: - x=0 - for partdata in ${PARTITION}; do - eval "partdata${x}=\"${partdata}\"" - x=$(( $x+1 )) - done - IFS="${OLDIFS}" - - case "${partdata2}" in - xfs) - has_xfs=1 - ;; - reiserfs) - has_reiserfs=1 - ;; - btrfs) - has_btrfs=1 - ;; - esac - - if [ "${partdata2}" = "swap" ]; then - echo "/dev/${device}${part} none swap sw 0 0" >> ${prefix}/etc/fstab - else - echo "/dev/${device}${part} ${partdata3} ${partdata2} ${partdata4} 0 1" >> ${prefix}/etc/fstab - fi -done - - -# -# Finally we can install any required packages for the given root -# filesystem -# -#if [ $has_xfs -eq 1 ]; then -# installDebianPackage ${prefix} xfsprogs -#fi -#if [ $has_reiserfs -eq 1 ]; then -# installDebianPackage ${prefix} reiserfsprogs -#fi -#if [ $has_btrfs -eq 1 ]; then -# installDebianPackage ${prefix} btrfs-tools -#fi - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/centos-4/90-make-fstab b/hooks/centos-4/90-make-fstab new file mode 120000 index 0000000..74a6267 --- /dev/null +++ b/hooks/centos-4/90-make-fstab @@ -0,0 +1 @@ +../common/90-make-fstab-rpm \ No newline at end of file diff --git a/hooks/centos-5/40-setup-networking b/hooks/centos-5/40-setup-networking deleted file mode 100755 index 992cd3d..0000000 --- a/hooks/centos-5/40-setup-networking +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/sh -# -# This script sets up the networking files for the new image. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - - -# -# Make sure we have an /etc/sysconfig/network-scripts directory. -# -mkdir -p ${prefix}/etc/sysconfig/network-scripts/ - - -# -# Test for static vs. DHCP -# -if [ -z "${dhcp}" ]; then - - # - # Setup the initial interface - # - cat <${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0 -DEVICE=eth0 -ONBOOT=yes -BOOTPROTO=static -IPADDR=${ip1} -NETMASK=${netmask} -GATEWAY=${gateway} -E_O_STATIC - - # - # Now setup any other ones. - # - interface=1 - count=2 - - while [ "${count}" -le "${ip_count}" ]; do - - value=\$ip${count} - value=`eval echo $value` - - logMessage Adding etho:${interface} - - cat <${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0:${interface} -DEVICE=eth0:${interface} -ONBOOT=yes -BOOTPROTO=static -IPADDR=${value} -NETMASK=${netmask} -E_O_STATIC - count=`expr $count + 1` - interface=`expr $interface + 1` - done - - # - # Hooks are run chrooted, hence the resolv.conf is moved - # temporarily to /etc/resolv.conf.old. Use that file, it - # will be restored after hooks are run. - # - if [ '' != "$nameserver" ]; then - rm -f ${prefix}/etc/resolv.conf.old - for ns in $nameserver; do - echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old - done - else - cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old - fi -else - cat <${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0 -DEVICE=eth0 -BOOTPROTO=dhcp -ONBOOT=yes -E_O_DHCP - chroot ${prefix} /usr/bin/yum -y install dhclient -fi - - -# -# Don't forget to setup the default route. -# -cat <${prefix}/etc/sysconfig/network -NETWORKING=yes -GATEWAY=${gateway} -HOSTNAME=${hostname} -EOF - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/centos-5/40-setup-networking b/hooks/centos-5/40-setup-networking new file mode 120000 index 0000000..22ecdae --- /dev/null +++ b/hooks/centos-5/40-setup-networking @@ -0,0 +1 @@ +../common/40-setup-networking-rpm \ No newline at end of file diff --git a/hooks/centos-5/70-install-ssh b/hooks/centos-5/70-install-ssh deleted file mode 100755 index 11dccfa..0000000 --- a/hooks/centos-5/70-install-ssh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# -# This script installs OpenSSH upon the new system. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - -# -# Install the OpenSSH server. -# -if [ ! -d ${prefix}/proc ]; then - mkdir -p ${prefix}/proc -fi -mount -o bind /proc ${prefix}/proc -chroot ${prefix} /usr/bin/yum -y install openssh-server passwd -umount ${prefix}/proc - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/centos-5/70-install-ssh b/hooks/centos-5/70-install-ssh new file mode 120000 index 0000000..bfbe615 --- /dev/null +++ b/hooks/centos-5/70-install-ssh @@ -0,0 +1 @@ +../common/70-install-ssh-rpm \ No newline at end of file diff --git a/hooks/centos-5/80-install-modules b/hooks/centos-5/80-install-modules deleted file mode 100755 index 11f83d5..0000000 --- a/hooks/centos-5/80-install-modules +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# -# Install modules from the host system into the new image. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - - - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - - -# -# Copy the modules from the host to the new system - we should only -# really copy the *correct* modules, but we don't know what they are. -# -mkdir -p ${prefix}/lib/modules -cp -au /lib/modules/*/ ${prefix}/lib/modules - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/centos-5/80-install-modules b/hooks/centos-5/80-install-modules new file mode 120000 index 0000000..12e39f0 --- /dev/null +++ b/hooks/centos-5/80-install-modules @@ -0,0 +1 @@ +../common/80-install-modules-rpm \ No newline at end of file diff --git a/hooks/common/40-setup-networking-deb b/hooks/common/40-setup-networking-deb new file mode 100755 index 0000000..b5f456f --- /dev/null +++ b/hooks/common/40-setup-networking-deb @@ -0,0 +1,170 @@ +#!/bin/sh +# +# This script sets up the /etc/network/interface file for the new +# image. +# +# Steve +# -- +# http://www.steve.org.uk/ + + +prefix=$1 + +# +# Source our common functions +# +if [ -e /usr/lib/xen-tools/common.sh ]; then + . /usr/lib/xen-tools/common.sh +else + . ./hooks/common.sh +fi + + +# +# Log our start +# +logMessage Script $0 starting + + +# +# Make sure we have an /etc/network directory. +# +mkdir -p ${prefix}/etc/network + + +# +# A function to setup DHCP for our new image. +# +setupDynamicNetworking () +{ + # + # The host is using DHCP. + # + cat < ${prefix}/etc/network/interfaces +# This file describes the network interfaces available on your system +# and how to activate them. For more information, see interfaces(5). + +# The loopback network interface +auto lo +iface lo inet loopback + +# The primary network interface +auto eth0 +iface eth0 inet dhcp +# post-up ethtool -K eth0 tx off + +# +# The commented out line above will disable TCP checksumming which +# might resolve problems for some users. It is disabled by default +# +E_O_DHCP +} + + + +# +# A function to setup static IP addresses for our new image. +# +setupStaticNetworking () +{ + # + # if $p2p is set then add a "pointopoint" setting. + # + point=''; + if [ ! -z "${p2p}" ]; then + point="pointopoint ${p2p}" + else + point='' + fi + + # + # broadcast address? + # + bcast=''; + if [ ! -z "${broadcast}" ]; then + bcast=" broadcast ${broadcast}" + fi + + # + # We have a static IP address + # + cat <${prefix}/etc/network/interfaces +# This file describes the network interfaces available on your system +# and how to activate them. For more information, see interfaces(5). + +# The loopback network interface +auto lo +iface lo inet loopback + +# The primary network interface +auto eth0 +iface eth0 inet static + address ${ip1} + gateway ${gateway} + netmask ${netmask} + ${bcast} + ${point} + # post-up ethtool -K eth0 tx off + +# +# The commented out line above will disable TCP checksumming which +# might resolve problems for some users. It is disabled by default +# +E_O_STATIC + + interface=1 + count=2 + + while [ "${count}" -le "${ip_count}" ]; do + + value=\$ip${count} + value=`eval echo $value` + + logMessage Adding etho:${interface} + + cat <>${prefix}/etc/network/interfaces +auto eth0:${interface} +iface eth0:${interface} inet static + address ${value} + netmask ${netmask} + # post-up ethtool -K eth0 tx off +E_O_STATIC + count=`expr $count + 1` + interface=`expr $interface + 1` + done + + # + # Hooks are run chrooted, hence the resolv.conf is moved + # temporarily to /etc/resolv.conf.old. Use that file, it + # will be restored after hooks are run. + # + if [ '' != "$nameserver" ]; then + rm -f ${prefix}/etc/resolv.conf.old + for ns in $nameserver; do + echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old + done + else + cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old + fi +} + + + + +# +# Call the relevant function +# +if [ -z "${dhcp}" ]; then + logMessage "Setting up static networking" + setupStaticNetworking + +else + logMessage "Setting up DHCP networking" + setupDynamicNetworking +fi + + +# +# Log our finish +# +logMessage Script $0 finished diff --git a/hooks/common/40-setup-networking-rpm b/hooks/common/40-setup-networking-rpm new file mode 100755 index 0000000..992cd3d --- /dev/null +++ b/hooks/common/40-setup-networking-rpm @@ -0,0 +1,112 @@ +#!/bin/sh +# +# This script sets up the networking files for the new image. +# +# Steve +# -- +# http://www.steve.org.uk/ + + +prefix=$1 + + +# +# Source our common functions +# +if [ -e /usr/lib/xen-tools/common.sh ]; then + . /usr/lib/xen-tools/common.sh +else + . ./hooks/common.sh +fi + + +# +# Log our start +# +logMessage Script $0 starting + + +# +# Make sure we have an /etc/sysconfig/network-scripts directory. +# +mkdir -p ${prefix}/etc/sysconfig/network-scripts/ + + +# +# Test for static vs. DHCP +# +if [ -z "${dhcp}" ]; then + + # + # Setup the initial interface + # + cat <${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0 +DEVICE=eth0 +ONBOOT=yes +BOOTPROTO=static +IPADDR=${ip1} +NETMASK=${netmask} +GATEWAY=${gateway} +E_O_STATIC + + # + # Now setup any other ones. + # + interface=1 + count=2 + + while [ "${count}" -le "${ip_count}" ]; do + + value=\$ip${count} + value=`eval echo $value` + + logMessage Adding etho:${interface} + + cat <${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0:${interface} +DEVICE=eth0:${interface} +ONBOOT=yes +BOOTPROTO=static +IPADDR=${value} +NETMASK=${netmask} +E_O_STATIC + count=`expr $count + 1` + interface=`expr $interface + 1` + done + + # + # Hooks are run chrooted, hence the resolv.conf is moved + # temporarily to /etc/resolv.conf.old. Use that file, it + # will be restored after hooks are run. + # + if [ '' != "$nameserver" ]; then + rm -f ${prefix}/etc/resolv.conf.old + for ns in $nameserver; do + echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old + done + else + cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old + fi +else + cat <${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0 +DEVICE=eth0 +BOOTPROTO=dhcp +ONBOOT=yes +E_O_DHCP + chroot ${prefix} /usr/bin/yum -y install dhclient +fi + + +# +# Don't forget to setup the default route. +# +cat <${prefix}/etc/sysconfig/network +NETWORKING=yes +GATEWAY=${gateway} +HOSTNAME=${hostname} +EOF + + +# +# Log our finish +# +logMessage Script $0 finished diff --git a/hooks/common/70-install-ssh-deb b/hooks/common/70-install-ssh-deb new file mode 100755 index 0000000..e6eca32 --- /dev/null +++ b/hooks/common/70-install-ssh-deb @@ -0,0 +1,67 @@ +#!/bin/sh +# +# This script installs OpenSSH Server on the newly created guest. +# +# It does this by generating the keys within the host, since guests +# do not have the necessary /dev/random and /dev/urandom to generate +# their own keys before boot. +# +# Dmitry Nedospasov +# -- +# http://nedos.net/ + +prefix=$1 + +# +# Source our common functions +# +if [ -e /usr/lib/xen-tools/common.sh ]; then + . /usr/lib/xen-tools/common.sh +else + . ./hooks/common.sh +fi + +# +# Log our start +# +logMessage Script $0 starting + +# +# Since our guests doesn't have an RNG, generate the keys from the host +# +# First, create an ssh directory +# +mkdir -p ${prefix}/etc/ssh + +# +# Second, Generate the Host RSA Key +# +if [ ! -f ${prefix}/etc/ssh/ssh_host_rsa_key ]; then +if ssh-keygen -t rsa -N "" -f ${prefix}/etc/ssh/ssh_host_rsa_key -C "root@${hostname}"; then + logMessage "successfully generetaged Host RSA" +else + logMessage "failed to generate Host RSA Key" +fi +fi + +# +# Third, Generate the Host DSA Key +# +if [ ! -f ${prefix}/etc/ssh/ssh_host_dsa_key ]; then +if ssh-keygen -t dsa -N "" -f ${prefix}/etc/ssh/ssh_host_dsa_key -C "root@${hostname}"; then + logMessage "successfully generetaged Host DSA" +else + logMessage "failed to generate Host DSA Key" +fi +fi + +# +# Install ssh +# +installDebianPackage ${prefix} openssh-server + +# +# Log our finish +# +logMessage Script $0 finished + diff --git a/hooks/common/70-install-ssh-rpm b/hooks/common/70-install-ssh-rpm new file mode 100755 index 0000000..11dccfa --- /dev/null +++ b/hooks/common/70-install-ssh-rpm @@ -0,0 +1,42 @@ +#!/bin/sh +# +# This script installs OpenSSH upon the new system. +# +# Steve +# -- +# http://www.steve.org.uk/ + + +prefix=$1 + + +# +# Source our common functions +# +if [ -e /usr/lib/xen-tools/common.sh ]; then + . /usr/lib/xen-tools/common.sh +else + . ./hooks/common.sh +fi + + +# +# Log our start +# +logMessage Script $0 starting + +# +# Install the OpenSSH server. +# +if [ ! -d ${prefix}/proc ]; then + mkdir -p ${prefix}/proc +fi +mount -o bind /proc ${prefix}/proc +chroot ${prefix} /usr/bin/yum -y install openssh-server passwd +umount ${prefix}/proc + + +# +# Log our finish +# +logMessage Script $0 finished diff --git a/hooks/common/80-install-modules-deb b/hooks/common/80-install-modules-deb new file mode 100755 index 0000000..45905ff --- /dev/null +++ b/hooks/common/80-install-modules-deb @@ -0,0 +1,86 @@ +#!/bin/sh +# +# Install modules from the host system into the new image, and +# ensure that 'module-init-tools' is setup. +# +# This is most likely required if you're using a custom kernel +# for your Xen system. But even if it isn't required it can't +# really do anything bad; just waste a bit of space. +# +# Steve +# -- +# http://www.steve.org.uk/ + + +prefix=$1 + + + +# +# Source our common functions +# +if [ -e /usr/lib/xen-tools/common.sh ]; then + . /usr/lib/xen-tools/common.sh +else + . ./hooks/common.sh +fi + + +# +# Log our start +# +logMessage Script $0 starting + +if [ ${pygrub} ]; then + logMessage "pygrub set, skipping module install" +else +# +# The name of the package containing the correct modules. +# +linux_modules_package="linux-modules-$(uname -r)" + +# +# Attempt to install that package. This will either work on an Etch +# system, or fail on a Sarge/custom kernel. +# +if [ -n "${modules}" -a -d "${modules}" ]; then + + # + # Modules path was specified during install + # + logMessage "Copying modules from ${modules}" + + mkdir -p ${prefix}/lib/modules + cp -au ${modules} ${prefix}/lib/modules +elif chroot ${prefix} /usr/bin/apt-cache show ${linux_modules_package} >/dev/null 2>/dev/null; then + + logMessage "Package '${linux_modules_package}' is available - installing" + + # + # If it worked then we can install the package. + # + installDebianPackage ${prefix} ${linux_modules_package} +else + + # + # Fall back to copying over modules from the host to the new + # system. + # + logMessage "Package '${linux_modules_package}' is not available" + logMessage "Copying modules from /lib/modules/$(uname -r)" + + mkdir -p ${prefix}/lib/modules + cp -au /lib/modules/$(uname -r) ${prefix}/lib/modules +fi + +# +# Install the module-init-tools package. +# +installDebianPackage ${prefix} module-init-tools + +fi # if pygrub + +# +# Log our finish +# +logMessage Script $0 finished diff --git a/hooks/common/80-install-modules-rpm b/hooks/common/80-install-modules-rpm new file mode 100755 index 0000000..11f83d5 --- /dev/null +++ b/hooks/common/80-install-modules-rpm @@ -0,0 +1,41 @@ +#!/bin/sh +# +# Install modules from the host system into the new image. +# +# Steve +# -- +# http://www.steve.org.uk/ + + +prefix=$1 + + + +# +# Source our common functions +# +if [ -e /usr/lib/xen-tools/common.sh ]; then + . /usr/lib/xen-tools/common.sh +else + . ./hooks/common.sh +fi + + +# +# Log our start +# +logMessage Script $0 starting + + +# +# Copy the modules from the host to the new system - we should only +# really copy the *correct* modules, but we don't know what they are. +# +mkdir -p ${prefix}/lib/modules +cp -au /lib/modules/*/ ${prefix}/lib/modules + + +# +# Log our finish +# +logMessage Script $0 finished diff --git a/hooks/common/90-make-fstab-deb b/hooks/common/90-make-fstab-deb new file mode 100755 index 0000000..42d775d --- /dev/null +++ b/hooks/common/90-make-fstab-deb @@ -0,0 +1,120 @@ +#!/bin/sh +# +# This script is responsible for setting up /etc/fstab upon the +# new instance. +# +# This should be a simple job, but it is complicated by some of the +# differences between filesystems - some root filesystems will require +# the installation of new packages, and we have to handle that here. +# +# Steve +# -- +# http://www.steve.org.uk/ + + +prefix=$1 + +# +# Source our common functions +# +if [ -e /usr/lib/xen-tools/common.sh ]; then + . /usr/lib/xen-tools/common.sh +else + . ./hooks/common.sh +fi + + +# +# Log our start +# +logMessage Script $0 starting + + +# +# Find the root device. +# +# 1. default to xvda. +# +# 2. If --ide is specified use hda. +# +# 3. If --scsi is specified use sda. +# +# 4. Otherwise use a named $disk_device +# +device=xvda +if [ "${ide}" ]; then + device=hda +elif [ "${scsi}" ]; then + device=sda +else + if [ ! -z "${disk_device}" ]; then + device=`basename $disk_device` + fi +fi + +logMessage "Root device is /dev/$device" + + +# +# Now we have the options we can create the fstab. +# +has_xfs=0 +has_reiserfs=0 +has_btrfs=0 +cat < ${prefix}/etc/fstab +# /etc/fstab: static file system information. +# +# +proc /proc proc defaults 0 0 +devpts /dev/pts devpts rw,noexec,nosuid,gid=5,mode=620 0 0 +E_O_FSTAB +for part in `seq 1 ${NUMPARTITIONS}`; do + eval "PARTITION=\"\${PARTITION${part}}\"" + OLDIFS="${IFS}" + IFS=: + x=0 + for partdata in ${PARTITION}; do + eval "partdata${x}=\"${partdata}\"" + x=$(( $x+1 )) + done + IFS="${OLDIFS}" + + case "${partdata2}" in + xfs) + has_xfs=1 + ;; + reiserfs) + has_reiserfs=1 + ;; + btrfs) + has_btrfs=1 + ;; + esac + + if [ "${partdata2}" = "swap" ]; then + echo "/dev/${device}${part} none swap sw 0 0" >> ${prefix}/etc/fstab + else + echo "/dev/${device}${part} ${partdata3} ${partdata2} ${partdata4} 0 1" >> ${prefix}/etc/fstab + fi +done + + +# +# Finally we can install any required packages for the given root +# filesystem +# +if [ $has_xfs -eq 1 ]; then + installDebianPackage ${prefix} xfsprogs +fi +if [ $has_reiserfs -eq 1 ]; then + installDebianPackage ${prefix} reiserfsprogs +fi +if [ $has_btrfs -eq 1 ]; then + installDebianPackage ${prefix} btrfs-tools +fi + + +# +# Log our finish +# +logMessage Script $0 finished diff --git a/hooks/common/90-make-fstab-rpm b/hooks/common/90-make-fstab-rpm new file mode 100755 index 0000000..278d1de --- /dev/null +++ b/hooks/common/90-make-fstab-rpm @@ -0,0 +1,123 @@ +#!/bin/sh +# +# This script is responsible for setting up /etc/fstab upon the +# new instance. +# +# This should be a simple job, but it is complicated by some of the +# differences between filesystems - some root filesystems will require +# the installation of new packages, and we have to handle that here. +# +# Steve +# -- +# http://www.steve.org.uk/ + + +prefix=$1 + +# +# Source our common functions +# +if [ -e /usr/lib/xen-tools/common.sh ]; then + . /usr/lib/xen-tools/common.sh +else + . ./hooks/common.sh +fi + + +# +# Log our start +# +logMessage Script $0 starting + + +logMessage Filesystem options are ${options} + + +# +# Find the root device. +# +# 1. default to xvda. +# +# 2. If --ide is specified use hda. +# +# 3. If --scsi is specified use sda. +# +# 4. Otherwise use a named $disk_device +# +device=xvda +if [ "${ide}" ]; then + device=hda +elif [ "${scsi}" ]; then + device=sda +else + if [ ! -z "${disk_device}" ]; then + device=`basename $disk_device` + fi +fi + +logMessage "Root device is /dev/$device" + + +# +# Now we have the options we can create the fstab. +# +has_xfs=0 +has_reiserfs=0 +has_btrfs=0 +cat < ${prefix}/etc/fstab +# /etc/fstab: static file system information. +# +# +proc /proc proc defaults 0 0 +devpts /dev/pts devpts rw,noexec,nosuid,gid=5,mode=620 0 0 +E_O_FSTAB +for part in `seq 1 ${NUMPARTITIONS}`; do + eval "PARTITION=\"\${PARTITION${part}}\"" + OLDIFS="${IFS}" + IFS=: + x=0 + for partdata in ${PARTITION}; do + eval "partdata${x}=\"${partdata}\"" + x=$(( $x+1 )) + done + IFS="${OLDIFS}" + + case "${partdata2}" in + xfs) + has_xfs=1 + ;; + reiserfs) + has_reiserfs=1 + ;; + btrfs) + has_btrfs=1 + ;; + esac + + if [ "${partdata2}" = "swap" ]; then + echo "/dev/${device}${part} none swap sw 0 0" >> ${prefix}/etc/fstab + else + echo "/dev/${device}${part} ${partdata3} ${partdata2} ${partdata4} 0 1" >> ${prefix}/etc/fstab + fi +done + + +# +# Finally we can install any required packages for the given root +# filesystem +# +#if [ $has_xfs -eq 1 ]; then +# installDebianPackage ${prefix} xfsprogs +#fi +#if [ $has_reiserfs -eq 1 ]; then +# installDebianPackage ${prefix} reiserfsprogs +#fi +#if [ $has_btrfs -eq 1 ]; then +# installDebianPackage ${prefix} btrfs-tools +#fi + + +# +# Log our finish +# +logMessage Script $0 finished diff --git a/hooks/dapper/40-setup-networking b/hooks/dapper/40-setup-networking deleted file mode 100755 index b5f456f..0000000 --- a/hooks/dapper/40-setup-networking +++ /dev/null @@ -1,170 +0,0 @@ -#!/bin/sh -# -# This script sets up the /etc/network/interface file for the new -# image. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - - -# -# Make sure we have an /etc/network directory. -# -mkdir -p ${prefix}/etc/network - - -# -# A function to setup DHCP for our new image. -# -setupDynamicNetworking () -{ - # - # The host is using DHCP. - # - cat < ${prefix}/etc/network/interfaces -# This file describes the network interfaces available on your system -# and how to activate them. For more information, see interfaces(5). - -# The loopback network interface -auto lo -iface lo inet loopback - -# The primary network interface -auto eth0 -iface eth0 inet dhcp -# post-up ethtool -K eth0 tx off - -# -# The commented out line above will disable TCP checksumming which -# might resolve problems for some users. It is disabled by default -# -E_O_DHCP -} - - - -# -# A function to setup static IP addresses for our new image. -# -setupStaticNetworking () -{ - # - # if $p2p is set then add a "pointopoint" setting. - # - point=''; - if [ ! -z "${p2p}" ]; then - point="pointopoint ${p2p}" - else - point='' - fi - - # - # broadcast address? - # - bcast=''; - if [ ! -z "${broadcast}" ]; then - bcast=" broadcast ${broadcast}" - fi - - # - # We have a static IP address - # - cat <${prefix}/etc/network/interfaces -# This file describes the network interfaces available on your system -# and how to activate them. For more information, see interfaces(5). - -# The loopback network interface -auto lo -iface lo inet loopback - -# The primary network interface -auto eth0 -iface eth0 inet static - address ${ip1} - gateway ${gateway} - netmask ${netmask} - ${bcast} - ${point} - # post-up ethtool -K eth0 tx off - -# -# The commented out line above will disable TCP checksumming which -# might resolve problems for some users. It is disabled by default -# -E_O_STATIC - - interface=1 - count=2 - - while [ "${count}" -le "${ip_count}" ]; do - - value=\$ip${count} - value=`eval echo $value` - - logMessage Adding etho:${interface} - - cat <>${prefix}/etc/network/interfaces -auto eth0:${interface} -iface eth0:${interface} inet static - address ${value} - netmask ${netmask} - # post-up ethtool -K eth0 tx off -E_O_STATIC - count=`expr $count + 1` - interface=`expr $interface + 1` - done - - # - # Hooks are run chrooted, hence the resolv.conf is moved - # temporarily to /etc/resolv.conf.old. Use that file, it - # will be restored after hooks are run. - # - if [ '' != "$nameserver" ]; then - rm -f ${prefix}/etc/resolv.conf.old - for ns in $nameserver; do - echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old - done - else - cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old - fi -} - - - - -# -# Call the relevant function -# -if [ -z "${dhcp}" ]; then - logMessage "Setting up static networking" - setupStaticNetworking - -else - logMessage "Setting up DHCP networking" - setupDynamicNetworking -fi - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/dapper/40-setup-networking b/hooks/dapper/40-setup-networking new file mode 120000 index 0000000..5b8a76d --- /dev/null +++ b/hooks/dapper/40-setup-networking @@ -0,0 +1 @@ +../common/40-setup-networking-deb \ No newline at end of file diff --git a/hooks/dapper/70-install-ssh b/hooks/dapper/70-install-ssh deleted file mode 100755 index e6eca32..0000000 --- a/hooks/dapper/70-install-ssh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh -# -# This script installs OpenSSH Server on the newly created guest. -# -# It does this by generating the keys within the host, since guests -# do not have the necessary /dev/random and /dev/urandom to generate -# their own keys before boot. -# -# Dmitry Nedospasov -# -- -# http://nedos.net/ - -prefix=$1 - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - -# -# Log our start -# -logMessage Script $0 starting - -# -# Since our guests doesn't have an RNG, generate the keys from the host -# -# First, create an ssh directory -# -mkdir -p ${prefix}/etc/ssh - -# -# Second, Generate the Host RSA Key -# -if [ ! -f ${prefix}/etc/ssh/ssh_host_rsa_key ]; then -if ssh-keygen -t rsa -N "" -f ${prefix}/etc/ssh/ssh_host_rsa_key -C "root@${hostname}"; then - logMessage "successfully generetaged Host RSA" -else - logMessage "failed to generate Host RSA Key" -fi -fi - -# -# Third, Generate the Host DSA Key -# -if [ ! -f ${prefix}/etc/ssh/ssh_host_dsa_key ]; then -if ssh-keygen -t dsa -N "" -f ${prefix}/etc/ssh/ssh_host_dsa_key -C "root@${hostname}"; then - logMessage "successfully generetaged Host DSA" -else - logMessage "failed to generate Host DSA Key" -fi -fi - -# -# Install ssh -# -installDebianPackage ${prefix} openssh-server - -# -# Log our finish -# -logMessage Script $0 finished - diff --git a/hooks/dapper/70-install-ssh b/hooks/dapper/70-install-ssh new file mode 120000 index 0000000..7749dd0 --- /dev/null +++ b/hooks/dapper/70-install-ssh @@ -0,0 +1 @@ +../common/70-install-ssh-deb \ No newline at end of file diff --git a/hooks/dapper/90-make-fstab b/hooks/dapper/90-make-fstab deleted file mode 100755 index 42d775d..0000000 --- a/hooks/dapper/90-make-fstab +++ /dev/null @@ -1,120 +0,0 @@ -#!/bin/sh -# -# This script is responsible for setting up /etc/fstab upon the -# new instance. -# -# This should be a simple job, but it is complicated by some of the -# differences between filesystems - some root filesystems will require -# the installation of new packages, and we have to handle that here. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - - -# -# Find the root device. -# -# 1. default to xvda. -# -# 2. If --ide is specified use hda. -# -# 3. If --scsi is specified use sda. -# -# 4. Otherwise use a named $disk_device -# -device=xvda -if [ "${ide}" ]; then - device=hda -elif [ "${scsi}" ]; then - device=sda -else - if [ ! -z "${disk_device}" ]; then - device=`basename $disk_device` - fi -fi - -logMessage "Root device is /dev/$device" - - -# -# Now we have the options we can create the fstab. -# -has_xfs=0 -has_reiserfs=0 -has_btrfs=0 -cat < ${prefix}/etc/fstab -# /etc/fstab: static file system information. -# -# -proc /proc proc defaults 0 0 -devpts /dev/pts devpts rw,noexec,nosuid,gid=5,mode=620 0 0 -E_O_FSTAB -for part in `seq 1 ${NUMPARTITIONS}`; do - eval "PARTITION=\"\${PARTITION${part}}\"" - OLDIFS="${IFS}" - IFS=: - x=0 - for partdata in ${PARTITION}; do - eval "partdata${x}=\"${partdata}\"" - x=$(( $x+1 )) - done - IFS="${OLDIFS}" - - case "${partdata2}" in - xfs) - has_xfs=1 - ;; - reiserfs) - has_reiserfs=1 - ;; - btrfs) - has_btrfs=1 - ;; - esac - - if [ "${partdata2}" = "swap" ]; then - echo "/dev/${device}${part} none swap sw 0 0" >> ${prefix}/etc/fstab - else - echo "/dev/${device}${part} ${partdata3} ${partdata2} ${partdata4} 0 1" >> ${prefix}/etc/fstab - fi -done - - -# -# Finally we can install any required packages for the given root -# filesystem -# -if [ $has_xfs -eq 1 ]; then - installDebianPackage ${prefix} xfsprogs -fi -if [ $has_reiserfs -eq 1 ]; then - installDebianPackage ${prefix} reiserfsprogs -fi -if [ $has_btrfs -eq 1 ]; then - installDebianPackage ${prefix} btrfs-tools -fi - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/dapper/90-make-fstab b/hooks/dapper/90-make-fstab new file mode 120000 index 0000000..a9b306a --- /dev/null +++ b/hooks/dapper/90-make-fstab @@ -0,0 +1 @@ +../common/90-make-fstab-deb \ No newline at end of file diff --git a/hooks/debian/40-setup-networking b/hooks/debian/40-setup-networking deleted file mode 100755 index b5f456f..0000000 --- a/hooks/debian/40-setup-networking +++ /dev/null @@ -1,170 +0,0 @@ -#!/bin/sh -# -# This script sets up the /etc/network/interface file for the new -# image. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - - -# -# Make sure we have an /etc/network directory. -# -mkdir -p ${prefix}/etc/network - - -# -# A function to setup DHCP for our new image. -# -setupDynamicNetworking () -{ - # - # The host is using DHCP. - # - cat < ${prefix}/etc/network/interfaces -# This file describes the network interfaces available on your system -# and how to activate them. For more information, see interfaces(5). - -# The loopback network interface -auto lo -iface lo inet loopback - -# The primary network interface -auto eth0 -iface eth0 inet dhcp -# post-up ethtool -K eth0 tx off - -# -# The commented out line above will disable TCP checksumming which -# might resolve problems for some users. It is disabled by default -# -E_O_DHCP -} - - - -# -# A function to setup static IP addresses for our new image. -# -setupStaticNetworking () -{ - # - # if $p2p is set then add a "pointopoint" setting. - # - point=''; - if [ ! -z "${p2p}" ]; then - point="pointopoint ${p2p}" - else - point='' - fi - - # - # broadcast address? - # - bcast=''; - if [ ! -z "${broadcast}" ]; then - bcast=" broadcast ${broadcast}" - fi - - # - # We have a static IP address - # - cat <${prefix}/etc/network/interfaces -# This file describes the network interfaces available on your system -# and how to activate them. For more information, see interfaces(5). - -# The loopback network interface -auto lo -iface lo inet loopback - -# The primary network interface -auto eth0 -iface eth0 inet static - address ${ip1} - gateway ${gateway} - netmask ${netmask} - ${bcast} - ${point} - # post-up ethtool -K eth0 tx off - -# -# The commented out line above will disable TCP checksumming which -# might resolve problems for some users. It is disabled by default -# -E_O_STATIC - - interface=1 - count=2 - - while [ "${count}" -le "${ip_count}" ]; do - - value=\$ip${count} - value=`eval echo $value` - - logMessage Adding etho:${interface} - - cat <>${prefix}/etc/network/interfaces -auto eth0:${interface} -iface eth0:${interface} inet static - address ${value} - netmask ${netmask} - # post-up ethtool -K eth0 tx off -E_O_STATIC - count=`expr $count + 1` - interface=`expr $interface + 1` - done - - # - # Hooks are run chrooted, hence the resolv.conf is moved - # temporarily to /etc/resolv.conf.old. Use that file, it - # will be restored after hooks are run. - # - if [ '' != "$nameserver" ]; then - rm -f ${prefix}/etc/resolv.conf.old - for ns in $nameserver; do - echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old - done - else - cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old - fi -} - - - - -# -# Call the relevant function -# -if [ -z "${dhcp}" ]; then - logMessage "Setting up static networking" - setupStaticNetworking - -else - logMessage "Setting up DHCP networking" - setupDynamicNetworking -fi - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/debian/40-setup-networking b/hooks/debian/40-setup-networking new file mode 120000 index 0000000..5b8a76d --- /dev/null +++ b/hooks/debian/40-setup-networking @@ -0,0 +1 @@ +../common/40-setup-networking-deb \ No newline at end of file diff --git a/hooks/debian/70-install-ssh b/hooks/debian/70-install-ssh deleted file mode 100755 index e6eca32..0000000 --- a/hooks/debian/70-install-ssh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh -# -# This script installs OpenSSH Server on the newly created guest. -# -# It does this by generating the keys within the host, since guests -# do not have the necessary /dev/random and /dev/urandom to generate -# their own keys before boot. -# -# Dmitry Nedospasov -# -- -# http://nedos.net/ - -prefix=$1 - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - -# -# Log our start -# -logMessage Script $0 starting - -# -# Since our guests doesn't have an RNG, generate the keys from the host -# -# First, create an ssh directory -# -mkdir -p ${prefix}/etc/ssh - -# -# Second, Generate the Host RSA Key -# -if [ ! -f ${prefix}/etc/ssh/ssh_host_rsa_key ]; then -if ssh-keygen -t rsa -N "" -f ${prefix}/etc/ssh/ssh_host_rsa_key -C "root@${hostname}"; then - logMessage "successfully generetaged Host RSA" -else - logMessage "failed to generate Host RSA Key" -fi -fi - -# -# Third, Generate the Host DSA Key -# -if [ ! -f ${prefix}/etc/ssh/ssh_host_dsa_key ]; then -if ssh-keygen -t dsa -N "" -f ${prefix}/etc/ssh/ssh_host_dsa_key -C "root@${hostname}"; then - logMessage "successfully generetaged Host DSA" -else - logMessage "failed to generate Host DSA Key" -fi -fi - -# -# Install ssh -# -installDebianPackage ${prefix} openssh-server - -# -# Log our finish -# -logMessage Script $0 finished - diff --git a/hooks/debian/70-install-ssh b/hooks/debian/70-install-ssh new file mode 120000 index 0000000..7749dd0 --- /dev/null +++ b/hooks/debian/70-install-ssh @@ -0,0 +1 @@ +../common/70-install-ssh-deb \ No newline at end of file diff --git a/hooks/debian/80-install-modules b/hooks/debian/80-install-modules deleted file mode 100755 index 45905ff..0000000 --- a/hooks/debian/80-install-modules +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/sh -# -# Install modules from the host system into the new image, and -# ensure that 'module-init-tools' is setup. -# -# This is most likely required if you're using a custom kernel -# for your Xen system. But even if it isn't required it can't -# really do anything bad; just waste a bit of space. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - - - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - -if [ ${pygrub} ]; then - logMessage "pygrub set, skipping module install" -else -# -# The name of the package containing the correct modules. -# -linux_modules_package="linux-modules-$(uname -r)" - -# -# Attempt to install that package. This will either work on an Etch -# system, or fail on a Sarge/custom kernel. -# -if [ -n "${modules}" -a -d "${modules}" ]; then - - # - # Modules path was specified during install - # - logMessage "Copying modules from ${modules}" - - mkdir -p ${prefix}/lib/modules - cp -au ${modules} ${prefix}/lib/modules -elif chroot ${prefix} /usr/bin/apt-cache show ${linux_modules_package} >/dev/null 2>/dev/null; then - - logMessage "Package '${linux_modules_package}' is available - installing" - - # - # If it worked then we can install the package. - # - installDebianPackage ${prefix} ${linux_modules_package} -else - - # - # Fall back to copying over modules from the host to the new - # system. - # - logMessage "Package '${linux_modules_package}' is not available" - logMessage "Copying modules from /lib/modules/$(uname -r)" - - mkdir -p ${prefix}/lib/modules - cp -au /lib/modules/$(uname -r) ${prefix}/lib/modules -fi - -# -# Install the module-init-tools package. -# -installDebianPackage ${prefix} module-init-tools - -fi # if pygrub - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/debian/80-install-modules b/hooks/debian/80-install-modules new file mode 120000 index 0000000..8826dcd --- /dev/null +++ b/hooks/debian/80-install-modules @@ -0,0 +1 @@ +../common/80-install-modules-deb \ No newline at end of file diff --git a/hooks/edgy/40-setup-networking b/hooks/edgy/40-setup-networking deleted file mode 100755 index b5f456f..0000000 --- a/hooks/edgy/40-setup-networking +++ /dev/null @@ -1,170 +0,0 @@ -#!/bin/sh -# -# This script sets up the /etc/network/interface file for the new -# image. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - - -# -# Make sure we have an /etc/network directory. -# -mkdir -p ${prefix}/etc/network - - -# -# A function to setup DHCP for our new image. -# -setupDynamicNetworking () -{ - # - # The host is using DHCP. - # - cat < ${prefix}/etc/network/interfaces -# This file describes the network interfaces available on your system -# and how to activate them. For more information, see interfaces(5). - -# The loopback network interface -auto lo -iface lo inet loopback - -# The primary network interface -auto eth0 -iface eth0 inet dhcp -# post-up ethtool -K eth0 tx off - -# -# The commented out line above will disable TCP checksumming which -# might resolve problems for some users. It is disabled by default -# -E_O_DHCP -} - - - -# -# A function to setup static IP addresses for our new image. -# -setupStaticNetworking () -{ - # - # if $p2p is set then add a "pointopoint" setting. - # - point=''; - if [ ! -z "${p2p}" ]; then - point="pointopoint ${p2p}" - else - point='' - fi - - # - # broadcast address? - # - bcast=''; - if [ ! -z "${broadcast}" ]; then - bcast=" broadcast ${broadcast}" - fi - - # - # We have a static IP address - # - cat <${prefix}/etc/network/interfaces -# This file describes the network interfaces available on your system -# and how to activate them. For more information, see interfaces(5). - -# The loopback network interface -auto lo -iface lo inet loopback - -# The primary network interface -auto eth0 -iface eth0 inet static - address ${ip1} - gateway ${gateway} - netmask ${netmask} - ${bcast} - ${point} - # post-up ethtool -K eth0 tx off - -# -# The commented out line above will disable TCP checksumming which -# might resolve problems for some users. It is disabled by default -# -E_O_STATIC - - interface=1 - count=2 - - while [ "${count}" -le "${ip_count}" ]; do - - value=\$ip${count} - value=`eval echo $value` - - logMessage Adding etho:${interface} - - cat <>${prefix}/etc/network/interfaces -auto eth0:${interface} -iface eth0:${interface} inet static - address ${value} - netmask ${netmask} - # post-up ethtool -K eth0 tx off -E_O_STATIC - count=`expr $count + 1` - interface=`expr $interface + 1` - done - - # - # Hooks are run chrooted, hence the resolv.conf is moved - # temporarily to /etc/resolv.conf.old. Use that file, it - # will be restored after hooks are run. - # - if [ '' != "$nameserver" ]; then - rm -f ${prefix}/etc/resolv.conf.old - for ns in $nameserver; do - echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old - done - else - cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old - fi -} - - - - -# -# Call the relevant function -# -if [ -z "${dhcp}" ]; then - logMessage "Setting up static networking" - setupStaticNetworking - -else - logMessage "Setting up DHCP networking" - setupDynamicNetworking -fi - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/edgy/40-setup-networking b/hooks/edgy/40-setup-networking new file mode 120000 index 0000000..5b8a76d --- /dev/null +++ b/hooks/edgy/40-setup-networking @@ -0,0 +1 @@ +../common/40-setup-networking-deb \ No newline at end of file diff --git a/hooks/edgy/70-install-ssh b/hooks/edgy/70-install-ssh deleted file mode 100755 index e6eca32..0000000 --- a/hooks/edgy/70-install-ssh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh -# -# This script installs OpenSSH Server on the newly created guest. -# -# It does this by generating the keys within the host, since guests -# do not have the necessary /dev/random and /dev/urandom to generate -# their own keys before boot. -# -# Dmitry Nedospasov -# -- -# http://nedos.net/ - -prefix=$1 - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - -# -# Log our start -# -logMessage Script $0 starting - -# -# Since our guests doesn't have an RNG, generate the keys from the host -# -# First, create an ssh directory -# -mkdir -p ${prefix}/etc/ssh - -# -# Second, Generate the Host RSA Key -# -if [ ! -f ${prefix}/etc/ssh/ssh_host_rsa_key ]; then -if ssh-keygen -t rsa -N "" -f ${prefix}/etc/ssh/ssh_host_rsa_key -C "root@${hostname}"; then - logMessage "successfully generetaged Host RSA" -else - logMessage "failed to generate Host RSA Key" -fi -fi - -# -# Third, Generate the Host DSA Key -# -if [ ! -f ${prefix}/etc/ssh/ssh_host_dsa_key ]; then -if ssh-keygen -t dsa -N "" -f ${prefix}/etc/ssh/ssh_host_dsa_key -C "root@${hostname}"; then - logMessage "successfully generetaged Host DSA" -else - logMessage "failed to generate Host DSA Key" -fi -fi - -# -# Install ssh -# -installDebianPackage ${prefix} openssh-server - -# -# Log our finish -# -logMessage Script $0 finished - diff --git a/hooks/edgy/70-install-ssh b/hooks/edgy/70-install-ssh new file mode 120000 index 0000000..7749dd0 --- /dev/null +++ b/hooks/edgy/70-install-ssh @@ -0,0 +1 @@ +../common/70-install-ssh-deb \ No newline at end of file diff --git a/hooks/edgy/80-install-modules b/hooks/edgy/80-install-modules deleted file mode 100755 index 45905ff..0000000 --- a/hooks/edgy/80-install-modules +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/sh -# -# Install modules from the host system into the new image, and -# ensure that 'module-init-tools' is setup. -# -# This is most likely required if you're using a custom kernel -# for your Xen system. But even if it isn't required it can't -# really do anything bad; just waste a bit of space. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - - - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - -if [ ${pygrub} ]; then - logMessage "pygrub set, skipping module install" -else -# -# The name of the package containing the correct modules. -# -linux_modules_package="linux-modules-$(uname -r)" - -# -# Attempt to install that package. This will either work on an Etch -# system, or fail on a Sarge/custom kernel. -# -if [ -n "${modules}" -a -d "${modules}" ]; then - - # - # Modules path was specified during install - # - logMessage "Copying modules from ${modules}" - - mkdir -p ${prefix}/lib/modules - cp -au ${modules} ${prefix}/lib/modules -elif chroot ${prefix} /usr/bin/apt-cache show ${linux_modules_package} >/dev/null 2>/dev/null; then - - logMessage "Package '${linux_modules_package}' is available - installing" - - # - # If it worked then we can install the package. - # - installDebianPackage ${prefix} ${linux_modules_package} -else - - # - # Fall back to copying over modules from the host to the new - # system. - # - logMessage "Package '${linux_modules_package}' is not available" - logMessage "Copying modules from /lib/modules/$(uname -r)" - - mkdir -p ${prefix}/lib/modules - cp -au /lib/modules/$(uname -r) ${prefix}/lib/modules -fi - -# -# Install the module-init-tools package. -# -installDebianPackage ${prefix} module-init-tools - -fi # if pygrub - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/edgy/80-install-modules b/hooks/edgy/80-install-modules new file mode 120000 index 0000000..8826dcd --- /dev/null +++ b/hooks/edgy/80-install-modules @@ -0,0 +1 @@ +../common/80-install-modules-deb \ No newline at end of file diff --git a/hooks/edgy/90-make-fstab b/hooks/edgy/90-make-fstab deleted file mode 100755 index 42d775d..0000000 --- a/hooks/edgy/90-make-fstab +++ /dev/null @@ -1,120 +0,0 @@ -#!/bin/sh -# -# This script is responsible for setting up /etc/fstab upon the -# new instance. -# -# This should be a simple job, but it is complicated by some of the -# differences between filesystems - some root filesystems will require -# the installation of new packages, and we have to handle that here. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - - -# -# Find the root device. -# -# 1. default to xvda. -# -# 2. If --ide is specified use hda. -# -# 3. If --scsi is specified use sda. -# -# 4. Otherwise use a named $disk_device -# -device=xvda -if [ "${ide}" ]; then - device=hda -elif [ "${scsi}" ]; then - device=sda -else - if [ ! -z "${disk_device}" ]; then - device=`basename $disk_device` - fi -fi - -logMessage "Root device is /dev/$device" - - -# -# Now we have the options we can create the fstab. -# -has_xfs=0 -has_reiserfs=0 -has_btrfs=0 -cat < ${prefix}/etc/fstab -# /etc/fstab: static file system information. -# -# -proc /proc proc defaults 0 0 -devpts /dev/pts devpts rw,noexec,nosuid,gid=5,mode=620 0 0 -E_O_FSTAB -for part in `seq 1 ${NUMPARTITIONS}`; do - eval "PARTITION=\"\${PARTITION${part}}\"" - OLDIFS="${IFS}" - IFS=: - x=0 - for partdata in ${PARTITION}; do - eval "partdata${x}=\"${partdata}\"" - x=$(( $x+1 )) - done - IFS="${OLDIFS}" - - case "${partdata2}" in - xfs) - has_xfs=1 - ;; - reiserfs) - has_reiserfs=1 - ;; - btrfs) - has_btrfs=1 - ;; - esac - - if [ "${partdata2}" = "swap" ]; then - echo "/dev/${device}${part} none swap sw 0 0" >> ${prefix}/etc/fstab - else - echo "/dev/${device}${part} ${partdata3} ${partdata2} ${partdata4} 0 1" >> ${prefix}/etc/fstab - fi -done - - -# -# Finally we can install any required packages for the given root -# filesystem -# -if [ $has_xfs -eq 1 ]; then - installDebianPackage ${prefix} xfsprogs -fi -if [ $has_reiserfs -eq 1 ]; then - installDebianPackage ${prefix} reiserfsprogs -fi -if [ $has_btrfs -eq 1 ]; then - installDebianPackage ${prefix} btrfs-tools -fi - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/edgy/90-make-fstab b/hooks/edgy/90-make-fstab new file mode 120000 index 0000000..a9b306a --- /dev/null +++ b/hooks/edgy/90-make-fstab @@ -0,0 +1 @@ +../common/90-make-fstab-deb \ No newline at end of file diff --git a/hooks/fedora-core-6/40-setup-networking b/hooks/fedora-core-6/40-setup-networking deleted file mode 100755 index 992cd3d..0000000 --- a/hooks/fedora-core-6/40-setup-networking +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/sh -# -# This script sets up the networking files for the new image. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - - -# -# Make sure we have an /etc/sysconfig/network-scripts directory. -# -mkdir -p ${prefix}/etc/sysconfig/network-scripts/ - - -# -# Test for static vs. DHCP -# -if [ -z "${dhcp}" ]; then - - # - # Setup the initial interface - # - cat <${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0 -DEVICE=eth0 -ONBOOT=yes -BOOTPROTO=static -IPADDR=${ip1} -NETMASK=${netmask} -GATEWAY=${gateway} -E_O_STATIC - - # - # Now setup any other ones. - # - interface=1 - count=2 - - while [ "${count}" -le "${ip_count}" ]; do - - value=\$ip${count} - value=`eval echo $value` - - logMessage Adding etho:${interface} - - cat <${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0:${interface} -DEVICE=eth0:${interface} -ONBOOT=yes -BOOTPROTO=static -IPADDR=${value} -NETMASK=${netmask} -E_O_STATIC - count=`expr $count + 1` - interface=`expr $interface + 1` - done - - # - # Hooks are run chrooted, hence the resolv.conf is moved - # temporarily to /etc/resolv.conf.old. Use that file, it - # will be restored after hooks are run. - # - if [ '' != "$nameserver" ]; then - rm -f ${prefix}/etc/resolv.conf.old - for ns in $nameserver; do - echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old - done - else - cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old - fi -else - cat <${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0 -DEVICE=eth0 -BOOTPROTO=dhcp -ONBOOT=yes -E_O_DHCP - chroot ${prefix} /usr/bin/yum -y install dhclient -fi - - -# -# Don't forget to setup the default route. -# -cat <${prefix}/etc/sysconfig/network -NETWORKING=yes -GATEWAY=${gateway} -HOSTNAME=${hostname} -EOF - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/fedora-core-6/40-setup-networking b/hooks/fedora-core-6/40-setup-networking new file mode 120000 index 0000000..22ecdae --- /dev/null +++ b/hooks/fedora-core-6/40-setup-networking @@ -0,0 +1 @@ +../common/40-setup-networking-rpm \ No newline at end of file diff --git a/hooks/fedora-core-6/80-install-modules b/hooks/fedora-core-6/80-install-modules deleted file mode 100755 index 11f83d5..0000000 --- a/hooks/fedora-core-6/80-install-modules +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# -# Install modules from the host system into the new image. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - - - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - - -# -# Copy the modules from the host to the new system - we should only -# really copy the *correct* modules, but we don't know what they are. -# -mkdir -p ${prefix}/lib/modules -cp -au /lib/modules/*/ ${prefix}/lib/modules - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/fedora-core-6/80-install-modules b/hooks/fedora-core-6/80-install-modules new file mode 120000 index 0000000..12e39f0 --- /dev/null +++ b/hooks/fedora-core-6/80-install-modules @@ -0,0 +1 @@ +../common/80-install-modules-rpm \ No newline at end of file diff --git a/hooks/fedora-core-6/90-make-fstab b/hooks/fedora-core-6/90-make-fstab deleted file mode 100755 index 278d1de..0000000 --- a/hooks/fedora-core-6/90-make-fstab +++ /dev/null @@ -1,123 +0,0 @@ -#!/bin/sh -# -# This script is responsible for setting up /etc/fstab upon the -# new instance. -# -# This should be a simple job, but it is complicated by some of the -# differences between filesystems - some root filesystems will require -# the installation of new packages, and we have to handle that here. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - - -logMessage Filesystem options are ${options} - - -# -# Find the root device. -# -# 1. default to xvda. -# -# 2. If --ide is specified use hda. -# -# 3. If --scsi is specified use sda. -# -# 4. Otherwise use a named $disk_device -# -device=xvda -if [ "${ide}" ]; then - device=hda -elif [ "${scsi}" ]; then - device=sda -else - if [ ! -z "${disk_device}" ]; then - device=`basename $disk_device` - fi -fi - -logMessage "Root device is /dev/$device" - - -# -# Now we have the options we can create the fstab. -# -has_xfs=0 -has_reiserfs=0 -has_btrfs=0 -cat < ${prefix}/etc/fstab -# /etc/fstab: static file system information. -# -# -proc /proc proc defaults 0 0 -devpts /dev/pts devpts rw,noexec,nosuid,gid=5,mode=620 0 0 -E_O_FSTAB -for part in `seq 1 ${NUMPARTITIONS}`; do - eval "PARTITION=\"\${PARTITION${part}}\"" - OLDIFS="${IFS}" - IFS=: - x=0 - for partdata in ${PARTITION}; do - eval "partdata${x}=\"${partdata}\"" - x=$(( $x+1 )) - done - IFS="${OLDIFS}" - - case "${partdata2}" in - xfs) - has_xfs=1 - ;; - reiserfs) - has_reiserfs=1 - ;; - btrfs) - has_btrfs=1 - ;; - esac - - if [ "${partdata2}" = "swap" ]; then - echo "/dev/${device}${part} none swap sw 0 0" >> ${prefix}/etc/fstab - else - echo "/dev/${device}${part} ${partdata3} ${partdata2} ${partdata4} 0 1" >> ${prefix}/etc/fstab - fi -done - - -# -# Finally we can install any required packages for the given root -# filesystem -# -#if [ $has_xfs -eq 1 ]; then -# installDebianPackage ${prefix} xfsprogs -#fi -#if [ $has_reiserfs -eq 1 ]; then -# installDebianPackage ${prefix} reiserfsprogs -#fi -#if [ $has_btrfs -eq 1 ]; then -# installDebianPackage ${prefix} btrfs-tools -#fi - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/fedora-core-6/90-make-fstab b/hooks/fedora-core-6/90-make-fstab new file mode 120000 index 0000000..74a6267 --- /dev/null +++ b/hooks/fedora-core-6/90-make-fstab @@ -0,0 +1 @@ +../common/90-make-fstab-rpm \ No newline at end of file diff --git a/hooks/intrepid/40-setup-networking b/hooks/intrepid/40-setup-networking deleted file mode 100755 index b5f456f..0000000 --- a/hooks/intrepid/40-setup-networking +++ /dev/null @@ -1,170 +0,0 @@ -#!/bin/sh -# -# This script sets up the /etc/network/interface file for the new -# image. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - - -# -# Make sure we have an /etc/network directory. -# -mkdir -p ${prefix}/etc/network - - -# -# A function to setup DHCP for our new image. -# -setupDynamicNetworking () -{ - # - # The host is using DHCP. - # - cat < ${prefix}/etc/network/interfaces -# This file describes the network interfaces available on your system -# and how to activate them. For more information, see interfaces(5). - -# The loopback network interface -auto lo -iface lo inet loopback - -# The primary network interface -auto eth0 -iface eth0 inet dhcp -# post-up ethtool -K eth0 tx off - -# -# The commented out line above will disable TCP checksumming which -# might resolve problems for some users. It is disabled by default -# -E_O_DHCP -} - - - -# -# A function to setup static IP addresses for our new image. -# -setupStaticNetworking () -{ - # - # if $p2p is set then add a "pointopoint" setting. - # - point=''; - if [ ! -z "${p2p}" ]; then - point="pointopoint ${p2p}" - else - point='' - fi - - # - # broadcast address? - # - bcast=''; - if [ ! -z "${broadcast}" ]; then - bcast=" broadcast ${broadcast}" - fi - - # - # We have a static IP address - # - cat <${prefix}/etc/network/interfaces -# This file describes the network interfaces available on your system -# and how to activate them. For more information, see interfaces(5). - -# The loopback network interface -auto lo -iface lo inet loopback - -# The primary network interface -auto eth0 -iface eth0 inet static - address ${ip1} - gateway ${gateway} - netmask ${netmask} - ${bcast} - ${point} - # post-up ethtool -K eth0 tx off - -# -# The commented out line above will disable TCP checksumming which -# might resolve problems for some users. It is disabled by default -# -E_O_STATIC - - interface=1 - count=2 - - while [ "${count}" -le "${ip_count}" ]; do - - value=\$ip${count} - value=`eval echo $value` - - logMessage Adding etho:${interface} - - cat <>${prefix}/etc/network/interfaces -auto eth0:${interface} -iface eth0:${interface} inet static - address ${value} - netmask ${netmask} - # post-up ethtool -K eth0 tx off -E_O_STATIC - count=`expr $count + 1` - interface=`expr $interface + 1` - done - - # - # Hooks are run chrooted, hence the resolv.conf is moved - # temporarily to /etc/resolv.conf.old. Use that file, it - # will be restored after hooks are run. - # - if [ '' != "$nameserver" ]; then - rm -f ${prefix}/etc/resolv.conf.old - for ns in $nameserver; do - echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old - done - else - cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old - fi -} - - - - -# -# Call the relevant function -# -if [ -z "${dhcp}" ]; then - logMessage "Setting up static networking" - setupStaticNetworking - -else - logMessage "Setting up DHCP networking" - setupDynamicNetworking -fi - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/intrepid/40-setup-networking b/hooks/intrepid/40-setup-networking new file mode 120000 index 0000000..5b8a76d --- /dev/null +++ b/hooks/intrepid/40-setup-networking @@ -0,0 +1 @@ +../common/40-setup-networking-deb \ No newline at end of file diff --git a/hooks/intrepid/70-install-ssh b/hooks/intrepid/70-install-ssh deleted file mode 100755 index e6eca32..0000000 --- a/hooks/intrepid/70-install-ssh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh -# -# This script installs OpenSSH Server on the newly created guest. -# -# It does this by generating the keys within the host, since guests -# do not have the necessary /dev/random and /dev/urandom to generate -# their own keys before boot. -# -# Dmitry Nedospasov -# -- -# http://nedos.net/ - -prefix=$1 - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - -# -# Log our start -# -logMessage Script $0 starting - -# -# Since our guests doesn't have an RNG, generate the keys from the host -# -# First, create an ssh directory -# -mkdir -p ${prefix}/etc/ssh - -# -# Second, Generate the Host RSA Key -# -if [ ! -f ${prefix}/etc/ssh/ssh_host_rsa_key ]; then -if ssh-keygen -t rsa -N "" -f ${prefix}/etc/ssh/ssh_host_rsa_key -C "root@${hostname}"; then - logMessage "successfully generetaged Host RSA" -else - logMessage "failed to generate Host RSA Key" -fi -fi - -# -# Third, Generate the Host DSA Key -# -if [ ! -f ${prefix}/etc/ssh/ssh_host_dsa_key ]; then -if ssh-keygen -t dsa -N "" -f ${prefix}/etc/ssh/ssh_host_dsa_key -C "root@${hostname}"; then - logMessage "successfully generetaged Host DSA" -else - logMessage "failed to generate Host DSA Key" -fi -fi - -# -# Install ssh -# -installDebianPackage ${prefix} openssh-server - -# -# Log our finish -# -logMessage Script $0 finished - diff --git a/hooks/intrepid/70-install-ssh b/hooks/intrepid/70-install-ssh new file mode 120000 index 0000000..7749dd0 --- /dev/null +++ b/hooks/intrepid/70-install-ssh @@ -0,0 +1 @@ +../common/70-install-ssh-deb \ No newline at end of file diff --git a/hooks/intrepid/80-install-modules b/hooks/intrepid/80-install-modules deleted file mode 100755 index 45905ff..0000000 --- a/hooks/intrepid/80-install-modules +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/sh -# -# Install modules from the host system into the new image, and -# ensure that 'module-init-tools' is setup. -# -# This is most likely required if you're using a custom kernel -# for your Xen system. But even if it isn't required it can't -# really do anything bad; just waste a bit of space. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - - - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - -if [ ${pygrub} ]; then - logMessage "pygrub set, skipping module install" -else -# -# The name of the package containing the correct modules. -# -linux_modules_package="linux-modules-$(uname -r)" - -# -# Attempt to install that package. This will either work on an Etch -# system, or fail on a Sarge/custom kernel. -# -if [ -n "${modules}" -a -d "${modules}" ]; then - - # - # Modules path was specified during install - # - logMessage "Copying modules from ${modules}" - - mkdir -p ${prefix}/lib/modules - cp -au ${modules} ${prefix}/lib/modules -elif chroot ${prefix} /usr/bin/apt-cache show ${linux_modules_package} >/dev/null 2>/dev/null; then - - logMessage "Package '${linux_modules_package}' is available - installing" - - # - # If it worked then we can install the package. - # - installDebianPackage ${prefix} ${linux_modules_package} -else - - # - # Fall back to copying over modules from the host to the new - # system. - # - logMessage "Package '${linux_modules_package}' is not available" - logMessage "Copying modules from /lib/modules/$(uname -r)" - - mkdir -p ${prefix}/lib/modules - cp -au /lib/modules/$(uname -r) ${prefix}/lib/modules -fi - -# -# Install the module-init-tools package. -# -installDebianPackage ${prefix} module-init-tools - -fi # if pygrub - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/intrepid/80-install-modules b/hooks/intrepid/80-install-modules new file mode 120000 index 0000000..8826dcd --- /dev/null +++ b/hooks/intrepid/80-install-modules @@ -0,0 +1 @@ +../common/80-install-modules-deb \ No newline at end of file diff --git a/hooks/intrepid/90-make-fstab b/hooks/intrepid/90-make-fstab deleted file mode 100755 index 42d775d..0000000 --- a/hooks/intrepid/90-make-fstab +++ /dev/null @@ -1,120 +0,0 @@ -#!/bin/sh -# -# This script is responsible for setting up /etc/fstab upon the -# new instance. -# -# This should be a simple job, but it is complicated by some of the -# differences between filesystems - some root filesystems will require -# the installation of new packages, and we have to handle that here. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - - -# -# Find the root device. -# -# 1. default to xvda. -# -# 2. If --ide is specified use hda. -# -# 3. If --scsi is specified use sda. -# -# 4. Otherwise use a named $disk_device -# -device=xvda -if [ "${ide}" ]; then - device=hda -elif [ "${scsi}" ]; then - device=sda -else - if [ ! -z "${disk_device}" ]; then - device=`basename $disk_device` - fi -fi - -logMessage "Root device is /dev/$device" - - -# -# Now we have the options we can create the fstab. -# -has_xfs=0 -has_reiserfs=0 -has_btrfs=0 -cat < ${prefix}/etc/fstab -# /etc/fstab: static file system information. -# -# -proc /proc proc defaults 0 0 -devpts /dev/pts devpts rw,noexec,nosuid,gid=5,mode=620 0 0 -E_O_FSTAB -for part in `seq 1 ${NUMPARTITIONS}`; do - eval "PARTITION=\"\${PARTITION${part}}\"" - OLDIFS="${IFS}" - IFS=: - x=0 - for partdata in ${PARTITION}; do - eval "partdata${x}=\"${partdata}\"" - x=$(( $x+1 )) - done - IFS="${OLDIFS}" - - case "${partdata2}" in - xfs) - has_xfs=1 - ;; - reiserfs) - has_reiserfs=1 - ;; - btrfs) - has_btrfs=1 - ;; - esac - - if [ "${partdata2}" = "swap" ]; then - echo "/dev/${device}${part} none swap sw 0 0" >> ${prefix}/etc/fstab - else - echo "/dev/${device}${part} ${partdata3} ${partdata2} ${partdata4} 0 1" >> ${prefix}/etc/fstab - fi -done - - -# -# Finally we can install any required packages for the given root -# filesystem -# -if [ $has_xfs -eq 1 ]; then - installDebianPackage ${prefix} xfsprogs -fi -if [ $has_reiserfs -eq 1 ]; then - installDebianPackage ${prefix} reiserfsprogs -fi -if [ $has_btrfs -eq 1 ]; then - installDebianPackage ${prefix} btrfs-tools -fi - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/intrepid/90-make-fstab b/hooks/intrepid/90-make-fstab new file mode 120000 index 0000000..a9b306a --- /dev/null +++ b/hooks/intrepid/90-make-fstab @@ -0,0 +1 @@ +../common/90-make-fstab-deb \ No newline at end of file diff --git a/hooks/karmic/40-setup-networking b/hooks/karmic/40-setup-networking deleted file mode 100755 index b5f456f..0000000 --- a/hooks/karmic/40-setup-networking +++ /dev/null @@ -1,170 +0,0 @@ -#!/bin/sh -# -# This script sets up the /etc/network/interface file for the new -# image. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - - -# -# Make sure we have an /etc/network directory. -# -mkdir -p ${prefix}/etc/network - - -# -# A function to setup DHCP for our new image. -# -setupDynamicNetworking () -{ - # - # The host is using DHCP. - # - cat < ${prefix}/etc/network/interfaces -# This file describes the network interfaces available on your system -# and how to activate them. For more information, see interfaces(5). - -# The loopback network interface -auto lo -iface lo inet loopback - -# The primary network interface -auto eth0 -iface eth0 inet dhcp -# post-up ethtool -K eth0 tx off - -# -# The commented out line above will disable TCP checksumming which -# might resolve problems for some users. It is disabled by default -# -E_O_DHCP -} - - - -# -# A function to setup static IP addresses for our new image. -# -setupStaticNetworking () -{ - # - # if $p2p is set then add a "pointopoint" setting. - # - point=''; - if [ ! -z "${p2p}" ]; then - point="pointopoint ${p2p}" - else - point='' - fi - - # - # broadcast address? - # - bcast=''; - if [ ! -z "${broadcast}" ]; then - bcast=" broadcast ${broadcast}" - fi - - # - # We have a static IP address - # - cat <${prefix}/etc/network/interfaces -# This file describes the network interfaces available on your system -# and how to activate them. For more information, see interfaces(5). - -# The loopback network interface -auto lo -iface lo inet loopback - -# The primary network interface -auto eth0 -iface eth0 inet static - address ${ip1} - gateway ${gateway} - netmask ${netmask} - ${bcast} - ${point} - # post-up ethtool -K eth0 tx off - -# -# The commented out line above will disable TCP checksumming which -# might resolve problems for some users. It is disabled by default -# -E_O_STATIC - - interface=1 - count=2 - - while [ "${count}" -le "${ip_count}" ]; do - - value=\$ip${count} - value=`eval echo $value` - - logMessage Adding etho:${interface} - - cat <>${prefix}/etc/network/interfaces -auto eth0:${interface} -iface eth0:${interface} inet static - address ${value} - netmask ${netmask} - # post-up ethtool -K eth0 tx off -E_O_STATIC - count=`expr $count + 1` - interface=`expr $interface + 1` - done - - # - # Hooks are run chrooted, hence the resolv.conf is moved - # temporarily to /etc/resolv.conf.old. Use that file, it - # will be restored after hooks are run. - # - if [ '' != "$nameserver" ]; then - rm -f ${prefix}/etc/resolv.conf.old - for ns in $nameserver; do - echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old - done - else - cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old - fi -} - - - - -# -# Call the relevant function -# -if [ -z "${dhcp}" ]; then - logMessage "Setting up static networking" - setupStaticNetworking - -else - logMessage "Setting up DHCP networking" - setupDynamicNetworking -fi - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/karmic/40-setup-networking b/hooks/karmic/40-setup-networking new file mode 120000 index 0000000..5b8a76d --- /dev/null +++ b/hooks/karmic/40-setup-networking @@ -0,0 +1 @@ +../common/40-setup-networking-deb \ No newline at end of file diff --git a/hooks/karmic/70-install-ssh b/hooks/karmic/70-install-ssh deleted file mode 100755 index e6eca32..0000000 --- a/hooks/karmic/70-install-ssh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh -# -# This script installs OpenSSH Server on the newly created guest. -# -# It does this by generating the keys within the host, since guests -# do not have the necessary /dev/random and /dev/urandom to generate -# their own keys before boot. -# -# Dmitry Nedospasov -# -- -# http://nedos.net/ - -prefix=$1 - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - -# -# Log our start -# -logMessage Script $0 starting - -# -# Since our guests doesn't have an RNG, generate the keys from the host -# -# First, create an ssh directory -# -mkdir -p ${prefix}/etc/ssh - -# -# Second, Generate the Host RSA Key -# -if [ ! -f ${prefix}/etc/ssh/ssh_host_rsa_key ]; then -if ssh-keygen -t rsa -N "" -f ${prefix}/etc/ssh/ssh_host_rsa_key -C "root@${hostname}"; then - logMessage "successfully generetaged Host RSA" -else - logMessage "failed to generate Host RSA Key" -fi -fi - -# -# Third, Generate the Host DSA Key -# -if [ ! -f ${prefix}/etc/ssh/ssh_host_dsa_key ]; then -if ssh-keygen -t dsa -N "" -f ${prefix}/etc/ssh/ssh_host_dsa_key -C "root@${hostname}"; then - logMessage "successfully generetaged Host DSA" -else - logMessage "failed to generate Host DSA Key" -fi -fi - -# -# Install ssh -# -installDebianPackage ${prefix} openssh-server - -# -# Log our finish -# -logMessage Script $0 finished - diff --git a/hooks/karmic/70-install-ssh b/hooks/karmic/70-install-ssh new file mode 120000 index 0000000..7749dd0 --- /dev/null +++ b/hooks/karmic/70-install-ssh @@ -0,0 +1 @@ +../common/70-install-ssh-deb \ No newline at end of file diff --git a/hooks/karmic/80-install-modules b/hooks/karmic/80-install-modules deleted file mode 100755 index 45905ff..0000000 --- a/hooks/karmic/80-install-modules +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/sh -# -# Install modules from the host system into the new image, and -# ensure that 'module-init-tools' is setup. -# -# This is most likely required if you're using a custom kernel -# for your Xen system. But even if it isn't required it can't -# really do anything bad; just waste a bit of space. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - - - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - -if [ ${pygrub} ]; then - logMessage "pygrub set, skipping module install" -else -# -# The name of the package containing the correct modules. -# -linux_modules_package="linux-modules-$(uname -r)" - -# -# Attempt to install that package. This will either work on an Etch -# system, or fail on a Sarge/custom kernel. -# -if [ -n "${modules}" -a -d "${modules}" ]; then - - # - # Modules path was specified during install - # - logMessage "Copying modules from ${modules}" - - mkdir -p ${prefix}/lib/modules - cp -au ${modules} ${prefix}/lib/modules -elif chroot ${prefix} /usr/bin/apt-cache show ${linux_modules_package} >/dev/null 2>/dev/null; then - - logMessage "Package '${linux_modules_package}' is available - installing" - - # - # If it worked then we can install the package. - # - installDebianPackage ${prefix} ${linux_modules_package} -else - - # - # Fall back to copying over modules from the host to the new - # system. - # - logMessage "Package '${linux_modules_package}' is not available" - logMessage "Copying modules from /lib/modules/$(uname -r)" - - mkdir -p ${prefix}/lib/modules - cp -au /lib/modules/$(uname -r) ${prefix}/lib/modules -fi - -# -# Install the module-init-tools package. -# -installDebianPackage ${prefix} module-init-tools - -fi # if pygrub - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/karmic/80-install-modules b/hooks/karmic/80-install-modules new file mode 120000 index 0000000..8826dcd --- /dev/null +++ b/hooks/karmic/80-install-modules @@ -0,0 +1 @@ +../common/80-install-modules-deb \ No newline at end of file diff --git a/hooks/karmic/90-make-fstab b/hooks/karmic/90-make-fstab deleted file mode 100755 index 42d775d..0000000 --- a/hooks/karmic/90-make-fstab +++ /dev/null @@ -1,120 +0,0 @@ -#!/bin/sh -# -# This script is responsible for setting up /etc/fstab upon the -# new instance. -# -# This should be a simple job, but it is complicated by some of the -# differences between filesystems - some root filesystems will require -# the installation of new packages, and we have to handle that here. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - - -# -# Find the root device. -# -# 1. default to xvda. -# -# 2. If --ide is specified use hda. -# -# 3. If --scsi is specified use sda. -# -# 4. Otherwise use a named $disk_device -# -device=xvda -if [ "${ide}" ]; then - device=hda -elif [ "${scsi}" ]; then - device=sda -else - if [ ! -z "${disk_device}" ]; then - device=`basename $disk_device` - fi -fi - -logMessage "Root device is /dev/$device" - - -# -# Now we have the options we can create the fstab. -# -has_xfs=0 -has_reiserfs=0 -has_btrfs=0 -cat < ${prefix}/etc/fstab -# /etc/fstab: static file system information. -# -# -proc /proc proc defaults 0 0 -devpts /dev/pts devpts rw,noexec,nosuid,gid=5,mode=620 0 0 -E_O_FSTAB -for part in `seq 1 ${NUMPARTITIONS}`; do - eval "PARTITION=\"\${PARTITION${part}}\"" - OLDIFS="${IFS}" - IFS=: - x=0 - for partdata in ${PARTITION}; do - eval "partdata${x}=\"${partdata}\"" - x=$(( $x+1 )) - done - IFS="${OLDIFS}" - - case "${partdata2}" in - xfs) - has_xfs=1 - ;; - reiserfs) - has_reiserfs=1 - ;; - btrfs) - has_btrfs=1 - ;; - esac - - if [ "${partdata2}" = "swap" ]; then - echo "/dev/${device}${part} none swap sw 0 0" >> ${prefix}/etc/fstab - else - echo "/dev/${device}${part} ${partdata3} ${partdata2} ${partdata4} 0 1" >> ${prefix}/etc/fstab - fi -done - - -# -# Finally we can install any required packages for the given root -# filesystem -# -if [ $has_xfs -eq 1 ]; then - installDebianPackage ${prefix} xfsprogs -fi -if [ $has_reiserfs -eq 1 ]; then - installDebianPackage ${prefix} reiserfsprogs -fi -if [ $has_btrfs -eq 1 ]; then - installDebianPackage ${prefix} btrfs-tools -fi - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/karmic/90-make-fstab b/hooks/karmic/90-make-fstab new file mode 120000 index 0000000..a9b306a --- /dev/null +++ b/hooks/karmic/90-make-fstab @@ -0,0 +1 @@ +../common/90-make-fstab-deb \ No newline at end of file