1999-10-05 15:22:43 +04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Setup a new config directory
|
|
|
|
#
|
|
|
|
if [ $# -lt 1 ] ; then
|
|
|
|
echo "Usage: $0 <newconfig> [<baseconfig>]"
|
|
|
|
echo "Usage: $0 init"
|
2003-01-06 03:31:49 +03:00
|
|
|
echo "Usage: $0 revert"
|
1999-10-05 15:22:43 +04:00
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
dir=$1
|
|
|
|
|
2000-08-22 16:06:46 +04:00
|
|
|
FILES="defaultdomain fstab ifconfig.* inetd.conf mrouted.conf \
|
2001-06-18 04:01:51 +04:00
|
|
|
mygate myname netstart nsswitch.conf ntp.conf \
|
2000-08-22 16:06:46 +04:00
|
|
|
rc.conf rc.conf.d resolv.conf"
|
|
|
|
|
1999-10-05 15:22:43 +04:00
|
|
|
if [ $dir = init ] ; then
|
2001-11-18 06:50:53 +03:00
|
|
|
if [ -d /etc/etc.network -o -e /etc/etc.current ] ; then
|
1999-10-05 15:22:43 +04:00
|
|
|
echo "Error: multi-configuration already initialized"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
dir=etc.network
|
|
|
|
cd /etc
|
|
|
|
mkdir -m 755 $dir
|
|
|
|
ln -s $dir etc.current
|
|
|
|
ln -s $dir etc.default
|
2000-08-22 16:06:46 +04:00
|
|
|
for i in ${FILES}; do
|
2003-01-06 02:32:54 +03:00
|
|
|
if [ -f $i -o -d $i ] ; then
|
1999-10-05 15:22:43 +04:00
|
|
|
mv $i $dir
|
|
|
|
ln -s etc.current/$i .
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
echo "/etc/$dir has now been created and populated."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2003-01-06 03:31:49 +03:00
|
|
|
if [ $dir = revert ] ; then
|
|
|
|
if [ ! -d /etc/etc.current ] ; then
|
|
|
|
echo "Error: multi-configuration not initialized"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
cd /etc
|
|
|
|
for i in ${FILES}; do
|
|
|
|
if [ -f $i -o -d $i ] ; then
|
|
|
|
stat="`ls -ld $i`"
|
|
|
|
case x"$stat" in
|
|
|
|
xl*) :;;
|
|
|
|
x*)
|
|
|
|
echo "$i: not a symlink, skipping"
|
|
|
|
continue ;;
|
|
|
|
esac
|
|
|
|
linkto="${stat##*-> }"
|
|
|
|
case x"$linkto" in
|
|
|
|
xetc.current/*) :;;
|
|
|
|
x*)
|
|
|
|
echo "$i: does not symlink to etc.current, skipping"
|
|
|
|
continue ;;
|
|
|
|
esac
|
|
|
|
if [ -f $i ] ; then
|
|
|
|
rm $i
|
|
|
|
cp -p $linkto $i
|
|
|
|
else
|
|
|
|
rm $i
|
|
|
|
( cd etc.current && pax -rw -pe $i /etc )
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
rm etc.current
|
|
|
|
rm etc.default
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
1999-10-05 15:22:43 +04:00
|
|
|
if [ "`expr $dir : 'etc\.\(.*\)'`" != $dir ] ; then
|
|
|
|
dir=etc.$dir
|
|
|
|
fi
|
|
|
|
if [ -e /etc/$dir ] ; then
|
|
|
|
echo "Error: $dir already exists"
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
newname=`expr $dir : 'etc.\(.*\)'`
|
|
|
|
if [ $# -lt 2 ] ; then
|
|
|
|
orig=etc.current
|
|
|
|
echo "Using current config as base for $newname"
|
|
|
|
else
|
|
|
|
orig=$2
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "`expr $orig : 'etc.\(.*\)'`" ] ; then
|
|
|
|
orig=etc.$orig
|
|
|
|
fi
|
|
|
|
|
1999-10-11 16:45:43 +04:00
|
|
|
if [ ! -d /etc/$orig ] ; then
|
|
|
|
echo "Original directory /etc/$orig does not exist."
|
|
|
|
exit 1;
|
|
|
|
fi
|
1999-10-05 15:22:43 +04:00
|
|
|
mkdir -m 755 /etc/$dir
|
2003-01-06 02:32:54 +03:00
|
|
|
cd /etc/$orig
|
|
|
|
pax -rw -pe . /etc/$dir
|
1999-10-05 15:22:43 +04:00
|
|
|
echo "/etc/$dir has now been created and populated."
|
|
|
|
exit 0
|