kernel - Overhaul namecache operations to reduce SMP contention
[dragonfly.git] / sbin / newbtconf / newbtconf.sh
blobcbd78caab9137b3748444f518a0fb18681b6108a
1 #!/bin/sh
3 # $DragonFly: src/sbin/newbtconf/newbtconf.sh,v 1.3 2008/02/17 19:51:53 swildner Exp $
4 # Setup a new config directory
6 if [ $# -lt 1 ] ; then
7 echo "usage: $0 <newconfig> [<baseconfig>]"
8 echo "usage: $0 init"
9 echo "usage: $0 revert"
10 exit 1;
12 dir=$1
14 FILES="defaultdomain dntpd.conf fstab ifconfig.* inetd.conf mrouted.conf \
15 mygate myname netstart nsswitch.conf \
16 rc.conf rc.conf.d resolv.conf"
18 if [ $dir = init ] ; then
19 if [ -d /etc/etc.network -o -e /etc/etc.current ] ; then
20 echo "Error: multi-configuration already initialized"
21 exit 1
23 dir=etc.network
24 cd /etc
25 mkdir -m 755 $dir
26 ln -s $dir etc.current
27 ln -s $dir etc.default
28 for i in ${FILES}; do
29 if [ -f $i -o -d $i ] ; then
30 mv $i $dir
31 ln -s etc.current/$i .
33 done
34 echo "/etc/$dir has now been created and populated."
35 exit 0
38 if [ $dir = revert ] ; then
39 if [ ! -d /etc/etc.current ] ; then
40 echo "Error: multi-configuration not initialized"
41 exit 1
43 cd /etc
44 for i in ${FILES}; do
45 if [ -f $i -o -d $i ] ; then
46 stat="`ls -ld $i`"
47 case x"$stat" in
48 xl*) :;;
49 x*)
50 echo "$i: not a symlink, skipping"
51 continue ;;
52 esac
53 linkto="${stat##*-> }"
54 case x"$linkto" in
55 xetc.current/*) :;;
56 x*)
57 echo "$i: does not symlink to etc.current, skipping"
58 continue ;;
59 esac
60 if [ -f $i ] ; then
61 rm $i
62 cp -p $linkto $i
63 else
64 rm $i
65 ( cd etc.current && pax -rw -pe $i /etc )
68 done
69 rm etc.current
70 rm etc.default
71 exit 0
74 if [ "`expr $dir : 'etc\.\(.*\)'`" != $dir ] ; then
75 dir=etc.$dir
77 if [ -e /etc/$dir ] ; then
78 echo "Error: $dir already exists"
79 exit 1;
81 newname=`expr $dir : 'etc.\(.*\)'`
82 if [ $# -lt 2 ] ; then
83 orig=etc.current
84 echo "Using current config as base for $newname"
85 else
86 orig=$2
89 if [ -z "`expr $orig : 'etc.\(.*\)'`" ] ; then
90 orig=etc.$orig
93 if [ ! -d /etc/$orig ] ; then
94 echo "Original directory /etc/$orig does not exist."
95 exit 1;
97 mkdir -m 755 /etc/$dir
98 cd /etc/$orig
99 pax -rw -pe . /etc/$dir
100 echo "/etc/$dir has now been created and populated."
101 exit 0