1#!/bin/sh 2# $FreeBSD$ 3# script to edit and save some config file(s). 4# If called with no arguments, it edits 3 files in /etc 5thefiles=$* 6[ -z "$thefiles" ] && \ 7 thefiles="/etc/rc.conf /etc/rc.firewall /etc/master.passwd" 8dev=`sysctl -n machdep.guessed_bootdev` 9[ -c "${dev}" ] || dev="/dev/fd0" 10mount ${dev} /mnt 11if [ "$?" != "0" ] ; then 12 echo "" 13 echo "Cannot mount ${dev} read-write!" 14 exit 1 15fi 16 17echo "Updating ${thefiles} on ${dev}: " 18 19for f in ${thefiles} ; do 20 case $f in 21 /etc ) 22 echo "Update all files in $f :" 23 srcs=`ls $f` 24 for i in $srcs ; do 25 if [ -f /mnt${f}/${i}.gz ]; then 26 echo -n "$i ..." 27 gzip < $f/$i > /mnt${f}/${i}.gz 28 fi 29 done 30 echo " Done." 31 ;; 32 33 passwd|master.passwd) 34 mkdir -p /mnt/etc 35 ee /etc/master.passwd 36 pwd_mkdb /etc/master.passwd 37 gzip < /etc/master.passwd > /mnt/etc/master.passwd.gz 38 ;; 39 40 /*) # only absolute pathnames are ok 41 mkdir -p /mnt/etc /mnt/root 42 [ -f $f ] && ee $f && gzip < $f > /mnt${f}.gz 43 ;; 44 45 *) 46 echo "File $f not recognised, you must use an absolute pathname." 47 ;; 48 esac 49done 50umount /mnt 51