From 2862fb995dfd842a3113dbae23068a0fc8fbab96 Mon Sep 17 00:00:00 2001 From: steve Date: Wed, 24 May 2006 19:35:16 +0000 Subject: [PATCH] 2006-05-24 19:35:16 by steve More updates. --- etc/hook.d/20-setup-apt | 4 +-- etc/hook.d/65-copy-user-files | 8 +++++ etc/hook.d/70-install-ssh | 59 ++++++++++++++++++++--------------- etc/hook.d/80-install-modules | 48 ++++++++++++++++++++++------ etc/hook.d/95-create-cfg | 7 +++++ etc/hook.d/99-clean-image | 51 +++++++++++++++++++++--------- 6 files changed, 126 insertions(+), 51 deletions(-) diff --git a/etc/hook.d/20-setup-apt b/etc/hook.d/20-setup-apt index f1825f1..7169c31 100755 --- a/etc/hook.d/20-setup-apt +++ b/etc/hook.d/20-setup-apt @@ -15,7 +15,7 @@ dist=$2 # This function will setup the sources.list file for new installations # of Debian GNU/Linux. # -function setupDebianSources +function setupDebian { cat < ${prefix}/etc/apt/sources.list # @@ -76,7 +76,7 @@ function setupCentOS4 # case "${dist}" in sarge|etch|sid) - setupDebianSources + setupDebian ;; centos4) setupCentOS4 diff --git a/etc/hook.d/65-copy-user-files b/etc/hook.d/65-copy-user-files index 2b88d24..9886f13 100755 --- a/etc/hook.d/65-copy-user-files +++ b/etc/hook.d/65-copy-user-files @@ -6,6 +6,14 @@ prefix=$1 +dist=$2 + + +# +# This script doesn't do anything different on a per-distribution basis +# + + if [ -d /etc/xen-tools/skel ]; then diff --git a/etc/hook.d/70-install-ssh b/etc/hook.d/70-install-ssh index 85202e1..dcea39a 100755 --- a/etc/hook.d/70-install-ssh +++ b/etc/hook.d/70-install-ssh @@ -10,45 +10,52 @@ prefix=$1 +dist=$2 -if [ "${rpmstrap}" ]; then - # - # Use yum to install openssh if we can. - # - if [[ -x ${prefix}/usr/bin/yum ]]; then - chroot ${prefix}/usr/bin/yum -y install openssh-server - chroot ${prefix}/usr/bin/yum -y install openssh-server - else - echo "I don't know how to install OpenSSH for your distro." - fi - - # - # Finished. - # - exit -fi # -# This function installs a package upon the guest image. +# Sets up the installation of OpenSSH on a Debian GNU/Linux system. # -function install_package +function setupDebian { - package=$1 - - DEBIAN_FRONTEND=noninteractive chroot ${prefix} /usr/bin/apt-get --yes --force-yes install $package + DEBIAN_FRONTEND=noninteractive chroot ${prefix} /usr/bin/apt-get --yes --force-yes install ssh + # + # Make sure sshd isn't running, this will cause our unmounting of the + # disk image to fail.. + # + chroot ${prefix} /etc/init.d/ssh stop } # -# Install the package. +# Sets up the installation of OpenSSH on a CentOS4 installation. # -install_package ssh +function setupCentOS4 +{ + chroot ${prefix}/usr/bin/yum -y install openssh-server + chroot ${prefix}/usr/bin/yum -y install openssh-server +} + + # -# Make sure sshd isn't running, this will cause our unmounting of the -# disk image to fail.. +# Entry point to the script. # -chroot ${prefix} /etc/init.d/ssh stop +case "${dist}" in + sarge|etch|sid) + setupDebianSources + ;; + centos4) + setupCentOS4 + ;; + *) + echo "Unknown distribution '${dist}'. Fixme"; + exit; + ;; +esac + + + diff --git a/etc/hook.d/80-install-modules b/etc/hook.d/80-install-modules index 87047b3..58763be 100755 --- a/etc/hook.d/80-install-modules +++ b/etc/hook.d/80-install-modules @@ -12,22 +12,52 @@ # http://www.steve.org.uk/ -# -# The virtual image is mounted here. -# prefix=$1 +dist=$2 + # # 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 -R /lib/modules/*/ ${prefix}/lib/modules +function copyModules +{ + mkdir -p ${prefix}/lib/modules + cp -R /lib/modules/*/ ${prefix}/lib/modules +} + + # -# Now install the 'module-init-tools', unless running under rpmstrap. +# Setup the modules on a Debian GNU/Linux system. # -if [ -z "${rpmstrap}" ]; then - +function setupDebian +{ + copyModules DEBIAN_FRONTEND=noninteractive chroot ${prefix} /usr/bin/apt-get --yes --force-yes install module-init-tools -fi \ No newline at end of file +} + + + +function setupCentOS4 +{ + copyModules +} + + + +# +# Entry point to the script. +# +case "${dist}" in + sarge|etch|sid) + setupDebian + ;; + centos4) + setupCentOS4 + ;; + *) + echo "Unknown distribution '${dist}'. Fixme"; + exit; + ;; +esac diff --git a/etc/hook.d/95-create-cfg b/etc/hook.d/95-create-cfg index f14ae8a..125196d 100755 --- a/etc/hook.d/95-create-cfg +++ b/etc/hook.d/95-create-cfg @@ -8,6 +8,13 @@ prefix=$1 +dist=$2 + + +# +# This script doesn't do anything different on a per-distribution basis +# + # # Useful hook for testing. diff --git a/etc/hook.d/99-clean-image b/etc/hook.d/99-clean-image index ff94bb8..f1cc332 100755 --- a/etc/hook.d/99-clean-image +++ b/etc/hook.d/99-clean-image @@ -7,22 +7,45 @@ # -- # http://www.steve.org.uk/ + prefix=$1 +dist=$2 -if [ "${rpmstrap}" ]; then - - # - # Clean the crazy RPM scattered files. - # - find ${prefix}/etc -name '*.rpmorig' -exec rm -f \{\} \; - find ${prefix}/etc -name '*.rpmnew' -exec rm -f \{\} \; - -else - - # - # Clean APT cache - # +# +# Clean the APT package cache for Debian GNU/Linux. +# +function setupDebian +{ chroot ${prefix} /usr/bin/apt-get clean +} -fi + +# +# Clean a new image of CentOS4. +# +function setupCentOS4 +{ + find ${prefix}/ -name '*.rpmorig' -exec rm -f \{\} \; + find ${prefix}/ -name '*.rpmnew' -exec rm -f \{\} \; + chroot ${prefix}/usr/bin/yum clean all + +} + + + +# +# Entry point to the script. +# +case "${dist}" in + sarge|etch|sid) + setupDebianSources + ;; + centos4) + setupCentOS4 + ;; + *) + echo "Unknown distribution '${dist}'. Fixme"; + exit; + ;; +esac