FreeNAS Code
This project has moved to github - see https://github.com/freenas
Brought to you by:
cochard,
mattolander
#!/bin/sh # Copyright (c) 2007-2009 Volker Theile (votdev@gmx.de) # All rights reserved. # PROVIDE: hosts # REQUIRE: netif # BEFORE: NETWORKING . /etc/rc.subr . /etc/util.subr . /etc/configxml.subr echo "Updating hosts." # LAN IF/ADDR _ifn=`configxml_get "//interfaces/lan/if"` _ifn=`get_if ${_ifn}` _ipaddr=`get_ipaddr inet ${_ifn}` # Generate /etc/hosts file /usr/local/bin/xml sel -t -m "//system[hostname != '' and domain != '']" \ -v "concat('::1 localhost localhost.',domain)" -n \ -v "concat('127.0.0.1 localhost localhost.',domain)" -n \ -i "//interfaces/lan/ipaddr[. != 'dhcp']" \ -v "concat(//interfaces/lan/ipaddr,' ',hostname,'.',domain,' ',hostname)" -n \ -b \ -i "//interfaces/lan/ipaddr[. = 'dhcp']" \ -i "string-length('${_ipaddr}') > 0" \ -v "concat('${_ipaddr}',' ',hostname,'.',domain,' ',hostname)" -n \ -b \ -b \ -m "//system/hosts" \ -i "string-length(name) > 0" -v "concat(address,' ',name)" -n -b \ -b \ ${configxml_file} | /usr/local/bin/xml unesc > /etc/hosts # Generate /etc/hosts.allow file /usr/local/bin/xml sel -t -m "//system/hostsacl/rule" \ -v "." -n \ ${configxml_file} | /usr/local/bin/xml unesc > /etc/hosts.allow