ifup-br - załącznik

Radosław Kintzi radek w pop.e-wro.pl
Wto, 4 Lis 2003, 19:18:07 CET


On Tue, Nov 04, 2003 at 06:15:35PM +0100, Arkadiusz Miskiewicz wrote:
> On Tuesday 04 of November 2003 17:54, Radosław Kintzi wrote:
> > Lepszy załącznik - teraz działa, lecz pewnie da się to lepiej zakodować.
> Zrobić funkcję np. wireless_param() robiącą to wszystko, wrzucić ją do 
> functions.network, a następnie użyć jej zarówno w ifup jak i ifup-br.

Proszę bardzo

r
-- 
Radosław Kintzi
mailto:radzio w pld-linux.org
gg:2199600
-------------- następna część ---------
? ifup-br.diff
? ifup.new
Index: functions.network
===================================================================
RCS file: /cvsroot/rc-scripts/sysconfig/network-scripts/functions.network,v
retrieving revision 1.8
diff -a -u -r1.8 functions.network
--- functions.network	19 Jun 2003 15:57:07 -0000	1.8
+++ functions.network	4 Nov 2003 18:13:45 -0000
@@ -433,6 +433,76 @@
     return 1
 }
 
+wireless_param () {
+    
+    device=$1
+    if [ "$2" = "br" ]; then
+	prefix="${device}_"
+    else
+	prefix=
+    fi
+    
+    if [ -z "$(eval echo \$${prefix}WLAN_NICKNAME)" ]; then
+	 WLAN_NICKNAME="$(hostname -f)"
+    else	     
+	 WLAN_NICKANME="$(eval echo \$${prefix}WLAN_NICKNAME)"
+    fi
+    
+    # wlan mode needs to be first
+    [ -n "$(eval echo \$${prefix}WLAN_MODE)" ] && iwconfig ${device} \
+   	 mode "$(eval echo \$${prefix}WLAN_MODE)"
+    iwconfig ${device} nickname WLAN_NICKNAME
+    [ -n "$(eval echo \$${prefix}WLAN_ESSID)" ] && iwconfig ${device} \
+   	 essid "$(eval echo \$${prefix}WLAN_ESSID)"
+    [ -n "$(eval echo \$${prefix}WLAN_NWID)" ] && iwconfig ${device} \
+    	nwid "$(eval echo \$${prefix}WLAN_NWID)"
+    if [ -n "$(eval echo \$${prefix}WLAN_FREQ)" -a "$(eval echo \$${prefix}${WLAN_MODE})" != "Managed" ] ; then
+	iwconfig ${device} freq "$(eval echo \$${prefix}WLAN_FREQ)"
+    elif [ -n "$(eval echo \$${prefix}WLAN_CHANNEL)" -a "$(eval echo \$${prefix}${WLAN_MODE})" != "Managed" ]; then
+	iwconfig ${device} \
+	channel "$(eval echo \$${prefix}WLAN_CHANNEL)"
+    fi
+    [ -n "$(eval echo \$${prefix}WLAN_SENS)" ] && iwconfig ${device} \
+    	sens "$(eval echo \$${prefix}WLAN_SENS)"
+    [ -n "$(eval echo \$${prefix}WLAN_AP)" ] && iwconfig ${device} \
+    	ap "$(eval echo \$${prefix}WLAN_AP)"
+    [ -n "$(eval echo \$${prefix}WLAN_BITRATE)" ] && \
+    	iwconfig ${device} \
+    	rate "$(eval echo \$${prefix}WLAN_BITRATE)"
+    [ -n "$(eval echo \$${prefix}WLAN_RTS_THRESHOLD)" ] && \
+    	iwconfig ${device} \
+	rts "$(eval echo \$${prefix}WLAN_RTS_THRESHOLD)"
+    [ -n "$(eval echo \$${prefix}WLAN_FRAGMENTATION_THRESHOLD)" ] && \
+    	iwconfig ${device} \
+	frag "$(eval echo \$${prefix}WLAN_FRAGMENTATION_THRESHOLD)"
+    if [ -n "$(eval echo \$${prefix}WLAN_KEY)" ]; then
+	iwconfig ${device} key "$(eval echo \$${prefix}WLAN_KEY)"
+	[ -n "$(eval echo \$${prefix}WLAN_ENCRYPTION)" ] && \
+		iwconfig ${device} \
+		key "$(eval echo \$${prefix}WLAN_ENCRYPTION)"
+    fi
+    if is_no "$(eval echo \$${prefix}WLAN_ENCRYPTION)"; then
+	iwconfig ${device} key off
+    fi
+    [ -n "$(eval echo \$${prefix}WLAN_POWER)" ] && \
+    	iwconfig ${device} "$(eval echo \$${prefix}WLAN_POWER)"
+    [ -n "$(eval echo \$${prefix}WLAN_TXPOWER)" ] && \
+    	iwconfig ${device} "$(eval echo \$${prefix}WLAN_TXPOWER)"
+    [ -n "$(eval echo \$${prefix}WLAN_RETRY)" ] && \
+    	iwconfig ${device} "$(eval echo \$${prefix}WLAN_RETRY)"
+    if is_yes "$(eval echo \$${prefix}WLAN_COMMIT)"; then
+	iwconfig ${device} commit
+    fi
+    [ -n "$(eval echo \$${prefix}WLAN_NWID)" ] && iwconfig ${device} \
+    	nwid "$(eval echo \$${prefix}WLAN_NWID)"
+	
+    #essid should be last due to netowork rescanning by wlan devices
+    [ -n "$(eval echo \$${prefix}WLAN_ESSID)" ] && iwconfig ${device} \
+    	essid "$(eval echo \$${prefix}WLAN_ESSID)"
+
+}
+
+
 # This must be last line !
 # vi:syntax=sh:tw=78:ts=8:sw=4
 
Index: ifup
===================================================================
RCS file: /cvsroot/rc-scripts/sysconfig/network-scripts/ifup,v
retrieving revision 1.71
diff -a -u -r1.71 ifup
--- ifup	7 Apr 2003 19:54:39 -0000	1.71
+++ ifup	4 Nov 2003 18:13:46 -0000
@@ -96,41 +96,9 @@
 fi
 
 if is_wireless_device "${DEVICE}"; then
-    [ -z "${WLAN_NICKNAME}" ] && WLAN_NICKNAME="$(hostname -f)"
-
-    # wlan mode needs to be first
-    [ -n "${WLAN_MODE}" ] && iwconfig ${DEVICE} mode ${WLAN_MODE}
-    iwconfig ${DEVICE} nickname ${WLAN_NICKNAME}
-    [ -n "${WLAN_ESSID}" ] && iwconfig ${DEVICE} essid ${WLAN_ESSID}
-    [ -n "${WLAN_NWID}" ] && iwconfig ${DEVICE} nwid ${WLAN_NWID}
-    if [ -n "${WLAN_FREQ}" -a "${WLAN_MODE}" != "Managed" ] ; then
-	iwconfig ${DEVICE} freq ${WLAN_FREQ}
-    elif [ -n "${WLAN_CHANNEL}" -a "${WLAN_MODE}" != "Managed" ]; then
-	iwconfig ${DEVICE} channel ${WLAN_CHANNEL}
-    fi
-    [ -n "${WLAN_SENS}" ] && iwconfig ${DEVICE} sens ${WLAN_SENS}
-    [ -n "${WLAN_AP}" ] && iwconfig ${DEVICE} ap ${WLAN_AP}
-    [ -n "${WLAN_BITRATE}" ] && iwconfig ${DEVICE} rate ${WLAN_BITRATE}
-    [ -n "${WLAN_RTS_THRESHOLD}" ] && iwconfig ${DEVICE} rts ${WLAN_RTS_THRESHOLD}
-    [ -n "${WLAN_FRAGMENTATION_THRESHOLD}" ] && iwconfig ${DEVICE} frag ${WLAN_FRAGMENTATION_THRESHOLD}
-    if [ -n "${WLAN_KEY}" ]; then
-	iwconfig ${DEVICE} key ${WLAN_KEY}
-	[ -n "${WLAN_ENCRYPTION}" ] && iwconfig ${DEVICE} key ${WLAN_ENCRYPTION}
-    fi
-    if is_no "${WLAN_ENCRYPTION}"; then
-	iwconfig ${DEVICE} key off
-    fi
-    [ -n "${WLAN_POWER}" ] && iwconfig ${DEVICE} ${WLAN_POWER}
-    [ -n "${WLAN_TXPOWER}" ] && iwconfig ${DEVICE} ${WLAN_TXPOWER}
-    [ -n "${WLAN_RETRY}" ] && iwconfig ${DEVICE} ${WLAN_RETRY}
-    if is_yes "${WLAN_COMMIT}"; then
-	iwconfig ${DEVICE} commit
-    fi
-    [ -n "${WLAN_NWID}" ] && iwconfig ${DEVICE} nwid ${WLAN_NWID}
-    # essid should be last due to netowork rescanning by wlan devices
-    [ -n "${WLAN_ESSID}" ] && iwconfig ${DEVICE} essid ${WLAN_ESSID}
+    wireless_param ${DEVICE}
 fi
-	
+
 if [ "$HANDLING" = "2" ]; then
 	exit 0
 fi
Index: ifup-br
===================================================================
RCS file: /cvsroot/rc-scripts/sysconfig/network-scripts/ifup-br,v
retrieving revision 1.4
diff -a -u -r1.4 ifup-br
--- ifup-br	11 May 2002 09:50:53 -0000	1.4
+++ ifup-br	4 Nov 2003 18:13:46 -0000
@@ -82,5 +82,11 @@
 	exit 1
 fi
 
+for device in $BRIDGE_DEVS; do
+    if is_wireless_device "${device}"; then
+	wireless_param "${device}" "br"
+    fi
+done
+
 # This must be last line !
 # vi:syntax=sh:tw=78:ts=8:sw=4


Więcej informacji o liście dyskusyjnej pld-devel-pl