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.
This commit is contained in:
parent
1de04d6919
commit
9db97a0145
@ -1,39 +1,50 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# $FreeBSD$
|
# $FreeBSD$
|
||||||
# script to edit and save some config file(s)
|
# script to edit and save some config file(s).
|
||||||
|
# If called with no arguments, it edits 3 files in /etc
|
||||||
thefiles=$*
|
thefiles=$*
|
||||||
pwd=`pwd`
|
[ -z "$thefiles" ] && \
|
||||||
dev="/dev/fd0c"
|
thefiles="/etc/rc.conf /etc/rc.firewall /etc/master.passwd"
|
||||||
echo "Updating content on ${dev}: "
|
dev=`sysctl -n kern.bootdevname`
|
||||||
|
[ -z ${dev} ] && dev="/dev/fd0"
|
||||||
mount ${dev} /mnt
|
mount ${dev} /mnt
|
||||||
if [ "X$?" != "X0" ] ; then
|
if [ "$?" != "0" ] ; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "Cannot mount ${dev} read-write!"
|
echo "Cannot mount ${dev} read-write!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [ "$thefiles" = "" ] ; then
|
|
||||||
srcs=`ls /etc`
|
echo "Updating ${thefiles} on ${dev}: "
|
||||||
for i in $srcs ; do
|
|
||||||
if [ -f /mnt/etc/$i.gz ] ; then
|
for f in ${thefiles} ; do
|
||||||
echo -n "$i ..."
|
case $f in
|
||||||
gzip < /etc/$i > /mnt/etc/$i.gz
|
/etc )
|
||||||
fi
|
echo "Update all files in $f :"
|
||||||
done
|
srcs=`ls $f`
|
||||||
elif [ "$thefiles" = "passwd" ] ; then
|
for i in $srcs ; do
|
||||||
ee /etc/master.passwd
|
if [ -f /mnt${f}/${i}.gz ]; then
|
||||||
pwd_mkdb master.passwd
|
echo -n "$i ..."
|
||||||
gzip < /etc/master.passwd /mnt/etc/master.passwd.gz
|
gzip < $f/$i > /mnt${f}/${i}.gz
|
||||||
else
|
fi
|
||||||
for i in $thefiles; do
|
done
|
||||||
if [ -f $i ] ; then
|
echo " Done."
|
||||||
ee $i
|
;;
|
||||||
gzip < $i > /mnt/$i.gz
|
|
||||||
fi
|
passwd|master.passwd)
|
||||||
done
|
mkdir -p /mnt/etc
|
||||||
fi
|
ee /etc/master.passwd
|
||||||
echo " Done."
|
pwd_mkdb /etc/master.passwd
|
||||||
echo -n "Updating kernel parameters... "
|
gzip < /etc/master.passwd > /mnt/etc/master.passwd.gz
|
||||||
kget /mnt/boot/kernel.conf
|
;;
|
||||||
|
|
||||||
|
/*) # 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
|
umount /mnt
|
||||||
cd ${pwd}
|
|
||||||
echo " Done."
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user