Annotation of embedaddon/dnsmasq/contrib/wrt/lease_update.sh, revision 1.1.1.1

1.1       misho       1: #!/bin/sh
                      2: 
                      3: # Copyright (c) 2006 Simon Kelley
                      4: #
                      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.
                      8: #
                      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.
                     13: 
                     14: 
                     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.
                     19: 
                     20: NVRAM=/usr/sbin/nvram
                     21: PREFIX=dnsmasq_lease_
                     22: 
                     23: # Arguments.
                     24: # $1 is action (add, del, old)
                     25: # $2 is MAC 
                     26: # $3 is address
                     27: # $4 is hostname (optional, may be unset)
                     28: 
                     29: # env.
                     30: # DNSMASQ_LEASE_LENGTH or DNSMASQ_LEASE_EXPIRES (which depends on HAVE_BROKEN_RTC)
                     31: # DNSMASQ_CLIENT_ID (optional, may be unset)
                     32: 
                     33: # File.
                     34: # length|expires MAC addr hostname|* CLID|* 
                     35: 
                     36: # Primary key is address.
                     37: 
                     38: if [ ${1} = init ] ; then
                     39:      ${NVRAM} show | sed -n -e "/^${PREFIX}.*/ s/^.*=//p"
                     40: else
                     41:      if [ ${1} = del ] ; then
                     42:           ${NVRAM} unset ${PREFIX}${3}
                     43:      fi
                     44: 
                     45:      if [ ${1} = old ] || [ ${1} = add ] ; then
                     46:           ${NVRAM} set ${PREFIX}${3}="${DNSMASQ_LEASE_LENGTH:-}${DNSMASQ_LEASE_EXPIRES:-} ${2} ${3} ${4:-*} ${DNSMASQ_CLIENT_ID:-*}"
                     47:      fi
                     48:      ${NVRAM} commit
                     49: fi
                     50: 
                     51: 
                     52: 
                     53: 
                     54:  

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>