#!/bin/sh ### # # FreeWLAN Addons - http://www.freewlan.info # # 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 . /tmp/network-config config_load mailservice config_get conalarm mail conalarm config_get to mail to config_load fon config_get essid public essid config_load blockmac config_get blockmac main enable case "$1" in "up") CONN="UP"; mac=`echo $CALLING_STATION_ID|sed s/-/:/g` echo "$mac $FRAMED_IP_ADDRESS $USER_NAME $SESSION_TIMEOUT `date +%s`" >>/tmp/online enabled blockmac && { grep -q $USER_NAME /etc/blockuser && { sleep 10 iwpriv=/usr/sbin/iwpriv $iwpriv ath0 maccmd 2 >/dev/null 2>&1 $iwpriv ath0 addmac $mac $iwpriv ath0 kickmac $mac STAT="BLOCKED" } } ;; "down") CONN="DOWN"; mac=`echo $CALLING_STATION_ID|sed s/-/:/g` grep -v $mac /tmp/online >/tmp/online_$$.tmp cat /tmp/online_$$.tmp >/tmp/online rm /tmp/online_$$.tmp enabled blockmac && { grep -q $USER_NAME /etc/blockuser && { iwpriv=/usr/sbin/iwpriv $iwpriv ath0 delmac $mac STAT="UNBLOCKED" } } ;; esac; if enabled $conalarm;then MAIL_TO="$to"; echo " $STAT Connection $CONN DATE $(date) ESSID $essid Hostname `cat /etc/hostname` Status URL http://$(ifconfig $wan_ifname 2>/dev/null | grep inet | awk -F'[: ]+' '{print $4}')/cgi-bin/webif/status.sh CALLED_STATION_ID $( ifconfig wifi0|grep HWaddr|sed -e "s/^.*HWaddr //" |sed -e "s/ //g" ) CALLING_STATION_ID $CALLING_STATION_ID FRAMED_IP_ADDRESS $FRAMED_IP_ADDRESS USER_NAME $USER_NAME SESSION_TIMEOUT $SESSION_TIMEOUT "| mail "Fonera: (`cat /etc/hostname`) $USER_NAME $CONN" "$MAIL_TO" fi