summaryrefslogtreecommitdiff
Side-by-side diff
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 @@
-#!/bin/bash
-
-SN="`basename $0`" # base portion of our filename
-AE="-a" # switch to add an entry
-RE="-r" # swithc to remove an entry
-EL="/tmp/resolv.conf" # expected location of the system nameserver config file
-ARGS="$@" # friendly variable name for all args
-
-usage(){
- echo "usage:
-$SN -a {ip} [{ip}...]
-$SN -r {ip} [{ip}...]"
-}
-
-#if are there at least two arguments?
-if [ "$#" -gt 1 ]
-then
-
- #remove any old resolv.conf file
- rm .resolve.conf .resolve.old .resolve.new 2> /dev/null
-
- #cast current nameserver file into OLD
- cat "$EL" > .resolve.old
-
- #build IP list
- for ARG in $ARGS
- do
- if [ "$ARG" != "$1" ]
- then
- IP_LIST=`echo "$IP_LIST $ARG"`
- fi
- done
-
- #select case on first switch
- case "$1" in
-
- #case '-a'
- "$AE" )
-
- #for each IP in IP_LIST
- for IP in $IP_LIST
- do
- #add nameserver entery to .newfile
- echo "nameserver $IP" >> .resolve.conf
-
- #cat OLD into grep excluding IP lines,
- #storing results into NEW
- cat .resolve.old | grep -v "$IP" > .resolve.new
-
- #set OLD to NEW
- cat .resolve.new > .resolve.old
-
- done
-
- #cat OLD onto end of .newfile
- cat .resolve.new >> .resolve.conf
-
- #clean up work files
- rm .resolve.new .resolve.old
-
- #move old conf file to old conf file.bak
- mv "$EL" "$EL.bak"
-
- #move .newfile to resolve.conf file
- mv .resolve.conf "$EL"
-
- echo "Added $IP_LIST to $EL"
- ;;
-
- #case '-r'
- "$RE" )
-
- #for each IP in IP_LIST
- for IP in $IP_LIST
- do
- #cat OLD into grep excluding IP lines,
- #storing results into NEW
- cat .resolve.old | grep -v "$IP" > .resolve.new
-
- #set OLD to NEW
- cat .resolve.new > .resolve.old
-
- done
-
- #move old conf file to old conf file.bak
- mv "$EL" "$EL.bak"
-
- #move .newfile to resolve.conf file
- mv .resolve.new "$EL"
-
- echo "Removed $IP_LIST from $EL"
-
- ;;
-
- #case else
- * )
-
- usage
- ;;
-
-
- #end switch
- esac
-
-#else
-else
-
- usage
-
-#end
-fi
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,3 +1,3 @@
-Files: 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
+Files: 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
Priority: optional
Section: opie/settings
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,3 +1,3 @@
-Files: 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
+Files: 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
Priority: optional
Section: opie/settings
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,3 +1,3 @@
-Files: 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
+Files: 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
Priority: optional
Section: opie/settings
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 @@
+#!/bin/sh
+
+arg0="`basename $0`" # base portion of our filename
+arg1="$1"
+tmpfile="/tmp/resolv.conf.$$"
+
+usage ( ) {
+ echo "usage: $arg0 -a|-r {ip} [{ip}...]"
+ rm -f $tmpfile
+ exit 1
+}
+
+
+[ "$#" -le 1 ] && usage
+
+shift
+
+cp /etc/resolv.conf $tmpfile
+
+case "$arg1" in
+ "-a")
+ for ip in "$@"; do
+ echo $ip
+ grep -sq "^nameserver $ip\$" $tmpfile || echo "nameserver $ip" >>$tmpfile
+ done
+ ;;
+ "-r")
+ for ip in "$@"; do
+ grep -v "^nameserver $ip\$" $tmpfile >$tmpfile.2
+ mv $tmpfile.2 $tmpfile
+ done
+ ;;
+ *)
+ usage
+ ;;
+esac
+
+[ -f $tmpfile ] && cp $tmpfile /etc/resolv.conf
+rm -f $tmpfile
+
+exit 0
+