3 # Purpose: set up access point on your box
4 # Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2.
7 # Latest change: Mit Okt 11 23:00:43 CEST 2006 [moemoe]
8 ################################################################################
13 CONFIG_FILE=/etc/grml/routersetup
14 . /etc/grml/lsb-functions
15 . /etc/grml/net-functions
16 . /etc/grml/script-functions
20 if ! [ -r "$CONFIG_FILE" ] ; then
21 eerror "$CONFIG_FILE could not be read."
27 [ -n "$AP_ESSID" ] || AP_ESSID=grml-ap
28 [ -n "$AP_ENC" ] || AP_ENC=off
32 echo $1 | grep -q wlan && DEV=$(echo $1 | sed 's/wlan/wifi/')
33 einfo "Finished setting up access point. Make sure your device $DEV is configured:"
34 einfo "For example put the following into /etc/network/interfaces and run \"ifup $DEV=ap\""
40 broadcast 192.168.10.255
42 einfo "On the client side put the following into /etc/network/interfaces and run \"ifup \$DEV=ap\""
48 broadcast 192.168.10.255
50 wireless_essid $AP_ESSID
56 einfo "Setting $1 to mode $2"
57 iwpriv $1 mode $2 ; eend $?
63 einfo "Setting wireless modes on $DEV"
66 einfo "Setting sid to: $AP_ESSID"
67 iwconfig $DEV essid $AP_ESSID ; eend $?
69 [ "$AP_ENC" = off ] && ENC_INFO='off' || ENC_INFO='******'
70 einfo "Settinc encrypton to: $ENC_INFO "
71 iwconfig $DEV enc $AP_ENC ; eend $?
73 einfo "Setting device up"
74 ifconfig $DEV up ; eend $?
80 einfo "Atheros setup: creating new WLAN AP device"
82 # ugly but don't know of another workaround
83 if iwconfig 2>/dev/null | grep -A1 ath0 | grep -q 'Access Point: Not-Associated' ; then
84 einfo "Destroying old ath device"
85 wlanconfig ath0 destroy ; eend $?
88 device=$(wlanconfig ath create wlandev $1 wlanmode ap)
91 setupWifiDevice $device
92 [ -n "$ATH_MODE" ] && set_ath_mode "$device" "$ATH_MODE"
99 einfo "Hostap setup: creating new WLAN AP device"
102 # einfo "Changing mode of $1 to AP"
103 # ifconfig $1 down ; eend $?
105 # dunno if the card is pci or pcmcia, just try to unload and
106 # load both versions,
107 [ -n $(lsmod | grep ^orinoco_pci) ] && HAPT="pci"
108 [ -n $(lsmod | grep ^orinoco_cs) ] && HAPT="cs"
109 [ -n $(lsmod | grep ^orinoco_plx) ] && HAPT="plx"
111 einfo "Unloading old modules"
112 modprobe -r orinoco orinoco_$HAPT
115 einfo "Loading new modules"
116 modprobe hostap_$HAPT
117 eend $? && setupWifiDevice $1
126 einfo "Trying to set $1 into mode master"
128 iwconfig $1 mode master
129 eend $? && setupWifiDevice $1
134 einfo "Generic setup (no hostap / atheros capable device found): creating new WLAN AP device"
135 echo "TODO! iwconfig $1 mode Ad-Hoc"
140 # If you want to extend this with a specific funtion for a
141 # special driver, please have a look at /etc/grml/net-functions
142 for i in $AP_DEVICE $(getWlanDevices) ; do
143 DRIVER=$(getLanDriver $i)
146 echo $i | grep -q ath && i=$(echo $i | sed 's/ath/wifi/')
163 einfo "Searching for WLAN device with ESSID $AP_ESSID"
164 DEVICE=$(iwconfig 2>/dev/null| grep "ESSID:\"$AP_ESSID\"" | awk '{print $1}')
166 if [ -n "$DEVICE" ] ; then
167 for i in $DEVICE ; do
168 einfo "Found device $i" ; eend 0
171 eerror "No device(s) with ESSID $AP_ESSID found"
176 einfo "Shutting down $DEVICE"
178 wlanconfig $DEVICE destroy ; eend $?
182 for i in $DEVICE ; do
183 einfo "Shutting down $i"
197 einfo "Trying to stop all present grml-ap setups"
206 echo "Usage: $0 {start|stop|restart}"
211 eerror "Your wlan card is not supported at the moment. Sorry" ; eend 1
214 ## END OF FILE #################################################################
215 # vim: ft=sh expandtab ai