summaryrefslogtreecommitdiff
authorsandman <sandman>2002-12-15 22:04:09 (UTC)
committer sandman <sandman>2002-12-15 22:04:09 (UTC)
commita6a23d1c30e395add577eec261ae728f8d783299 (patch) (unidiff)
treee216789ee24be045fb3f6ffb4dc55ca0b25c8195
parent6de66e1e2af2b3b06e53dd83338b9dc9df6190df (diff)
downloadopie-a6a23d1c30e395add577eec261ae728f8d783299.zip
opie-a6a23d1c30e395add577eec261ae728f8d783299.tar.gz
opie-a6a23d1c30e395add577eec261ae728f8d783299.tar.bz2
moved changedns to /usr/bin (so ifup/down actually find it), and rewrote it
(runs with busybox now and doesn't write to temporary files in the current directory, which could be anywhere)
Diffstat (more/less context) (ignore whitespace changes)
-rwxr-xr-xbin/changedns111
-rw-r--r--noncore/net/networksetup/opie-networksetup.control2
-rw-r--r--noncore/settings/networksettings/opie-networksettings.control2
-rw-r--r--noncore/settings/networksettings/opie-networksetup.control2
-rwxr-xr-xroot/usr/bin/changedns42
5 files changed, 45 insertions, 114 deletions
diff --git a/bin/changedns b/bin/changedns
deleted file mode 100755
index 4760a67..0000000
--- a/bin/changedns
+++ b/dev/null
@@ -1,111 +0,0 @@
1#!/bin/bash
2
3 SN="`basename $0`"# base portion of our filename
4 AE="-a" # switch to add an entry
5 RE="-r" # swithc to remove an entry
6 EL="/tmp/resolv.conf"# expected location of the system nameserver config file
7 ARGS="$@" # friendly variable name for all args
8
9usage(){
10 echo "usage:
11$SN -a {ip} [{ip}...]
12$SN -r {ip} [{ip}...]"
13}
14
15#if are there at least two arguments?
16if [ "$#" -gt 1 ]
17then
18
19 #remove any old resolv.conf file
20 rm .resolve.conf .resolve.old .resolve.new 2> /dev/null
21
22 #cast current nameserver file into OLD
23 cat "$EL" > .resolve.old
24
25 #build IP list
26 for ARG in $ARGS
27 do
28 if [ "$ARG" != "$1" ]
29 then
30 IP_LIST=`echo "$IP_LIST $ARG"`
31 fi
32 done
33
34 #select case on first switch
35 case "$1" in
36
37 #case '-a'
38 "$AE")
39
40 #for each IP in IP_LIST
41 for IP in $IP_LIST
42 do
43 #add nameserver entery to .newfile
44 echo "nameserver $IP" >> .resolve.conf
45
46 #cat OLD into grep excluding IP lines,
47 #storing results into NEW
48 cat .resolve.old | grep -v "$IP" > .resolve.new
49
50 #set OLD to NEW
51 cat .resolve.new > .resolve.old
52
53 done
54
55 #cat OLD onto end of .newfile
56 cat .resolve.new >> .resolve.conf
57
58 #clean up work files
59 rm .resolve.new .resolve.old
60
61 #move old conf file to old conf file.bak
62 mv "$EL" "$EL.bak"
63
64 #move .newfile to resolve.conf file
65 mv .resolve.conf "$EL"
66
67 echo "Added $IP_LIST to $EL"
68 ;;
69
70 #case '-r'
71 "$RE")
72
73 #for each IP in IP_LIST
74 for IP in $IP_LIST
75 do
76 #cat OLD into grep excluding IP lines,
77 #storing results into NEW
78 cat .resolve.old | grep -v "$IP" > .resolve.new
79
80 #set OLD to NEW
81 cat .resolve.new > .resolve.old
82
83 done
84
85 #move old conf file to old conf file.bak
86 mv "$EL" "$EL.bak"
87
88 #move .newfile to resolve.conf file
89 mv .resolve.new "$EL"
90
91 echo "Removed $IP_LIST from $EL"
92
93 ;;
94
95 #case else
96 *)
97
98 usage
99 ;;
100
101
102 #end switch
103 esac
104
105#else
106else
107
108 usage
109
110#end
111fi
diff --git a/noncore/net/networksetup/opie-networksetup.control b/noncore/net/networksetup/opie-networksetup.control
index 425150b..3d6a32c 100644
--- a/noncore/net/networksetup/opie-networksetup.control
+++ b/noncore/net/networksetup/opie-networksetup.control
@@ -1,8 +1,8 @@
1Files: bin/networksetup apps/Settings/networksetup.desktop plugins/networksetup/* pics/networksetup/* pics/Network/PPPConnect.png $QTDIR/lib/libinterfaces.so.1.0.0 $QTDIR/lib/libinterfaces.so.1.0 $QTDIR/lib/libinterfaces.so.1 bin/changedns bin/getprofile 1Files: bin/networksetup apps/Settings/networksetup.desktop plugins/networksetup/* pics/networksetup/* pics/Network/PPPConnect.png $QTDIR/lib/libinterfaces.so.1.0.0 $QTDIR/lib/libinterfaces.so.1.0 $QTDIR/lib/libinterfaces.so.1 root/usr/bin/changedns bin/getprofile
2Priority: optional 2Priority: optional
3Section: opie/settings 3Section: opie/settings
4Maintainer: Ben Meyer <meyerb@sharpsec.com> 4Maintainer: Ben Meyer <meyerb@sharpsec.com>
5Architecture: arm 5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION 6Version: $QPE_VERSION-$SUB_VERSION
7Depends: opie-base ($QPE_VERSION) 7Depends: opie-base ($QPE_VERSION)
8Description: Opie network setup tool 8Description: Opie network setup tool
diff --git a/noncore/settings/networksettings/opie-networksettings.control b/noncore/settings/networksettings/opie-networksettings.control
index 425150b..3d6a32c 100644
--- a/noncore/settings/networksettings/opie-networksettings.control
+++ b/noncore/settings/networksettings/opie-networksettings.control
@@ -1,8 +1,8 @@
1Files: bin/networksetup apps/Settings/networksetup.desktop plugins/networksetup/* pics/networksetup/* pics/Network/PPPConnect.png $QTDIR/lib/libinterfaces.so.1.0.0 $QTDIR/lib/libinterfaces.so.1.0 $QTDIR/lib/libinterfaces.so.1 bin/changedns bin/getprofile 1Files: bin/networksetup apps/Settings/networksetup.desktop plugins/networksetup/* pics/networksetup/* pics/Network/PPPConnect.png $QTDIR/lib/libinterfaces.so.1.0.0 $QTDIR/lib/libinterfaces.so.1.0 $QTDIR/lib/libinterfaces.so.1 root/usr/bin/changedns bin/getprofile
2Priority: optional 2Priority: optional
3Section: opie/settings 3Section: opie/settings
4Maintainer: Ben Meyer <meyerb@sharpsec.com> 4Maintainer: Ben Meyer <meyerb@sharpsec.com>
5Architecture: arm 5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION 6Version: $QPE_VERSION-$SUB_VERSION
7Depends: opie-base ($QPE_VERSION) 7Depends: opie-base ($QPE_VERSION)
8Description: Opie network setup tool 8Description: Opie network setup tool
diff --git a/noncore/settings/networksettings/opie-networksetup.control b/noncore/settings/networksettings/opie-networksetup.control
index 425150b..3d6a32c 100644
--- a/noncore/settings/networksettings/opie-networksetup.control
+++ b/noncore/settings/networksettings/opie-networksetup.control
@@ -1,8 +1,8 @@
1Files: bin/networksetup apps/Settings/networksetup.desktop plugins/networksetup/* pics/networksetup/* pics/Network/PPPConnect.png $QTDIR/lib/libinterfaces.so.1.0.0 $QTDIR/lib/libinterfaces.so.1.0 $QTDIR/lib/libinterfaces.so.1 bin/changedns bin/getprofile 1Files: bin/networksetup apps/Settings/networksetup.desktop plugins/networksetup/* pics/networksetup/* pics/Network/PPPConnect.png $QTDIR/lib/libinterfaces.so.1.0.0 $QTDIR/lib/libinterfaces.so.1.0 $QTDIR/lib/libinterfaces.so.1 root/usr/bin/changedns bin/getprofile
2Priority: optional 2Priority: optional
3Section: opie/settings 3Section: opie/settings
4Maintainer: Ben Meyer <meyerb@sharpsec.com> 4Maintainer: Ben Meyer <meyerb@sharpsec.com>
5Architecture: arm 5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION 6Version: $QPE_VERSION-$SUB_VERSION
7Depends: opie-base ($QPE_VERSION) 7Depends: opie-base ($QPE_VERSION)
8Description: Opie network setup tool 8Description: Opie network setup tool
diff --git a/root/usr/bin/changedns b/root/usr/bin/changedns
new file mode 100755
index 0000000..8270e86
--- a/dev/null
+++ b/root/usr/bin/changedns
@@ -0,0 +1,42 @@
1#!/bin/sh
2
3 arg0="`basename $0`"# base portion of our filename
4arg1="$1"
5tmpfile="/tmp/resolv.conf.$$"
6
7usage ( ) {
8 echo "usage: $arg0 -a|-r {ip} [{ip}...]"
9 rm -f $tmpfile
10 exit 1
11}
12
13
14[ "$#" -le 1 ] && usage
15
16shift
17
18cp /etc/resolv.conf $tmpfile
19
20case "$arg1" in
21 "-a")
22 for ip in "$@"; do
23 echo $ip
24 grep -sq "^nameserver $ip\$" $tmpfile || echo "nameserver $ip" >>$tmpfile
25 done
26 ;;
27 "-r")
28 for ip in "$@"; do
29 grep -v "^nameserver $ip\$" $tmpfile >$tmpfile.2
30 mv $tmpfile.2 $tmpfile
31 done
32 ;;
33 *)
34 usage
35 ;;
36esac
37
38[ -f $tmpfile ] && cp $tmpfile /etc/resolv.conf
39rm -f $tmpfile
40
41exit 0
42