#!/bin/sh
#
# SambaManager.pre_delete <installer path> <installed path>
#
if /bin/sed '/^netbios-/d' /etc/inetd.conf >/tmp/inetd.conf
then
	if /bin/mv -f /tmp/inetd.conf /etc/inetd.conf
	then
#     kill any running daemons
		if [ -f /tmp/smbd.pid ]
		then
			/bin/kill -9 `/bin/cat /tmp/smbd.pid`
			/bin/rm -f /tmp/smbd.pid
		fi
		if [ -f /tmp/nmbd.pid ]
		then
			/bin/kill -9 `/bin/cat /tmp/nmbd.pid`
			/bin/rm -f /tmp/nmbd.pid
		fi
#     send a SIGHUP to inetd.conf
		/bin/kill -1 `/bin/ps ax | /bin/grep inetd | /bin/grep -v grep | /bin/awk '{ print $1 }'`
		echo "OK. /etc/inetd.conf cleaned."
		/bin/rm -f /usr/local/smbpasswd /users/local/smbpasswd
	else
		echo "FAILED. Could not edit /etc/inetd.conf."
		/bin/rm /tmp/inetd.conf
	fi
else
	echo "FAILED. Could not edit /etc/inetd.conf."
	/bin/rm /tmp/inetd.conf
fi
exit 0
