3 # Copyright (c) 2006 Simon Kelley
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; version 2 dated June, 1991.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
15 # if $1 is add del or old, this is a dnsmasq-called lease-change
16 # script, update the nvram database. if $1 is init, emit a
17 # dnsmasq-format lease file to stdout representing the current state of the
18 # database, this is called by dnsmasq at startup.
24 # $1 is action (add, del, old)
27 # $4 is hostname (optional, may be unset)
30 # DNSMASQ_LEASE_LENGTH or DNSMASQ_LEASE_EXPIRES (which depends on HAVE_BROKEN_RTC)
31 # DNSMASQ_CLIENT_ID (optional, may be unset)
34 # length|expires MAC addr hostname|* CLID|*
36 # Primary key is address.
38 if [ ${1} = init ] ; then
39 ${NVRAM} show | sed -n -e "/^${PREFIX}.*/ s/^.*=//p"
41 if [ ${1} = del ] ; then
42 ${NVRAM} unset ${PREFIX}${3}
45 if [ ${1} = old ] || [ ${1} = add ] ; then
46 ${NVRAM} set ${PREFIX}${3}="${DNSMASQ_LEASE_LENGTH:-}${DNSMASQ_LEASE_EXPIRES:-} ${2} ${3} ${4:-*} ${DNSMASQ_CLIENT_ID:-*}"