Menu

[r3313]: / trunk / etc / rc.d / hosts  Maximize  Restore  History

Download this file

27 lines (21 with data), 710 Bytes

#!/bin/sh
# Copyright (c) 2007-2008 Volker Theile (votdev@gmx.de)
# All rights reserved.

# PROVIDE: hosts
# REQUIRE: var
# BEFORE: netif

. /etc/util.subr
. /etc/configxml.subr

echo "Updating hosts."

# Get interface address
_if=`configxml_get "//interfaces/lan/if"`
_ipaddr=`get_ipaddr inet ${_if}`

# Generate /etc/hosts file
/usr/local/bin/xml sel -t -m "//system" \
	-v "concat('::1 localhost localhost.',domain)" -n \
	-v "concat('127.0.0.1 localhost localhost.',domain)" -n \
	-o "${_ipaddr} " -v "concat(hostname,'.',domain,' ',hostname)" -n \
	-m "//system/hosts" \
		-i "string-length(name) > 0" -v "concat(address,' ',name)" -n -b \
	-b \
	${configxml_file} | /usr/local/bin/xml unesc > /etc/hosts
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.