#!/bin/sh
# Try to bring nmbd up when an interface comes up, if smbd is already running.

# Don't bother to do anything for lo.
if [ "$IFACE" = lo ]; then
	exit 0
fi

# Only run from ifup.
if [ "$MODE" != start ]; then
	exit 0
fi

if [ ! -x /etc/init.d/smbd ]; then
	exit 0
fi

# Samba only cares about inet and inet6. Get thee gone, strange people
# still using ipx.
case $ADDRFAM in
	inet|inet6|NetworkManager)
		;;
	*)
		exit 0
		;;
esac


# Really only necessary to do anything if nmbd is not already running
if status smbd | grep "start/running" > /dev/null \
        && status nmbd | grep "stop/waiting" > /dev/null
then
        start nmbd || exit 0
fi 

exit 0
