freebsd-dev/release/picobsd/mfs_tree/stand/update
Luigi Rizzo 9db97a0145 Unbreak "update" script, by doing a mkdir -p of the relevant
directories when writing to disk.

Use the (yet to be committed) sysctl variable kern.bootdevname
to derive the device name, fallback to /dev/fd0 if kern.bootdevname
is unset or not available.
2002-03-08 12:14:46 +00:00

51 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
# $FreeBSD$
# script to edit and save some config file(s).
# If called with no arguments, it edits 3 files in /etc
thefiles=$*
[ -z "$thefiles" ] && \
thefiles="/etc/rc.conf /etc/rc.firewall /etc/master.passwd"
dev=`sysctl -n kern.bootdevname`
[ -z ${dev} ] && dev="/dev/fd0"
mount ${dev} /mnt
if [ "$?" != "0" ] ; then
echo ""
echo "Cannot mount ${dev} read-write!"
exit 1
fi
echo "Updating ${thefiles} on ${dev}: "
for f in ${thefiles} ; do
case $f in
/etc )
echo "Update all files in $f :"
srcs=`ls $f`
for i in $srcs ; do
if [ -f /mnt${f}/${i}.gz ]; then
echo -n "$i ..."
gzip < $f/$i > /mnt${f}/${i}.gz
fi
done
echo " Done."
;;
passwd|master.passwd)
mkdir -p /mnt/etc
ee /etc/master.passwd
pwd_mkdb /etc/master.passwd
gzip < /etc/master.passwd > /mnt/etc/master.passwd.gz
;;
/*) # only absolute pathnames are ok
mkdir -p /mnt/etc /mnt/root
[ -f $f ] && ee $f && gzip < $f > /mnt${f}.gz
;;
*)
echo "File $f not recognised, you must use an absolute pathname."
;;
esac
done
umount /mnt