#!/bin/sh
#
# startfile for built in samba, by newbiefan @ wl500g.info
# For Olegs & Ily's FW for Asus Routers
# store this script in /opt/etc/init.d if you've installed optware

# Prgmname=/full_path/Prgmname
prgmname1="/usr/sbin/nmbd"
prgmname2="/usr/sbin/smbd"

# configfile=/full_path/configfile
configfile="/opt/etc/smb.conf"

#location of pid-file
nmbdpid="/var/lock/nmbd.pid"
smbdpid="/var/lock/smbd.pid"

start() {
        # Code here to start the program
        ${prgmname1} -D -s ${configfile}
        ${prgmname2} -D -s ${configfile}
        return 0
}

stop() {
        # Code here to stop the program and check it's dead
        #if [ -n "`pidof nmbd`" ]; then
        [ -f $nmbdpid ] && kill `cat $nmbdpid`
        sleep 1
        [ -f $smbdpid ] && kill `cat $smbdpid`
        return 0
}
##########################start here##########################
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        stop
        sleep 2
        start
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart}"
        exit 1
esac
sleep 1
exit
