From 1408aaac058e85b8e38d38ae11cc61aacd09ac2f Mon Sep 17 00:00:00 2001 From: Greg Price Date: Sun, 28 Oct 2007 02:47:50 -0400 Subject: [PATCH] postinst script, nicer pathnames, and read password hash from a file The postinst script has been tested by running it directly, but I still haven't attempted actually building and installing the package. svn path=/trunk/packages/sipb-xen-guest-installer/sipb-xen-guest-installer/; revision=221 --- debian/sipb-xen-guest-installer.postinst | 53 ++++++++++++++++++++++++++++++ files/usr/sbin/sipb-xen-make-iso | 8 +++-- 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100755 debian/sipb-xen-guest-installer.postinst diff --git a/debian/sipb-xen-guest-installer.postinst b/debian/sipb-xen-guest-installer.postinst new file mode 100755 index 0000000..8b81a90 --- /dev/null +++ b/debian/sipb-xen-guest-installer.postinst @@ -0,0 +1,53 @@ +#!/bin/sh +# postinst script for sipb-xen-guest-installer +# +# see: dh_installdeb(1) + +set -e +set -x +#set -n + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + for d in /srv/guest-installer/*; do + # download the actual iso, unpack it, patch it. + wget -nc -i $d/iso.url -O $d/cdrom.orig.iso + MOUNTDIR=$(mktemp -d /mnt/sipb-xen-guest-installer.cdrom.XXXXXX) + mount -t iso9660 -o loop $d/cdrom.orig.iso $MOUNTDIR + rm -rf $d/cdrom.orig; cp -a $MOUNTDIR $d/cdrom.orig + umount $MOUNTDIR; rmdir $MOUNTDIR + rm -rf $d/cdrom; cp -a $d/cdrom.orig $d/cdrom + patch -d $d/cdrom -p1 <$d/cdrom.patch + done + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + diff --git a/files/usr/sbin/sipb-xen-make-iso b/files/usr/sbin/sipb-xen-make-iso index 82abba9..97b651e 100755 --- a/files/usr/sbin/sipb-xen-make-iso +++ b/files/usr/sbin/sipb-xen-make-iso @@ -6,13 +6,17 @@ import shutil import tempfile from subprocess import call -def make_debian_cd(basetree, passhash): - old_preseed = file(os.path.join(basetree, 'preseed.cfg')) +data_dir = '/srv/guest-installer' + +def make_debian_cd(name, passhashfile): + basetree = os.path.join(data_dir, name) tmptree = tempfile.mkdtemp('', 'auto-install.', '/tmp') cdtree = os.path.join(tmptree, 'cdrom') shutil.copytree(os.path.join(basetree, 'cdrom'), cdtree, symlinks=True) new_preseed = file(os.path.join(cdtree, 'preseed.cfg'), 'w') + old_preseed = file(os.path.join(basetree, 'preseed.cfg')) new_preseed.write(old_preseed.read()) + passhash = file(passhashfile).read() new_preseed.write('d-i passwd/root-password-crypted password '+passhash+'\n') new_preseed.close() output_iso = os.path.join(tmptree, 'install.iso') -- 1.7.9.5