commit 6e09be7ab25b8197fbe7818104082235558e1ba2 parent b8a4807c50499c30d295493d82057f8abc8994a2 Author: dsp <dsp@2f30.org> Date: Fri, 11 Jan 2019 13:36:09 -0700 script to modify an OpenBSD bsd.rd to include an auto_install or auto_upgrade file Diffstat:
A | autoinstallate | | | 47 | +++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 47 insertions(+), 0 deletions(-)
diff --git a/autoinstallate b/autoinstallate @@ -0,0 +1,47 @@ +#!/bin/sh +#modifies a bsd.rd to contain an auto{install,conf} file +#requires an updated cvs src to build rdsetroot +#the binary is placed under /tmp as well as the ramdisk +#Warning: if the file is not named auto_upgrade.conf or auto_install.conf +#the installer won't be able to find it! + +RDROOTDIR=/usr/src/distrib/common +TMPBIN=/tmp/rdsetroot +TMPRD=/tmp/ramdisk.img + +if [ $# -lt 2 ]; then + echo "Usage: $(basename $0) <bsr.rd> <autofile>" + exit 1 +fi + +if [ ! -d $RDROOTDIR ]; then + echo "please checkout sources via CVS" + exit 1 +fi + +#build binary +cc -o $TMPBIN $RDROOTDIR/elf32.c $RDROOTDIR/elf64.c $RDROOTDIR/elfrdsetroot.c +if [ ! -e $TMPBIN ]; then + echo "failed to build rdsetroot under /tmp" + exit 1 +fi + +#extract ramdisk +$TMPBIN -x $1 $TMPRD + +#mount it +vnconfig vnd0 $TMPRD +mount /dev/vnd0a /mnt + +#copy the autofile +cp $2 /mnt/ + +# umount ramdisk +umount /dev/vnd0a +vnconfig -u vnd0 + +# put modified ramdisk in bsd.rd +$TMPBIN $1 $TMPRD + +# cleanup +rm $TMPBIN $TMPRD