summaryrefslogtreecommitdiff
path: root/network
diff options
context:
space:
mode:
authorJudd Vinet <judd@archlinux.org>2004-07-03 19:40:02 +0000
committerJudd Vinet <judd@archlinux.org>2004-07-03 19:40:02 +0000
commit2c20f4d5637da88e983b65db9c97373aa79d8a37 (patch)
tree030f97c8daf6c7cba5c1b2f62820b21171e5cd49 /network
parentcd0e2c63acc50d080edba54b797f7f1c58da1312 (diff)
added iflist and rtlist functions and made ifup,ifdown,rtup,rtdown accessible from outside the script
Diffstat (limited to 'network')
-rwxr-xr-xnetwork46
1 files changed, 46 insertions, 0 deletions
diff --git a/network b/network
index dd834f7..69a1bdb 100755
--- a/network
+++ b/network
@@ -5,6 +5,10 @@
ifup()
{
+ if [ "$1" = "" ]; then
+ echo "usage: $0 ifup <interface_name>"
+ return 1
+ fi
varname="\$${1}"
eval new_ifline=$varname
if [ "$new_ifline" = "dhcp" ]; then
@@ -19,6 +23,10 @@ ifup()
ifdown()
{
+ if [ "$1" = "" ]; then
+ echo "usage: $0 ifdown <interface_name>"
+ return 1
+ fi
varname="\$${1}"
eval new_ifline=$varname
if [ "$new_ifline" = "dhcp" ]; then
@@ -30,8 +38,25 @@ ifdown()
return $?
}
+iflist()
+{
+ for ifline in ${INTERFACES[@]}; do
+ if echo $ifline | grep '^[^\!]' >/dev/null 2>&1; then
+ echo -en " $ifline:\t"
+ else
+ echo -en "$ifline:\t"
+ fi
+ eval real_ifline=\$${ifline#!}
+ echo $real_ifline
+ done
+}
+
rtup()
{
+ if [ "$1" = "" ]; then
+ echo "usage: $0 rtup <route_name>"
+ return 1
+ fi
varname="\$${1}"
eval new_rtline=$varname
/sbin/route add $new_rtline
@@ -40,12 +65,29 @@ rtup()
rtdown()
{
+ if [ "$1" = "" ]; then
+ echo "usage: $0 rtdown <route_name>"
+ return 1
+ fi
varname="\$${1}"
eval new_rtline=$varname
/sbin/route del $new_rtline
return $?
}
+rtlist()
+{
+ for rtline in ${ROUTES[@]}; do
+ if echo $rtline | grep '^[^\!]' >/dev/null 2>&1; then
+ echo -en " $rtline:\t"
+ else
+ echo -en "$rtline:\t"
+ fi
+ eval real_rtline=\$${rtline#!}
+ echo $real_rtline
+ done
+}
+
case "$1" in
start)
if ! ck_daemon network; then
@@ -100,6 +142,10 @@ case "$1" in
sleep 2
$0 start
;;
+ ifup|ifdown|iflist|rtup|rtdown|rtlist)
+ $1 $2
+ ;;
*)
echo "usage: $0 {start|stop|restart}"
+ echo " $0 {ifup|ifdown|iflist|rtup|rtdown|rtlist}"
esac