11 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/wlanap
/settings
)
15 mkdir
-p /var
/run
/hostapd
17 boot_mesg
"Starting hostapd... "
19 # Check Interface configuration
20 if ! ip link show
$INTERFACE > /dev
/null
2>&1; then
21 boot_mesg
"Interface $INTERFACE doesn't exist." ${FAILURE}
25 if [ "$(ip link show $INTERFACE | /bin/grep "ether
")" == "" ]; then
26 boot_mesg
"Interface $INTERFACE is assigned to wlan master device." ${FAILURE}
27 boot_mesg
"Please reboot to fix this." ${FAILURE}
31 if [ "$(iwconfig $INTERFACE | /bin/grep "IEEE
")" == "" ]; then
32 boot_mesg
"Interface $INTERFACE is no wireless device." ${FAILURE}
38 if [ -e "/sys/class/net/$INTERFACE/phy80211" ]; then
41 elif [ -e "/sys/class/net/$INTERFACE/madwifi_name_type" ]; then
44 elif [ "$(/bin/grep hostap /sys/class/net/$INTERFACE/uevent)" != "" ]; then
48 boot_mesg
"Interface $INTERFACE is a not supported wireless device." ${FAILURE}
53 echo driver
=$driver > /etc
/hostapd.conf.tmp
54 grep -v "^driver=" /etc
/hostapd.conf
>> /etc
/hostapd.conf.tmp
55 mv /etc
/hostapd.conf.tmp
/etc
/hostapd.conf
57 echo DRIVER
=$DRIVER > /var
/ipfire
/wlanap
/settings.tmp
58 grep -v "^DRIVER=" /var
/ipfire
/wlanap
/settings
>> /var
/ipfire
/wlanap
/settings.tmp
59 chown nobody
:nobody
/var
/ipfire
/wlanap
/settings.tmp
60 chmod 644 /var
/ipfire
/wlanap
/settings.tmp
61 mv /var
/ipfire
/wlanap
/settings.tmp
/var
/ipfire
/wlanap
/settings
63 if [ "$DRIVER" == "MADWIFI" ]; then
64 if [ "$(/usr/sbin/iwconfig $INTERFACE | /bin/grep "Mode
:Master
")" == "" ]; then
65 boot_mesg
"Setting MADWIFI wlan $INTERFACE to Master mode... "
66 # Set Atheros Cards to master mode
67 /usr
/bin
/wlanconfig
$INTERFACE destroy
> /dev
/null
68 /usr
/bin
/wlanconfig
$INTERFACE create wlandev wifi0 wlanmode ap
> /dev
/null
70 elif [ "$DRIVER" == "HOSTAP" ]; then
71 if [ "$(/usr/sbin/iwconfig $INTERFACE | /bin/grep "Mode
:Master
")" == "" ]; then
72 boot_mesg
"Setting HOSTAP wlan $INTERFACE to Master mode... "
73 # Set Prism Cards to master mode
74 /usr
/bin
/iwconfig
$INTERFACE mode master
> /dev
/null
78 # First reset to World (00) and then set new country
79 /usr
/sbin
/iw reg
set 00
80 /usr
/sbin
/iw reg
set $COUNTRY
82 /usr
/sbin
/iwconfig
$INTERFACE channel
$CHANNEL 2>/dev
/null
83 /usr
/sbin
/iwconfig
$INTERFACE txpower
$TXPOWER
85 /usr
/bin
/hostapd
-P /var
/run
/hostapd
/etc
/hostapd.conf
>/dev
/null
2>&1 &
89 if [ $DRIVER == "MADWIFI" ]; then
90 iwpriv
$INTERFACE maccmd
3
91 if [ $MACMODE != 0 ]; then
92 FILE
="/var/ipfire/wlanap/macfile"
96 iwpriv
$INTERFACE addmac
$LINE
99 iwpriv
$INTERFACE maccmd
$MACMODE
105 if [ "$(/usr/sbin/iwconfig $INTERFACE | /bin/grep "Mode
:Master
")" == "" ]; then
106 boot_mesg
"Error! Can't set wlan master mode"
115 boot_mesg
"Stopping hostapd..."
117 killproc
/usr
/bin
/hostapd
128 statusproc
/usr
/bin
/hostapd
132 echo "Usage: ${0} {start|stop|restart|status}"