#!/bin/bash if [ ! -f $1 ]; then echo "$1 doesn't exist" exit 1 fi MNTPOINT=/tmp/updboottree.$$ INITRD=/tmp/updboottree.$$.initrd LOOPMNT=/tmp/updboottree.$$.initrdmnt rm -rf $MNTPOINT $LOOPMNT mkdir $MNTPOINT $LOOPMNT mount -t vfat -o loop $1 $MNTPOINT gunzip < $MNTPOINT/initrd.img > $INITRD mount -o loop $INITRD $LOOPMNT FROM=$2 TO=$FROM if [ $(echo $FROM | cut -d- -f1) = loader ]; then TO=loader fi if [ ! -x $LOOPMNT/sbin/$TO ]; then echo "$LOOPMNT/sbin/$TO doesn't exist" else cp $FROM $FROM.foo strip $FROM.foo install $FROM.foo $LOOPMNT/sbin/$TO rm -f $FROM.foo fi umount $LOOPMNT gzip -9 < $INITRD > $INITRD.new cp $INITRD.new $MNTPOINT/initrd.img umount $MNTPOINT if [ -n "$3" -a -f "$3" ]; then echo "Replacing $3" cp -f $INITRD.new $3 fi rm -rf $MNTPOINT $LOOPMNT $INITRD $INITRD.new