From 502d99a2567724ac5153a0eaa64bc13e8d13ce24 Mon Sep 17 00:00:00 2001 From: rjones Date: Fri, 7 Sep 2007 16:36:03 +0100 Subject: [PATCH] Update. --- .cvsignore | 3 ++- Makefile | 23 +++++++++++++++++------ livecd-post.sh.in | 40 ++++++++++++++++++++++++++++++++++++++++ livecd-test.ks.in | 26 +++++++++++++++++++------- p2v.init | 23 +++++++++++++++++++++++ virt-p2v.sh | 9 +++++++++ 6 files changed, 110 insertions(+), 14 deletions(-) create mode 100644 livecd-post.sh.in create mode 100644 p2v.init create mode 100755 virt-p2v.sh diff --git a/.cvsignore b/.cvsignore index 213f93d..72bc0c4 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1,2 +1,3 @@ *.iso -livecd-test.ks \ No newline at end of file +livecd-test.ks +livecd-post.sh \ No newline at end of file diff --git a/Makefile b/Makefile index 4cc99aa..0fec87d 100644 --- a/Makefile +++ b/Makefile @@ -19,27 +19,38 @@ BASEREPO := http://download.fedora.redhat.com/pub/fedora/linux/releases/7/Fedora export http_proxy := http://127.0.0.1:3128/ export ftp_proxy := http://127.0.0.1:3128/ +LABEL := virt-p2v-$(VERSION) + #---------------------------------------------------------------------- all: @echo "make build Build the live CD ISO" - @echo "make boot [ISO=foo.iso] Boot the named ISO (uses qemu)" + @echo "make boot [ISO=foo.iso] Boot built/named ISO (uses qemu)" build: livecd-test.ks + rm -f $(LABEL).iso livecd-creator \ --config=$< \ - --fslabel=virt-p2v-$(VERSION) + --fslabel=$(LABEL) ls -lhtr *.iso -ISO = virt-p2v-$(VERSION).iso +ISO = $(LABEL).iso boot: - qemu -m 512 $(ISO) + qemu -m 512 -cdrom $(ISO) -livecd-test.ks: livecd-test.ks.in Makefile +livecd-test.ks: livecd-test.ks.in livecd-post.sh Makefile sed \ -e 's|@BASEREPO@|$(BASEREPO)|g' \ -e 's|@LANG@|$(LANG)|g' \ -e 's|@KEYBOARD@|$(KEYBOARD)|g' \ -e 's|@TIMEZONE@|$(TIMEZONE)|g' \ - < $< > $@ \ No newline at end of file + < $< | cat - livecd-post.sh > $@ + +livecd-post.sh: livecd-post.sh.in p2v.init virt-p2v.sh Makefile + sed \ + -e '/@P2V.INIT@/ r p2v.init' \ + -e '/@P2V.INIT@/ d' \ + -e '/@VIRT-P2V.SH@/ r virt-p2v.sh' \ + -e '/@VIRT-P2V.SH@/ d' \ + < $< > $@ diff --git a/livecd-post.sh.in b/livecd-post.sh.in new file mode 100644 index 0000000..82427ae --- /dev/null +++ b/livecd-post.sh.in @@ -0,0 +1,40 @@ +# This is the post-configuration section of the kickstart +# installer. It runs inside the live CD chroot while it is +# being created (after all the packages have been installed) +# but before we make the ISO. + +# Create a 'p2v' init script which runs last thing during the +# boot. + +cat > /etc/init.d/p2v << '__EOF__' +@P2V.INIT@ +__EOF__ + +# Make the 'p2v' script run when the live CD boots. +chmod 0755 /etc/init.d/p2v +/sbin/restorecon /etc/init.d/p2v +/sbin/chkconfig --add p2v + +cat > /usr/bin/virt-p2v.sh << '__EOF__' +@VIRT-P2V.SH@ +__EOF__ + +chmod 0755 /usr/bin/virt-p2v.sh +/sbin/restorecon /usr/bin/virt-p2v.sh + +# Turn off firstboot for livecd boots. +echo "RUN_FIRSTBOOT=NO" > /etc/sysconfig/firstboot + +# Don't start yum-updatesd for livecd boots. +chkconfig --level 345 yum-updatesd off + +# Don't start cron/at as they tend to spawn things which are +# disk intensive that are painful on a live image. +chkconfig --level 345 crond off +chkconfig --level 345 atd off +chkconfig --level 345 anacron off +chkconfig --level 345 readahead_early off +chkconfig --level 345 readahead_later off + +# Stopgap fix for RH #217966; should be fixed in HAL instead +touch /media/.hal-mtab diff --git a/livecd-test.ks.in b/livecd-test.ks.in index 0d3975e..1b55ad4 100644 --- a/livecd-test.ks.in +++ b/livecd-test.ks.in @@ -1,3 +1,5 @@ +# $Id$ + lang @LANG@ keyboard @KEYBOARD@ timezone @TIMEZONE@ @@ -19,19 +21,29 @@ rootfiles # dd, sleep, sync, etc. coreutils -# dmsetup + +# For device mapping device-mapper -# blockdev, mount, umount util-linux -# modprobe module-init-tools -# gzip gzip -# ssh + +# For remote communications openssh-clients -# nc nc +# For the shell script +dialog +grep +sed +gawk + +# Some other generally useful packages +which +perl +rpm + -# EOF +# The contents of livecd-post.sh are appended to the file after %post. +%post diff --git a/p2v.init b/p2v.init new file mode 100644 index 0000000..cb54b24 --- /dev/null +++ b/p2v.init @@ -0,0 +1,23 @@ +#!/bin/bash +# +# p2v: Init script which starts the p2v process. +# +# chkconfig: 345 99 99 +# description: Init script which starts the p2v process. + +. /etc/init.d/functions + +# How were we called? +case "$1" in +start) + # Some modules which we definitely will need. + /sbin/modprobe dm_mod + /sbin/modprobe dm_snapshot + + # Start the P2V script. + /usr/bin/virt-p2v.sh + + ;; + +*) ;; +esac diff --git a/virt-p2v.sh b/virt-p2v.sh new file mode 100755 index 0000000..16d3fd9 --- /dev/null +++ b/virt-p2v.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# +# virt-p2v.sh is a shell script which performs a physical to +# virtual conversion of local disks, interactively. +# +# By Richard W.M. Jones + + + -- 1.8.3.1