#!/bin/sh
# Startup script for the Samba Web Administration Tool (SWAT)
# IPnuts Extension Project
# http://ipnuts-ext.sourceforge.jp/wiki/
RCDLINKS="2,S56 0,K56 6,K56"

case "$1" in
  start)
	echo -n "Starting SWAT"
	grep "swat" /etc/inetd.conf > /dev/null
	if [ $? -ne 0 ]; then
	echo -e "swat\t\tstream\ttcp\tnowait\troot\t/usr/sbin/tcpd\t/usr/sbin/swat swat" >> /etc/inetd.conf
	fi
	/etc/init.d/inetd reload > /dev/null
	echo .
	;;
  stop)
  	echo -n "Shutting down SWAT"
	grep "swat" /etc/inetd.conf > /dev/null
	if [ $? -eq 0 ]; then
	grep -v "swat" /etc/inetd.conf > /tmp/swat_init.tmp
	rm -f /etc/inetd.conf
	mv /tmp/swat_init.tmp /etc/inetd.conf
	fi
	/etc/init.d/inetd reload > /dev/null
	echo .
	;;
  restart|reload)
  	$0 stop
	$0 start
	;;
  *)
	echo "Usage: $0 {start|stop|restart|reload}"
	exit 1
	;;
esac

exit 0
