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 ################################################################################
12 CONFIG_FILE=/etc/grml/routersetup
13 . /etc/grml/lsb-functions
14 . /etc/grml/net-functions
15 . /etc/grml/script-functions
19 if [ -r "$CONFIG_FILE" ] ; then
22 ewarn "Could not read $CONFIG_FILE"
25 # defaults if unconfigured
26 [ -n "$AP_ESSID" ] || AP_ESSID=grml-ap
27 [ -n "$AP_ENC" ] || AP_ENC=off
31 echo $1 | grep -q wlan && DEV=$(echo $1 | sed 's/wlan/wifi/')
32 einfo "Finished setting up access point. Make sure your device $DEV is configured:"
33 einfo "For example put the following into /etc/network/interfaces and run \"ifup $DEV=ap\""
39 broadcast 192.168.10.255
41 einfo "On the client side put the following into /etc/network/interfaces and run \"ifup \$DEV=ap\""
47 broadcast 192.168.10.255
49 wireless_essid $AP_ESSID
55 einfo "Setting $1 to mode $2"
56 iwpriv $1 mode $2 ; eend $?
62 einfo "Setting wireless modes on $DEV"
65 einfo "Setting sid to: $AP_ESSID"
66 iwconfig $DEV essid $AP_ESSID ; eend $?
68 [ "$AP_ENC" = off ] && ENC_INFO='off' || ENC_INFO='******'
69 einfo "Settinc encrypton to: $ENC_INFO "
70 iwconfig $DEV enc $AP_ENC ; eend $?
72 einfo "Setting device up"
73 ifconfig $DEV up ; eend $?
79 einfo "Atheros setup: creating new WLAN AP device"
81 # ugly but don't know of another workaround
82 if iwconfig 2>/dev/null | grep -A1 ath0 | grep -q 'Access Point: Not-Associated' ; then
83 einfo "Destroying old ath device"
84 wlanconfig ath0 destroy ; eend $?
87 device=$(wlanconfig ath create wlandev $1 wlanmode ap)
90 setupWifiDevice $device
91 [ -n "$ATH_MODE" ] && set_ath_mode "$device" "$ATH_MODE"
98 einfo "Hostap setup: creating new WLAN AP device"
101 # einfo "Changing mode of $1 to AP"
102 # ifconfig $1 down ; eend $?
104 # dunno if the card is pci or pcmcia, just try to unload and
105 # load both versions,
106 [ -n $(lsmod | grep ^orinoco_pci) ] && HAPT="pci"
107 [ -n $(lsmod | grep ^orinoco_cs) ] && HAPT="cs"
108 [ -n $(lsmod | grep ^orinoco_plx) ] && HAPT="plx"
110 einfo "Unloading old modules"
111 modprobe -r orinoco orinoco_$HAPT
114 einfo "Loading new modules"
115 modprobe hostap_$HAPT
116 eend $? && setupWifiDevice $1
125 einfo "Trying to set $1 into mode master"
127 iwconfig $1 mode master
128 eend $? && setupWifiDevice $1
133 einfo "Generic setup (no hostap / atheros capable device found): creating new WLAN AP device"
134 echo "TODO! iwconfig $1 mode Ad-Hoc"
139 # If you want to extend this with a specific funtion for a
140 # special driver, please have a look at /etc/grml/net-functions
141 for i in $AP_DEVICE $(getWlanDevices) ; do
142 DRIVER=$(getLanDriver $i)
145 echo $i | grep -q ath && i=$(echo $i | sed 's/ath/wifi/')
162 einfo "Searching for WLAN device with ESSID $AP_ESSID"
163 DEVICE=$(iwconfig 2>/dev/null| grep "ESSID:\"$AP_ESSID\"" | awk '{print $1}')
165 if [ -n "$DEVICE" ] ; then
166 for i in $DEVICE ; do
167 einfo "Found device $i" ; eend 0
170 eerror "No device(s) with ESSID $AP_ESSID found"
175 einfo "Shutting down $DEVICE"
177 wlanconfig $DEVICE destroy ; eend $?
181 for i in $DEVICE ; do
182 einfo "Shutting down $i"
196 einfo "Trying to stop all present grml-ap setups"
205 echo "Usage: $0 {start|stop|restart}"
210 eerror "Your wlan card is not supported at the moment. Sorry" ; eend 1
213 ## END OF FILE #################################################################
214 # vim: ft=sh expandtab ai