#!/bin/sh ### # # FreeWLAN Addons - http://www.freewlan.info # # This Script is based on work by Dema - see http://fonblog.wordpress.com/ # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA # # http://www.gnu.org/copyleft/gpl.html # ### . /etc/functions.sh config_load router config_get mode mode mode if [ "$mode" -eq "2" ]; then config_get rssid mode rssid config_get key mode key config_get enc mode enc config_get dhcp mode dhcp config_get ip mode ip config_get netmask mode netmask config_get gateway mode gateway config_get dns mode dns config_get ssid mode ssid config_get bridge mode bridge config_get oldwan mode oldwan # stop daemons killall -9 udhcpc killall dnsmasq killall chilli killall wpa_supplicant # flush netfilter tables iptables -F iptables -P INPUT ACCEPT iptables -P OUTPUT ACCEPT iptables -P FORWARD ACCEPT iptables -t nat -F # create new VAP devices wlanconfig ath0 destroy wlanconfig ath1 destroy # VAP ath0 as station managed wlanconfig ath0 create wlandev wifi0 wlanmode sta nosbeacon ifconfig ath0 up case "$enc" in wpa|WPA) iwpriv ath0 wpa 3 iwconfig ath0 essid "$rssid" wpa_supplicant -iath0 -c/etc/wpa_supplicant.conf -B -d ;; wep|WEP) iwconfig ath0 key "$key" iwpriv ath0 authmode 2 iwconfig ath0 essid "$rssid" ;; *) iwconfig ath0 essid "$rssid" ;; esac case "$dhcp" in 1) udhcpc -i ath0 -R ln -sf /tmp/resolv.conf /etc/resolv.conf ;; *) ifconfig ath0 $ip netmask $netmask up echo "nameserver $dns" > /etc/resolv.conf route add default gw $gateway ;; esac # VAP ath1 as Access Point wlanconfig ath1 create wlandev wifi0 wlanmode ap iwconfig ath1 essid FON_"$ssid" ifconfig ath1 192.168.20.1 netmask 255.255.255.0 up # eth0 as Bridge if enabled $bridge; then ifconfig eth0 192.168.11.1 netmask 255.255.255.0 up # forwarding between the two subnets iptables -t nat -A POSTROUTING -o ath0 -j MASQUERADE iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE dnsmasq --conf-file /etc/dnsmasq.repeater fi # generate chilli.repeater containing right magic and dhcpif TMP_C=/tmp/chilli.repeater ETC_C=/etc/chilli.repeater touch $ETC_C touch $TMP_C RADIUSSERVER=radius01.fon.com RADIUSSECRET=garrafon RADIUSADMUSR=chillispot RADIUSADMPWD=chillispot MAC=$(ifconfig wifi0 | head -n1 | awk '{print $5}'|sed s/:/-/g) MAC=${MAC:-fon} /usr/sbin/chilli_radconfig \ -c /dev/null \ --radiusserver1="$RADIUSSERVER" \ --radiussecret="$RADIUSSECRET" \ --adminuser="$RADIUSADMUSR" \ --adminpasswd="$RADIUSADMPWD" \ --radiusnasid="$MAC" \ --dhcpif ath1 \ > $TMP_C [ -n "$(cat $TMP_C)" ] && { MD5SUM_TMP=$(md5sum $TMP_C | awk '{ print $1 }') MD5SUM_ETC=$(md5sum $ETC_C | awk '{ print $1 }') if [ ! "$MD5SUM_TMP" = "$MD5SUM_ETC" ]; then sed -e "s/eth1/ath1/" $TMP_C > $ETC_C fi } chilli --conf /etc/chilli.repeater fi