SetStaticLeases
#!/bin/sh
# Defines the DD-WRT nvram variables `static_leases' and `static_leasenum'
# to create a `Services: Services: DHCP Server: Static Leases:' table.
# Edit this script before run it !
# Tested with `DD-WRT v24-sp2 (12/14/11) std - build 18007' for Gateworks GW2358-4
# and `DD-WRT v24-sp2 (08/07/10) mini - build 14896' for Linksys WRT54GL v1.1.
# This script was written by Stephan Seidl in 2012, no copyright is claimed.
# It is offered as-is, without any warranty.
# This script is in the public domain; do with it what you wish.
sys=0
ifconfig -a | tr '[a-z]' '[A-Z]' | grep -q '00:11:22:33:EE:97' && sys=1
ifconfig -a | tr '[a-z]' '[A-Z]' | grep -q '00:11:22:33:EE:98' && sys=1
ifconfig -a | tr '[a-z]' '[A-Z]' | grep -q '00:11:22:33:4C:69' && sys=2
ifconfig -a | tr '[a-z]' '[A-Z]' | grep -q '00:11:22:33:4C:6A' && sys=2
ifconfig -a | tr '[a-z]' '[A-Z]' | grep -q '00:11:22:33:4C:6B' && sys=2
ifconfig -a | tr '[a-z]' '[A-Z]' | grep -q '00:11:22:33:E3:99' && sys=3
ifconfig -a | tr '[a-z]' '[A-Z]' | grep -q '00:11:22:33:E3:9A' && sys=3
ifconfig -a | tr '[a-z]' '[A-Z]' | grep -q '00:11:22:33:E3:9B' && sys=3
ifconfig -a | tr '[a-z]' '[A-Z]' | grep -q '00:11:22:33:02:6E' && sys=4
ifconfig -a | tr '[a-z]' '[A-Z]' | grep -q '00:11:22:33:02:6F' && sys=4
ifconfig -a | tr '[a-z]' '[A-Z]' | grep -q '00:11:22:33:02:70' && sys=4
test "${sys}" != "0" || exit 0
if [ "${sys}" = "1" ]; then
scommw="00:11:22:33:EE:98"
scomm="00:11:22:33:EE:97"
wa1="00:11:22:33:4C:69"
fi
if [ "${sys}" = "2" ]; then
exit 0
fi
if [ "${sys}" = "3" ]; then
scommw="00:11:22:33:E3:9A"
scomm="00:11:22:33:E3:99"
wa1="00:11:22:33:02:6E"
fi
if [ "${sys}" = "4" ]; then
exit 0
fi
arg=""
arg="${arg} 00:11:22:33:4B:88 = modem = 192.168.1.1 = 1440 @ "
arg="${arg} ${scommw} = scommw = 192.168.1.15 = 1440 @ "
arg="${arg} 00:11:22:33:C4:56 = shome = 10.xxx.yyy.11 = 1440 @ "
arg="${arg} 00:11:22:33:12:66 = sbase = 10.xxx.yyy.12 = 1440 @ "
arg="${arg} 00:11:22:33:FD:FF = smobie = 10.xxx.yyy.14 = 1440 @ "
arg="${arg} ${scomm} = scomm = 10.xxx.yyy.15 = 1440 @ "
arg="${arg} 00:00:00:00:00:00 = sinou = 10.xxx.yyy.16 = 1440 @ "
arg="${arg} 00:00:00:00:00:00 = stest = 10.xxx.yyy.17 = 1440 @ "
arg="${arg} 00:11:22:33:11:EA = swind = 10.xxx.yyy.18 = 1440 @ "
arg="${arg} 00:00:00:00:00:00 = sback = 10.xxx.yyy.19 = 1440 @ "
arg="${arg} 00:11:22:33:9C:7B = pserver1 = 10.xxx.yyy.21 = 1440 @ "
arg="${arg} 00:11:22:33:91:1D = pserver2 = 10.xxx.yyy.22 = 1440 @ "
arg="${arg} 00:11:22:33:71:EE = leone = 10.xxx.yyy.31 = 1440 @ "
arg="${arg} 00:00:00:00:00:00 = shomealt = 10.xxx.yyy.32 = 1440 @ "
arg="${arg} 00:11:22:33:EA:4C = rosae = 10.xxx.yyy.33 = 1440 @ "
arg="${arg} 00:11:22:33:A6:1C = selmae = 10.xxx.yyy.34 = 1440 @ "
arg="${arg} 00:11:22:33:12:66 = pserver = 10.xxx.yyy.41 = 1440 @ "
arg="${arg} 00:11:22:33:12:66 = tserver = 10.xxx.yyy.42 = 1440 @ "
arg="${arg} 00:11:22:33:1D:FB = ups1 = 10.xxx.yyy.61 = 1440 @ "
arg="${arg} 00:11:22:33:CA:39 = tel1 = 10.xxx.yyy.71 = 1440 @ "
arg="${arg} 00:11:22:33:BF:4F = smobi = 10.xxx.yyy.114 = 1440 @ "
arg="${arg} 00:11:22:33:13:92 = leon = 10.xxx.yyy.131 = 1440 @ "
arg="${arg} 00:00:00:00:00:00 = shomealtw = 10.xxx.yyy.132 = 1440 @ "
arg="${arg} 00:11:22:33:A9:D7 = rosa = 10.xxx.yyy.133 = 1440 @ "
arg="${arg} 00:11:22:33:BA:0E = selma = 10.xxx.yyy.134 = 1440 @ "
arg="${arg} ${wa1} = wa1 = 10.xxx.yyy.151 = 1440 @ "
arg="${arg} 00:11:22:33:70:55 = radio1 = 10.xxx.yyy.181 = 1440 @ "
arg="${arg} # "
num="${arg}"
num=`echo "${num}" | tr '\012' ' '`
num=`echo "${num}" | tr '@' '\012'`
num=`echo "${num}" | wc -l`
num=`echo "${num} 1 - p " | dc`
num=`echo "${num}" | sed 's, ,,g'`
arg=`echo "${arg}" | sed 's, ,,g'`
arg=`echo "${arg}" | tr '@' ' '`
arg=`echo "${arg}" | tr '#' '\012'`
nvram set static_leases="${arg}"
nvram set static_leasenum="${num}"
nvram commit
Stephan K.H. Seidl