# Configure nsd-control

# Run it as nsd user to have correct permissions
# OpenSSL require rnd file in home temporary
sudo -u nsd HOME=/opt/local/etc/nsd nsd-control-setup
rm /opt/local/etc/nsd/.rnd

# Enable nsd service
svcadm enable svc:/network/nsd:default

# Configure nsd-control

# Run it as nsd user to have correct permissions
# OpenSSL require rnd file in home temporary
sudo -u nsd HOME=/opt/local/etc/nsd nsd-control-setup
rm /opt/local/etc/nsd/.rnd

# Create nsd_listen.conf file with all ip addresses managed
# by vmadm sdc:nics / mdata
NSD_LISTEN_CONF='/opt/local/etc/nsd/nsd_listen.conf'
echo > ${NSD_LISTEN_CONF}
if mdata-get sdc:nics 1>/dev/null 2>&1; then
	echo "ip-address: 127.0.0.1" >  ${NSD_LISTEN_CONF}
	echo "ip-address: ::1"       >> ${NSD_LISTEN_CONF}
	for ip in $(mdata-get sdc:nics | json -a ip); do
		echo "ip-address: ${ip%/*}" >> ${NSD_LISTEN_CONF}
	done
fi

# Enable nsd service
svcadm enable svc:/network/nsd:default

Add script that read out sdc:nic ip information to generate nsd_listen.conf file
Add script that read out sdc:nic ip information to generate nsd_listen.conf file

If we could read the information from sdc:nic and parse it we listen on
that ip addresses. If not the nsd_listen.conf is cleaned to we try to
listen on all interface (which moslty result in the bug).

We're also sure we listen on localhost ipv4 and ipv6.
