diff --git a/etc/hook.d/10-disable-tls b/etc/hook.d/10-disable-tls deleted file mode 100755 index 8f62478..0000000 --- a/etc/hook.d/10-disable-tls +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/sh -# -# This script disables TLS on the new image. -# -# Steve -# -- -# http://www.steve.org.uk/ - - - -prefix=$1 -dist=$2 - - -# -# Disable TLS and create an empty directory. -# -function disableTLS -{ - mv ${prefix}/lib/tls ${prefix}/lib/tls.disabled - mkdir ${prefix}/lib/tls -} - - -# -# Install a Debian package onto the new system. -# -function installDebianPackage -{ - package=$1 - - DEBIAN_FRONTEND=noninteractive chroot ${prefix} /usr/bin/apt-get --yes --force-yes install ${package} - -} - - - - -# -# This function will disable TLS and install 'libc6-xen' on sid/etch -# systems. -# -function setupDebian -{ - disableTLS - - # - # For sid + etch systems install libc6-xen - # - case "${dist}" in - etch|sid) - installDebianPackage libc6-xen - installDebianPackage libc6-xen - ;; - esac -} - - - -# -# Handle CentOS -# -function setupCentOS4 -{ - disableTLS -} - - - - -# -# 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/15-disable-hwclock b/etc/hook.d/15-disable-hwclock deleted file mode 100755 index 81139e6..0000000 --- a/etc/hook.d/15-disable-hwclock +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# -# This script disables the hardware clock. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 -dist=$2 - - - -# -# Disable the startup scripts from all runlevels. -# -function setupDebian -{ - chmod -x ${prefix}/etc/init.d/hwclock.sh - chmod -x ${prefix}/etc/init.d/hwclockfirst.sh -} - - - -# -# Entry point to the script. -# -case "${dist}" in - sarge|etch|sid) - setupDebian - ;; - *) - echo "Unknown distribution '${dist}'. Fixme"; - exit; - ;; -esac - - - - diff --git a/etc/hook.d/20-setup-apt b/etc/hook.d/20-setup-apt deleted file mode 100755 index 7169c31..0000000 --- a/etc/hook.d/20-setup-apt +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/sh -# -# This script sets up the /etc/apt/sources.list for APT. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 -dist=$2 - - -# -# This function will setup the sources.list file for new installations -# of Debian GNU/Linux. -# -function setupDebian -{ - cat < ${prefix}/etc/apt/sources.list -# -# /etc/apt/sources.list -# - - -# -# ${dist} -# -deb ${mirror} ${dist} main contrib non-free -deb-src ${mirror} ${dist} main contrib non-free - -# -# Security updates -# -deb http://security.debian.org/ stable/updates main contrib non-free -deb-src http://security.debian.org/ stable/updates main contrib non-free - - -E_O_APT - - - - # - # Now that the sources have been setup make sure the system is up to date. - # - chroot ${prefix} /usr/bin/apt-get update -} - - - - -# -# This function sets up Yum on the new CentOS4 installations. -# -function setupCentOS4 -{ - perl -pi.bak -e 's/enabled=0/enabled=1/g' ${prefix}/etc/yum.repos.d/*.repo - perl -pi.bak -e 's/gpgcheck=1/gpgcheck=0/g' ${prefix}/etc/yum.repos.d/*.repo - perl -pi.bak -e 's/^\#baseurl/baseurl/g' ${prefix}/etc/yum.repos.d/*.repo - perl -pi.bak -e 's/^mirrorlist/#mirrorlist/g' ${prefix}/etc/yum.repos.d/*.repo - perl -pi.bak -e 's/\$releasever/4/g' ${prefix}/etc/yum.repos.d/*.repo - - # - # Update the package lists that Yum knows about. - # - if [[ -x ${prefix}/usr/bin/yum ]]; then - chroot ${prefix}/usr/bin/yum update - fi -} - - - - -# -# 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/30-fix-inittab b/etc/hook.d/30-fix-inittab deleted file mode 100755 index 461b4c8..0000000 --- a/etc/hook.d/30-fix-inittab +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -# -# This script does two things: -# -# 1. Sets the console type for the first terminal to 'console'. -# 2. Comments out all virtual terminals which aren't on the first console. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 -dist=$2 - - -sed -i -e 's/tty[0-9]$/console/g' -e 's/^\([2-6].*:respawn*\)/#\1/' -e 's/^T/#\t/' ${prefix}/etc/inittab diff --git a/etc/hook.d/40-setup-networking b/etc/hook.d/40-setup-networking deleted file mode 100755 index 12d9430..0000000 --- a/etc/hook.d/40-setup-networking +++ /dev/null @@ -1,184 +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 -dist=$2 - - - -# -# Sets up the networking installation for Debian GNU/Linux. -# -function setupDebian -{ - if [[ -z "${dhcp}" ]]; then - - # - # 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} - # 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` - - 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 - else - - # - # 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 - - fi -} - - - - -# -# Setup networking for CentOS4 -# -function setupCentOS4 -{ - - # - # 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` - - 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 - - else - - cat <${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0 -DEVICE=eth0 -BOOTPROTO=dhcp -ONBOOT=yes -E_O_DHCP - fi - - # - # Don't forget to setup the default route. - # - cat <${prefix}/etc/sysconfig/network -NETWORKING=yes -GATEWAY=${gateway} -HOSTNAME=${hostname} -EOF -} - - - - -# -# Entry point to the script. -# -case "${dist}" in - sarge|etch|sid) - mkdir -p ${prefix}/etc/network - setupDebian - ;; - centos4) - mkdir -p ${prefix}/etc/sysconfig/network-scripts/ - setupCentOS4 - ;; - *) - echo "Unknown distribution '${dist}'. Fixme"; - exit; - ;; -esac - - - - diff --git a/etc/hook.d/50-setup-hostname b/etc/hook.d/50-setup-hostname deleted file mode 100755 index 7c0aa67..0000000 --- a/etc/hook.d/50-setup-hostname +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/sh -# -# This script places the new systems hostname into a couple of files within -# the new image. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 -dist=$2 - - -# -# This script doesn't do anything different on a per-distribution basis -# - -echo ${hostname} > ${prefix}/etc/hostname -echo ${hostname} > ${prefix}/etc/mailname - - -# -# Fixup the /etc/hosts file upon the new image for -# machines with static IPs -# -if [[ -z "${dhcp}" ]]; then - - # Non-IPv6 stuff. - grep -v '\(::\|IPv6\)' /etc/hosts > ${prefix}/etc/hosts - - # New entry. - echo "${ip1} ${hostname}" >> ${prefix}/etc/hosts - echo " " >> ${prefix}/etc/hosts - - # IPv6 stuff. - grep '\(::\|IPv6\)' /etc/hosts >> ${prefix}/etc/hosts -fi - - -# -# Allow the host system to know the IP address of our new guest. -# -if [[ -z "${dhcp}" ]]; then - - if ( grep ${hostname} /etc/hosts > /dev/null ) ; then - - # Host already has IP address for the given host. - : - else - echo "${ip1} ${hostname}" >> /etc/hosts - - # - # If we've updated the /etc/hosts file on the host machine - # and there is an installation of dnsmasq installed then - # reload it. - # - # This will let the local LAN clients lookup the new address. - # - if [ -x /usr/sbin/dnsmasq ] ; - if [ -e /var/run/dnsmasq.pid ]; then - kill -HUP `cat /var/run/dnsmasq.pid` - fi - fi - fi -fi diff --git a/etc/hook.d/55-create-dev b/etc/hook.d/55-create-dev deleted file mode 100755 index b4cf6b9..0000000 --- a/etc/hook.d/55-create-dev +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh -# -# This script ensures that the new guest images have a nicely -# populated /dev directory. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 -dist=$2 - -# -# This routine sets up /dev on a Debian GNU/Linux system. -# -function setupDebian -{ - cd ${prefix}/dev - ./MAKEDEV generic -} - - -# -# This routine sets up /dev on a CentOS4 system. -# -function setupCentOS4 -{ - chroot ${prefix} /bin/sh -c 'cd /dev && ./MAKEDEV console' - chroot ${prefix} /bin/sh -c 'cd /dev && ./MAKEDEV null' - chroot ${prefix} /bin/sh -c 'cd /dev && ./MAKEDEV zero' -} - - - - -# -# 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/60-copy-host-files b/etc/hook.d/60-copy-host-files deleted file mode 100755 index 1bd59d3..0000000 --- a/etc/hook.d/60-copy-host-files +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/perl -w -# -# This script copies "essential" files from the host to the new -# system. -# -# At the same time it tries to copy all non-system accounts from -# the host system into the new guest unless the root password is -# being setup with --passwd. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -use strict; -use Env; -use File::Copy; - - -my $prefix = shift; - -die "Prefix must be given" unless defined( $prefix ); -die "Prefix must be a directory" unless ( -d $prefix ); - - -# -# Make sure we have $prefix/etc -# -die "Prefix is missing /etc : $prefix" unless ( -d $prefix . "/etc" ); - - -# -# Copy some files literally. -# -my @files = ( "/etc/hosts", - "/etc/resolv.conf", - "/etc/gshadow", - "/etc/group" - ); - -foreach my $file ( @files ) -{ - File::Copy::copy( $file, $prefix . "/etc/" ); -} - - -# -# Only copy the /etc/shadow file if --passwd is *not* specified. -# -if ( !$ENV{'passwd'} ) -{ - File::Copy::copy( "/etc/shadow", $prefix . "/etc/" ); -} - - - -# -# If sudo is installed upon the host then install it upon the guest, -# with the same setup. -# -if ( ( -e "/etc/sudoers" ) && ( -x $prefix . "/usr/bin/apt-get" ) ) -{ - File::Copy::copy( "/etc/sudoers", $prefix . "/etc" ); - chmod( 0440, $prefix. "/etc/sudoers" ); - - `DEBIAN_FRONTEND=noninteractive chroot ${prefix} /usr/bin/apt-get --yes --force-yes install sudo`; -} - - - -# -# Now modify the password file *unless* the "--passwd" option -# was given. -# -if ( ! $ENV{'passwd'} ) -{ - open( ORIG, "<", "/etc/passwd" ) - or die "Failed to open /etc/passwd - $!"; - open( NEW, ">>", $prefix . "/etc/passwd" ) - or die "Failed to open $prefix/etc/passwd - $!"; - - foreach my $line ( ) - { - chomp( $line ); - if ( $line =~ /^([^:]+):([^:]+):([^:]+)/ ) - { - my $user = $1; - my $pass = $2; - my $uid = $3; - - if ( ( $uid >= 1000 ) && - ( $user ne "nobody" ) ) - { - print NEW $line . "\n"; - } - } - } - - close( NEW ); - close( ORIG ); -} diff --git a/etc/hook.d/65-copy-user-files b/etc/hook.d/65-copy-user-files deleted file mode 100755 index 9886f13..0000000 --- a/etc/hook.d/65-copy-user-files +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# -# Copy files from a 'skel' directory, if present, into the -# new images -# - - -prefix=$1 -dist=$2 - - -# -# This script doesn't do anything different on a per-distribution basis -# - - - -if [ -d /etc/xen-tools/skel ]; then - - # - # Copy everything from skel directory, even "dotfiles". - # - (cd /etc/xen-tools/skel; tar -cf - . ) | (cd ${prefix}/; tar -xpf -) - -else - - echo "skel directory not present, ignoring." - -fi diff --git a/etc/hook.d/70-install-ssh b/etc/hook.d/70-install-ssh deleted file mode 100755 index 4516add..0000000 --- a/etc/hook.d/70-install-ssh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/sh -# -# This script installs OpenSSH upon the new system. It must make sure -# that the server is not running before it exits - otherwise the temporary -# mounted directory will not be unmountable. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 -dist=$2 - - -# -# Install a Debian package onto the new system. -# -function installDebianPackage -{ - package=$1 - - DEBIAN_FRONTEND=noninteractive chroot ${prefix} /usr/bin/apt-get --yes --force-yes install ${package} - -} - -# -# Sets up the installation of OpenSSH on a Debian GNU/Linux system. -# -function setupDebian -{ - case "${dist}" in - sarge) - installDebianPackage ssh - ;; - etch|sid) - installDebianPackage openssh-server - installDebianPackage openssh-client - ;; - esac - - # - # Make sure sshd isn't running, this will cause our unmounting of the - # disk image to fail.. - # - chroot ${prefix} /etc/init.d/ssh stop -} - - - -# -# Sets up the installation of OpenSSH on a CentOS4 installation. -# -function setupCentOS4 -{ - chroot ${prefix} /bin/mount /proc - chroot ${prefix} /usr/bin/yum -y install openssh-server - chroot ${prefix} /usr/bin/yum -y install openssh-server - chroot ${prefix} /bin/umount /proc -} - - - -# -# 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/80-install-modules b/etc/hook.d/80-install-modules deleted file mode 100755 index 58763be..0000000 --- a/etc/hook.d/80-install-modules +++ /dev/null @@ -1,63 +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 -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. -# -function copyModules -{ - mkdir -p ${prefix}/lib/modules - cp -R /lib/modules/*/ ${prefix}/lib/modules -} - - - -# -# Setup the modules on a Debian GNU/Linux system. -# -function setupDebian -{ - copyModules - DEBIAN_FRONTEND=noninteractive chroot ${prefix} /usr/bin/apt-get --yes --force-yes install module-init-tools -} - - - -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/90-make-fstab b/etc/hook.d/90-make-fstab deleted file mode 100755 index 7776598..0000000 --- a/etc/hook.d/90-make-fstab +++ /dev/null @@ -1,80 +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 - - -# -# This function installs a package upon the guest image. -# -function install_package -{ - package=$1 - - # - # Only install the package if we're not running under rpmstrap - # - if [ -z "${rpmstrap}" ]; then - DEBIAN_FRONTEND=noninteractive chroot ${prefix} /usr/bin/apt-get --yes --force-yes install $package - fi -} - - - - -# -# Options to mount the root filesystem with, we need to have -# different options for xfs. -# -# The default option works for ext2, ext3, and reiserfs. -# -options="errors=remount-ro" - -case "${fs}" in - xfs) - options="defaults" - ;; -esac - - -# -# Make sure we use ide style device names if required -# -device=sda -if [ "${ide}" ]; then - device=hda -fi - -# -# Now we have the options we can create the fstab. -# -cat < ${prefix}/etc/fstab -/dev/${device}1 / ${fs} ${options} 0 1 -/dev/${device}2 none swap sw 0 0 -proc /proc proc defaults 0 0 -E_O_FSTAB - - -# -# Finally we can install any required packages for the given root -# filesystem -# -case "${fs}" in - xfs) - install_package xfsprogs - ;; - reiserfs) - install_package reiserfsprogs - ;; -esac diff --git a/etc/hook.d/95-create-cfg b/etc/hook.d/95-create-cfg deleted file mode 100755 index e7e4eaa..0000000 --- a/etc/hook.d/95-create-cfg +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/sh -# -# This script is responsible for setting up the Xen Configuration file -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 -dist=$2 - - -# -# This script doesn't do anything different on a per-distribution basis -# - - -# -# Useful hook for testing. -# -output_dir=/etc/xen - -if [ "${testing}" ]; then - if [ -d ${testing_dir} ]; then - output_dir=${testing_dir} - fi -fi - - -# -# Make sure we use ide style device names if required -# -device=sda -if [ "${ide}" ]; then - device=hda -fi - - -echo "Creating Xen configuration file in /etc/xen .. " - -# -# Default stuff -# -cat < ${output_dir}/${hostname}.cfg -kernel = '${kernel}' -ramdisk = '${initrd}' -memory = ${memory} -name = '${hostname}' -root = '/dev/${device}1 ro' -disk = [ '${imagevbd},${device}1,w', '${swapvbd},${device}2,w' ] -E_O_CFG - - -# -# DHCP vs. Static -# -if [ "${dhcp}" ]; then - cat <> ${output_dir}/${hostname}.cfg -dhcp = "dhcp" -vif = [ '' ] -E_O_CFG -else - echo "vif = ['ip=${ip1}']" >> ${output_dir}/${hostname}.cfg -fi - diff --git a/etc/hook.d/99-clean-image b/etc/hook.d/99-clean-image deleted file mode 100755 index f1cc332..0000000 --- a/etc/hook.d/99-clean-image +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# -# This script cleans the newly created image appropriately both for -# RPM based systems and for APT systems. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 -dist=$2 - - -# -# Clean the APT package cache for Debian GNU/Linux. -# -function setupDebian -{ - chroot ${prefix} /usr/bin/apt-get clean -} - - -# -# 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