mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-01 17:12:46 +00:00
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
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=91866
@ -1,39 +1,50 @@
|
||||
#!/bin/sh
|
||||
# $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=$*
|
||||
pwd=`pwd`
|
||||
dev="/dev/fd0c"
|
||||
echo "Updating content on ${dev}: "
|
||||
[ -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 [ "X$?" != "X0" ] ; then
|
||||
if [ "$?" != "0" ] ; then
|
||||
echo ""
|
||||
echo "Cannot mount ${dev} read-write!"
|
||||
exit 1
|
||||
fi
|
||||
if [ "$thefiles" = "" ] ; then
|
||||
srcs=`ls /etc`
|
||||
for i in $srcs ; do
|
||||
if [ -f /mnt/etc/$i.gz ] ; then
|
||||
echo -n "$i ..."
|
||||
gzip < /etc/$i > /mnt/etc/$i.gz
|
||||
fi
|
||||
done
|
||||
elif [ "$thefiles" = "passwd" ] ; then
|
||||
ee /etc/master.passwd
|
||||
pwd_mkdb master.passwd
|
||||
gzip < /etc/master.passwd /mnt/etc/master.passwd.gz
|
||||
else
|
||||
for i in $thefiles; do
|
||||
if [ -f $i ] ; then
|
||||
ee $i
|
||||
gzip < $i > /mnt/$i.gz
|
||||
fi
|
||||
done
|
||||
fi
|
||||
echo " Done."
|
||||
echo -n "Updating kernel parameters... "
|
||||
kget /mnt/boot/kernel.conf
|
||||
|
||||
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
|
||||
cd ${pwd}
|
||||
echo " Done."
|
||||
|
Loading…
Reference in New Issue
Block a user