##----------------------------------------------------------------------------- ## rc941.wol - fli4l configuration parameters __FLI4LVER__ ## ## Creation: 12.10.2002 gk ## Last Update: $Id: rc941.wol 27 2006-03-14 14:49:21Z frudolph $ ## ## Copyright (c) 2002-2004 Georg Kainzbauer ## Copyright (c) 2006 Frank Rudolph ## ## ## 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. ##----------------------------------------------------------------------------- # find the ethX for act. HOST_X_NAME find_eth () { [ 0$IP_NET_N -eq 0 ] || for idx in `seq 1 $IP_NET_N` do eval IP_NET_X='$IP_NET_'$idx'' if [ "$IP_NET_X" = "dhcp" ] then continue fi eval HOST_X_DEV='$IP_NET_'$idx'_DEV' eval net1=`netcalc network $IP_NET_X` eval HOST_X_MASK=`echo $IP_NET_X | cut -d"/" -f 2` eval HOST_X_NET=`netcalc network $HOST_X_IP $HOST_X_MASK` if [ "$net1" = "$HOST_X_NET" ] then break fi done } addhost() { eval echo 'WOL_HOST_'$idx1'_NUM $HOST_X_MAC $HOST_X_DEV $HOST_X_IP $HOST_X_NAME' >> /var/run/wol/hosts.mac idx1=`/usr/bin/expr $idx1 + 1` } build_host_list() { idx1=0 [ 0$HOSTS_N -eq 0 ] || for i in `seq 1 $HOSTS_N` do eval HOST_X_MAC='$HOST_'$i'_MAC' eval HOST_X_IP='$HOST_'$i'_IP4' eval HOST_X_NAME='$HOST_'$i'_NAME' found=0 # if there is no MAC we couldn't wakeup the host if [ -n "$HOST_X_MAC" ] then find_eth [ 0$WOL_LIST_N -eq 0 ] || for j in `seq 1 $WOL_LIST_N` do eval WOL_LIST_X='$WOL_LIST_'$j'' translate_ip_net $WOL_LIST_X if echo $WOL_LIST_X | egrep '(ip_net|IP_NET)_([1-9]|[1-9][0-9])' > /dev/null then eval WOL_LIST_X=`netcalc network $res` else WOL_LIST_X=$res fi if [ "$WOL_LIST_X" = "$HOST_X_NET" ] then if ( [ "$WOL_LIST" = "black" ] ) then found=1 else addhost fi break fi if ( [ "$WOL_LIST_X" = "$HOST_X_IP" ] ) then if ( [ "$WOL_LIST" = "black" ] ) then found=1 else #if ( [ "$WOL_LIST" = "white" ] ) addhost fi break fi done if ( [ 0 -eq $found ] && [ "$WOL_LIST" = "black" ]) then addhost fi fi done #eval echo 'NUM_OF_HOSTS $idx1' >> /var/run/wol/hosts.mac } if [ "$OPT_WOL" = "yes" ] then begin_script WOL "setting up WakeOnLan (ether-wake)" if [ "$OPT_HTTPD" = "yes" -a "$WOL_HTML" = "yes" ] then httpd-menu.sh add -p 900 'control_wol.cgi' 'WakeOnLAN' '$_MT_ctrl' 'wol' fi # only add host to wol # - 0 to x clients are blacklisted, 0 means all hosts will be added to hosts.mac (this is default) # - 1 to x clients are whitelisted, 0 means no hosts will be added to hosts.mac if (( [ $WOL_LIST_N -ge 0 ] && [ "$WOL_LIST" = "black" ] ) || ( [ $WOL_LIST_N -gt 0 ] && [ "$WOL_LIST" = "white" ] )) then mkdir /var/run/wol build_host_list fi # --- experimental code piece start --- if [ "$WOL_BOOT" = yes ] then [ 0$WOL_BOOT_N -eq 0 ] || for j in `seq 1 $WOL_BOOT_N` do eval WOL_HOST_X='$WOL_BOOT_'$j'' translate_ip_net $WOL_HOST_X [ 0$HOSTS_N -eq 0 ] || for i in `seq 1 $HOSTS_N` do eval HOST_X_IP='$HOST_'$i'_IP4' if [ "$res" = "$HOST_X_IP" ] then eval HOST_X_MAC='$HOST_'$i'_MAC' find_eth ether-wake -i $HOST_X_DEV $HOST_X_MAC eval echo 'Send wol-paket to client $WOL_HOST_X \($HOST_X_MAC\) via $HOST_X_DEV.' break fi done done fi # --- experimental code piece end --- end_script fi