-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathnewbtconf.sh
More file actions
100 lines (94 loc) · 1.93 KB
/
newbtconf.sh
File metadata and controls
100 lines (94 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/sh
#
# Setup a new config directory
#
if [ $# -lt 1 ] ; then
echo "Usage: $0 <newconfig> [<baseconfig>]"
echo "Usage: $0 init"
echo "Usage: $0 revert"
exit 1;
fi
dir=$1
FILES="defaultdomain fstab ifconfig.* inetd.conf mrouted.conf \
mygate myname netstart nsswitch.conf ntp.conf \
rc.conf rc.conf.d resolv.conf"
if [ $dir = init ] ; then
if [ -d /etc/etc.network -o -e /etc/etc.current ] ; then
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
for i in ${FILES}; do
if [ -f $i -o -d $i ] ; then
mv $i $dir
ln -s etc.current/$i .
fi
done
echo "/etc/$dir has now been created and populated."
exit 0
fi
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
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
if [ ! -d /etc/$orig ] ; then
echo "Original directory /etc/$orig does not exist."
exit 1;
fi
mkdir -m 755 /etc/$dir
cd /etc/$orig
pax -rw -pe . /etc/$dir
echo "/etc/$dir has now been created and populated."
exit 0