[Ovirt-devel] [PATCH node-image] edit-livecd: optionally append kernel boot params
Alan Pevec
apevec at redhat.com
Tue Dec 2 10:57:36 UTC 2008
---
edit-livecd | 37 +++++++++++++++++++++++++++++--------
1 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/edit-livecd b/edit-livecd
index 0200034..8025fb6 100755
--- a/edit-livecd
+++ b/edit-livecd
@@ -25,12 +25,17 @@ warn() { printf '%s: %s\n' "$ME" "$*" >&2; }
try_h() { printf "Try \`$ME -h' for more information.\n" >&2; }
die() { warn "$@"; try_h; exit 1; }
+NODEIMG_DEFAULT=/usr/share/ovirt-node-image/ovirt-node-image.iso
+CD=$NODEIMG_DEFAULT
+
usage() {
case $# in 1) warn "$1"; try_h; exit 1;; esac
cat <<EOF
-Usage: $ME livecd.iso program
- livecd.iso - LiveCD ISO to edit
- program - Arbitrary program/script that is run inside of the livecd root
+Usage: $ME -i LiveCD.iso [-b bootparams] [-p program]
+ -h: display this help and exit
+ -i: livecd.iso - LiveCD ISO to edit (default: $NODEIMG_DEFAULT)
+ -b: bootparams - optional parameters appended to the kernel command line
+ -p: program - Arbitrary program/script that is run inside of the livecd root
filesystem. This script is not run in a chroot environment so
it can access the host filesystem. The program should be executable
If program is omitted the script will pause and allow the user in
@@ -48,16 +53,26 @@ EOF
# exit after any error:
set -e
-test $# -lt 1 && { usage; exit 1; }
+err=0 help=0
+while getopts :b:i:p:h c; do
+ case $c in
+ i) CD=$OPTARG;;
+ b) PARAMS=$OPTARG;;
+ p) PROG=$OPTARG;;
+ h) help=1;;
+ '?') err=1; warn "invalid option: \`-$OPTARG'";;
+ :) err=1; warn "missing argument to \`-$OPTARG' option";;
+ *) err=1; warn "internal error: \`-$OPTARG' not handled";;
+ esac
+done
+test $err = 1 && { try_h; exit 1; }
+test $help = 1 && { usage; exit 0; }
# first, check to see we are root
if [ $( id -u ) -ne 0 ]; then
die "Must run as root"
fi
-CD=$1
-PROG=$2
-
which mkisofs mksquashfs sed > /dev/null 2>&1
WDIR=`mktemp -d $PWD/livecd.XXXXXXXXXX`
@@ -81,7 +96,8 @@ function mnt() {
addExit "rm -Rf $WDIR"
-LABEL=$(isoinfo -d -i $CD | awk -F ": " '/Volume id:/ {print $2}')
+eval $(/lib/udev/vol_id $CD)
+LABEL=$ID_FS_LABEL
# mount the CD image
mnt "-t auto $CD -o loop,ro" cd
@@ -122,6 +138,11 @@ mksquashfs $WDIR/sq-w/ $WDIR/cd-w/LiveOS/squashfs.img -noappend
echo ">>> Recomputing MD5 sums"
( cd $WDIR/cd-w && find . -type f -not -name md5sum.txt -not -path '*/isolinux/*' -print0 | xargs -0 -- md5sum > md5sum.txt )
+if [ -n "$PARAMS" ]; then
+ echo ">>> Appending boot parameters"
+ sed -i 's/^ append .*$/& '$PARAMS/ "$WDIR/cd-w/isolinux/isolinux.cfg"
+fi
+
echo ">>> Creating ISO image $ISO"
mkisofs \
-V "$LABEL" \
--
1.5.6.5
More information about the ovirt-devel
mailing list