#!/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 # ### THCLVER="1.0" . /etc/functions.sh . /tmp/network-config config_load fon # private key for fetching the info from the FON server KEY=/etc/dropbear/key USER=openwrt SERVER=download.fon.com PORT=1937 # gather information about this machine # gather information about this machine WLMAC=$( ifconfig wifi0|grep HWaddr|sed -e "s/^.*HWaddr //" |sed -e "s/ //g" ) #$wifi_ifname WLMAC2=$( ifconfig $lan_ifname|grep HWaddr|sed -e "s/^.*HWaddr //" |sed -e "s/ //g" ) if [ -f /tmp/eth0_mac ]; then ETMAC=$(cat /tmp/eth0_mac) else ETMAC=$( ifconfig eth0|grep HWaddr|sed -e "s/^.*HWaddr //" |sed -e "s/ //g" ) fi # gather information about this machine FONREV="$(cat /etc/fon_revision)" FIRMWARE="$(cat /etc/fon_version)" DEVICE="$(cat /etc/fon_device)" #CHILLVER="$(ipkg list_installed|grep chillispot| cut -d\ -f3)" CHILLVER="1.0-1" record_changes () { if [ ! -d /www/updates ]; then mkdir /www/updates fi if [ -s /tmp/thinclient.sh ]; then FS=$(ls -l /tmp/$1.sh | tr -s " " | cut -d " " -f 5) if [ $FS -gt 35 ]; then md5=$(md5sum /tmp/thinclient.sh); md5=$(echo $md5|cut -d" " -f1); md5sum /www/updates/* | grep -q $md5 || \ cp /tmp/$1.sh /www/updates/$1-$(date '+%Y%m%d-%H%M').sh rm /tmp/thinclient.sh fi else echo "Datei leer oder nicht da. $(date '+%Y%m%d-%H%M')" >> /www/updates/fonupdate.log; fi } exec_cron_mode () { if [ -n "$2" ]; then sleep "$((0x$(head -c2 /dev/urandom | hexdump | awk '$2 > 0 {print $2}') % $2))" fi echo "mode='$1' wlmac='$WLMAC' mac='$ETMAC' fonrev='$FONREV' firmware='$FIRMWARE' chillver='$CHILLVER' thclver='$THCLVER' device='$DEVICE'" | ssh -T ${PORT:+ -p $PORT}${KEY:+ -i $KEY} "${USER}@${SERVER}" > /tmp/thinclient.sh if [ -f /etc/debug ]; then record_changes 'thinclient' fi } rm -f /tmp/thinclient.sh rm -rf /tmp/.ssh cp -r /etc/dropbear /tmp/.ssh case "$1" in cron) exec_cron_mode $1 '1700' ;; force) exec_cron_mode 'cron' ;; start) exec_cron_mode $1 ;; *) echo "Usage: `basename $0` {cron|force|start}" exit esac #. /tmp/.thinclient.sh