#! /bin/sh


case "$1" in

    start)
    	echo "update smbd configuration"
	getcfg cifs_enable
        if [ "$?" != "1" ]; then
                echo "samba  disable"
                exit 0
        fi
	getcfg gen_samba_conf 
	echo "smbd server on"
	/sbin/smbd -D
	/sbin/nmbd -D
	lpd
	;;

    stop)
	echo "samba down"
	
	killall -9 smbd
	if [ "$?" = "0" ]; then echo "Done"
	else                    echo "FAILED"; fi
	
	killall -9 nmbd
	if [ "$?" = "0" ]; then echo "Done"
	else                    echo "FAILED"; fi

	killall -9 lpd 
	;;

    restart)
    	$0 stop
	sleep 1
	$0 start
	;;

    *)
	echo "Usage: $0 (start|stop|restart)"
	exit 1
	;;

esac

exit 0

