diff options
author | Judd Vinet <judd@archlinux.org> | 2005-06-30 23:57:54 +0000 |
---|---|---|
committer | Judd Vinet <judd@archlinux.org> | 2005-06-30 23:57:54 +0000 |
commit | 863e8311cfc2ec7dc98fdb43abaa8499dd3414a4 (patch) | |
tree | d60ee22af2dd5ab6b2618af6bc172ecc0c0f56c7 /network | |
parent | 47ca58301f0bf0680baf59465202c4209b1ac112 (diff) |
added new netcfg stuff for roaming network profiles
Diffstat (limited to 'network')
-rwxr-xr-x | network | 130 |
1 files changed, 90 insertions, 40 deletions
@@ -3,13 +3,13 @@ . /etc/rc.conf . /etc/rc.d/functions -# look for wireless settings +# wireless settings [ -f /etc/conf.d/wireless ] && . /etc/conf.d/wireless - -# look for ethernet bonding settings +# ethernet bonding settings [ -f /etc/conf.d/bonding ] && . /etc/conf.d/bonding - -# look for dhcpcd settings +# bridge settings +[ -f /etc/conf.d/bridges ] && . /etc/conf.d/bridges +# dhcpcd settings [ -f /etc/conf.d/dhcpcd ] && . /etc/conf.d/dhcpcd # Special wrapper for hotplug ifup calls @@ -31,22 +31,18 @@ ifup() echo "usage: $0 ifup <interface_name>" return 1 fi - for wif in ${WLAN_INTERFACES[@]}; do - if [ "$wif" = "${1}" ]; then - wvarname="\$wlan_${1}" - eval wif_line=$wvarname - /usr/sbin/iwconfig $wif_line - /bin/sleep 2 - fi - done - varname="\$${1}" - eval new_ifline=$varname - if [ "$new_ifline" = "dhcp" ]; then + eval iwcfg="\$wlan_${1}" + if [ "$iwcfg" != "" ]; then + /usr/sbin/iwconfig $iwcfg + /bin/sleep 2 + fi + eval ifcfg="\$${1}" + if [ "$ifcfg" = "dhcp" ]; then # remove the .pid file if it exists rm -f /etc/dhcpc/dhcpcd-${1}.{pid,cache} >/dev/null 2>&1 - /usr/sbin/dhcpcd $DHCPCD_ARGS $1 + /usr/sbin/dhcpcd $DHCPCD_ARGS ${1} else - /sbin/ifconfig $new_ifline + /sbin/ifconfig $ifcfg fi return $? } @@ -57,17 +53,16 @@ ifdown() echo "usage: $0 ifdown <interface_name>" return 1 fi - varname="\$${1}" - eval new_ifline=$varname - if [ "$new_ifline" = "dhcp" ]; then + eval ifcfg="\$${1}" + if [ "$ifcfg" = "dhcp" ]; then if [ -f /etc/dhcpc/dhcpcd-${1}.pid ]; then /bin/kill `cat /etc/dhcpc/dhcpcd-${1}.pid` else # No .pid file, just bring the interface itself down - /sbin/ifconfig $1 down + /sbin/ifconfig ${1} down fi else - /sbin/ifconfig $new_ifline down + /sbin/ifconfig $ifcfg down fi return $? } @@ -91,9 +86,8 @@ rtup() echo "usage: $0 rtup <route_name>" return 1 fi - varname="\$${1}" - eval new_rtline=$varname - /sbin/route add $new_rtline + eval routecfg="\$${1}" + /sbin/route add $routecfg return $? } @@ -103,9 +97,8 @@ rtdown() echo "usage: $0 rtdown <route_name>" return 1 fi - varname="\$${1}" - eval new_rtline=$varname - /sbin/route del $new_rtline + eval routecfg="\$${1}" + /sbin/route del $routecfg return $? } @@ -122,28 +115,79 @@ rtlist() done } +bond_up() +{ + for ifline in ${BOND_INTERFACES[@]}; do + if [ "$ifline" = "${ifline#!}" ]; then + eval bondcfg="\$bond_${ifline}" + /sbin/ifenslave $ifline $bondcfg || error=1 + fi + done +} + +bridge_up() +{ + for br in ${BRIDGE_INTERFACES[@]}; do + if [ "$br" = "${br#!}" ]; then + # if the bridge already exists, remove it + if [ "`/sbin/ifconfig $br 2>/dev/null`" ]; then + /sbin/ifconfig $br down + /usr/sbin/brctl delbr $br + fi + /usr/sbin/brctl addbr $br + eval brifs="\$bridge_${br}" + for brif in $brifs; do + if [ "$brif" = "${brif#!}" ]; then + /usr/sbin/brctl addif $br $brif || error=1 + fi + done + fi + done +} + +bridge_down() +{ + for br in ${BRIDGE_INTERFACES[@]}; do + if [ "$br" = "${br#!}" ]; then + /usr/sbin/brctl delbr $br + fi + done +} + + case "$1" in start) if ! ck_daemon network; then echo "Network is already running. Try 'network restart'" exit fi + + # See if we're using network profiles + if [ "$NET" ]; then + # This env var is passed from the kernel boot line + /usr/bin/netcfg $NET + elif [ "$NET_PROFILES" ]; then + if [ "$NET_PROFILES" = "menu" ]; then + /usr/bin/netcfg --menu --timeout 5 + else + for prof in ${NET_PROFILES[@]}; do + /usr/bin/netcfg $prof + done + fi + fi + stat_busy "Starting Network" error=0 - # bring up interfaces + # bring up bridge interfaces + bridge_up + # bring up ethernet interfaces for ifline in ${INTERFACES[@]}; do if echo $ifline | grep '^[^\!]' >/dev/null 2>&1; then ifup $ifline || error=1 fi done # bring up bond interfaces - for ifline in ${BOND_INTERFACES[@]}; do - if echo $ifline | grep '^[^\!]' 2>&1 >/dev/null; then - bvarname="\$bond_${ifline}" - eval bif_line=$bvarname - /sbin/ifenslave $ifline $bif_line || error=1 - fi - done + bond_up # bring up routes for rtline in "${ROUTES[@]}"; do if echo $rtline | grep '^[^\!]' 2>&1 >/dev/null; then @@ -158,10 +202,14 @@ case "$1" in fi ;; stop) - if ck_daemon network; then - echo "Network is not running. Try 'network start'" - exit + #if ck_daemon network; then + # echo "Network is not running. Try 'network start'" + # exit + #fi + if [ "$NET_PROFILES" ]; then + /usr/bin/netcfg --stopall fi + stat_busy "Stopping Network" rm_daemon network error=0 @@ -175,6 +223,8 @@ case "$1" in ifdown $ifline || error=1 fi done + # bring down bridge interfaces + bridge_down if [ $error -eq 0 ]; then stat_done else |