1 |
Hallo, |
2 |
|
3 |
Am Montag, den 15.05.2006, 16:36 +0200 schrieb Juergen Rose: |
4 |
|
5 |
> Was sind Eure Methoden um vergleichbare Situationen zu behandeln? Am |
6 |
> liebsten waere mir, wenn ich nur eine Netzwerkkonfiguration fuer zu |
7 |
> Hause haette. Der Rechner testet zuerst, ob er am Festnetz haengt |
8 |
> (ifplugd oder aehnlich), wenn ja - konfiguriert er eth0 und aktiviert |
9 |
> die Schnittstelle, wenn nein - konfiguriert er ath0 und aktiviert sie. |
10 |
|
11 |
ich benutze dazu ifplugd und hab meine /etc/ifplugd/ifplugd.action nach |
12 |
meinen Bedürfnissen angepasst. (Je nachdem, welchen Domainname der |
13 |
DHCP-Server beispielsweise auswirft, wird Samba gestartet, die Firewall |
14 |
anders konfiguriert, etc...). Beim Einstöpseln des Netzwerkkabels wird |
15 |
ath0 entfernt, beim Ziehen wieder eins erstellt... |
16 |
|
17 |
Bei mir sieht das so aus: |
18 |
---------------------------------- |
19 |
|
20 |
#!/bin/sh |
21 |
# Copyright 1999-2004 Gentoo Foundation |
22 |
# Distributed under the terms of the GNU General Public License v2 |
23 |
# |
24 |
# Gentoo-specific ifplugd.action |
25 |
# |
26 |
# This file gets called by ifplugd when it wants to bring an interface |
27 |
# up or down. |
28 |
# |
29 |
|
30 |
if grep -q initng /proc/1/cmdline |
31 |
then |
32 |
EXEC="/sbin/ngc" |
33 |
INITNG="yes" |
34 |
else |
35 |
EXEC="/etc/init.d/net.$1" |
36 |
INITNG="no" |
37 |
fi |
38 |
|
39 |
case "$2" in |
40 |
up) |
41 |
if [ "${INITNG}" = "yes" ] |
42 |
then |
43 |
ARGS="-u net/$1" |
44 |
else |
45 |
ARGS="--quiet start" |
46 |
fi |
47 |
if [ `/etc/init.d/net.ath0 status | grep -c "started"` != 0 ]; |
48 |
then |
49 |
/etc/init.d/net.ath0 stop; |
50 |
fi |
51 |
if [ `less /proc/net/wireless | grep -c ath0` != 0 ]; then |
52 |
wlanconfig ath0 destroy; |
53 |
fi |
54 |
if [ `/bin/domainname | grep -c "NETZWERKNAME"` != 0 ]; then |
55 |
##########TU WAS BESONDERS |
56 |
fi |
57 |
;; |
58 |
down) |
59 |
if [ "${INITNG}" = "yes" ] |
60 |
then |
61 |
ARGS="-d net/$1" |
62 |
else |
63 |
ARGS="--quiet stop" |
64 |
fi |
65 |
if [ `/etc/init.d/samba status | grep -c "started"` != 0 ]; then |
66 |
if test -r /var/run/dhcpcd-ath0.pid; then |
67 |
rm /var/run/dhcpcd-ath0.pid; fi |
68 |
if [ `less /proc/net/wireless | grep -c ath0` == 0 ]; then |
69 |
wlanconfig ath0 create wlandev wifi0 wlanmode sta; |
70 |
sleep 2 |
71 |
fi |
72 |
if [ `/etc/init.d/net.ath0 status | grep -c "started"` != 0 ]; |
73 |
then |
74 |
/etc/init.d/net.ath0 restart; |
75 |
else |
76 |
/etc/init.d/net.ath0 start; |
77 |
fi |
78 |
;; |
79 |
*) |
80 |
echo "$0: wrong arguments" >&2 |
81 |
echo "Call with <interface> <up|down>" >&2 |
82 |
exit 1 |
83 |
;; |
84 |
esac |
85 |
|
86 |
export IN_BACKGROUND=true |
87 |
|
88 |
if [ -x "${EXEC}" ] |
89 |
then |
90 |
${EXEC} ${ARGS} |
91 |
exit 0 |
92 |
else |
93 |
logger -t ifplugd.action "Error: Couldn't configure $1, no |
94 |
${EXEC} !" |
95 |
exit 1 |
96 |
fi |
97 |
|
98 |
# vim: set ts=4 |
99 |
|
100 |
-------------------------- |
101 |
Damit das auch beim Booten funktioniert: die /etc/conf.d/local.start |
102 |
(Manche Accesspoints, die ich nutze, können leider nur WEP. Damit |
103 |
funktioniert aber mein wpa_supplicant nicht. Gibts da wen, der das |
104 |
laufen hat?) |
105 |
-------------------------- |
106 |
# /etc/conf.d/local.start |
107 |
|
108 |
# This is a good place to load any misc programs |
109 |
# on startup ( use 1>&2 to hide output) |
110 |
|
111 |
echo enable > /proc/acpi/ibm/hotkey |
112 |
echo 0xffff > /proc/acpi/ibm/hotkey |
113 |
|
114 |
# if not plugged in, find out whether there is an usuable wlan |
115 |
if [ `/sbin/mii-tool eth0 | grep -c "no link"` != 0 ]; then |
116 |
# echo " starting wlan"; |
117 |
# /etc/init.d/net.ath0 start; |
118 |
if [ `iwlist ath0 ap | grep -c "MAC_AD ACCESSPOINT"` == 1 ]; then |
119 |
/usr/local/bin/scheissnetz2 |
120 |
else |
121 |
read -p "Soll ich nach einem Netz suchen (1), mit XXXXXX Wlan |
122 |
verbinden (2) oder nichts tun (3)? Eingabe: " todo |
123 |
case "$todo" in |
124 |
1) echo "WLAN wird gesucht" |
125 |
/etc/init.d/net.ath0 start;; |
126 |
2) echo "Verbinde mit Leas Wlan" |
127 |
/usr/local/bin/wepnetz;; |
128 |
3) echo "Kein WLAN wird konfiguriert";; |
129 |
*) echo "Falsche Eingabe, kein WLAN konfiguriert";; |
130 |
esac |
131 |
fi |
132 |
else |
133 |
echo "searching a suitable lan"; |
134 |
#/etc/init.d/net.eth0 start |
135 |
# waiting for some services to settle |
136 |
sleep 5 |
137 |
|
138 |
fi |
139 |
|
140 |
|
141 |
Viele Grüße |
142 |
|
143 |
Bene |
144 |
-- |
145 |
Das große Karthago führte drei Kriege. |
146 |
Nach dem ersten war es noch mächtig. |
147 |
Nach dem zweiten war es noch bewohnbar. |
148 |
Nach dem dritten war es nicht mehr zu finden. |
149 |
(Bertold Brecht) |
150 |
|
151 |
|
152 |
|
153 |
-- |
154 |
gentoo-user-de@g.o mailing list |