summaryrefslogtreecommitdiff
path: root/functions/allowed/hosts
blob: 912a9ea4bc7133aa77ac4226ac71f145b9ef9e83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#
# utility function used by node.tag/node.def to list "allowed"
# or expanded hosts/address
#
declare -a _vyatta_hosts
declare -a _vyatta_symbolic_hosts=( '<hostname>' '<x.x.x.x>' )
declare -i _vyatta_hostfile_lastmod=0
declare _vyatta_hostfile_sed='s/#.*//; ; s/^[^ \t]\+[ \t]\+//; s/[ \t]\+/\n/g; /^$/d'

function vyatta-allowed-hosts ()
{
    : ${HOSTFILE:=/etc/hosts}
    local -i curmod=$(stat --printf %Y $HOSTFILE)

    if [ $curmod -ne $_vyatta_hostfile_lastmod ] ; then
	_vyatta_hosts=( $(sed "$_vyatta_hostfile_sed" $HOSTFILE) )
	_vyatta_hostfile_lastmod=$curmod
    fi
    printf "%s\n" ${_vyatta_symbolic_hosts[@]}  # ${_vyatta_hosts[@]} $* 	# commenting this untill ipv6 is supported
}

###  Local Variables:
###  mode: shell-script
###  End: