#! /bin/sh
#
# startfile for built in vsftpd, 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
prgmname="/usr/sbin/vsftpd"
shortname="vsftpd"

#configfile=/full_path/configfile or in case of needed options: "-D -s /opt/etc/smb.conf"
configfile="/opt/etc/vsftpd.conf"

#location of pid-file, if any, configure stop function of this script  
#pidfile="/var/lock/vsftpd.pid"

###########################End of Script configuration###################

start() {
        # Code here to start the program
        ${prgmname} ${configfile}
        logger -t $shortname "$prgmname started with config from $configfile"
        return 0
}

stop() {
        # Code here to stop the program and check it's dead
        if [ -n "`pidof $shortname`" ]; then
        killall $shortname
        logger -t $shortname "$prgmname stopped"
        fi
        return 0
}
##########################start here##########################
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        logger -t $shortname "Restart of $prgmname, executed from $(whoami)"
        stop
        sleep 2
        start
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart}"
        exit 1
esac
sleep 1
exit
