Current File : //etc/rc3.d/S50pure-ftpd
#!/bin/bash
#
# Startup script for the pure-ftpd FTP Server  $Revision: 1.1 $
#
# chkconfig: - 85 15
# description: Pure-FTPd is an FTP server daemon based upon Troll-FTPd
# processname: pure-ftpd
# pidfile: /var/run/pure-ftpd.pid
# config: /etc/pure-ftpd/pure-ftpd.conf

### BEGIN INIT INFO
# Provides: pure-ftpd Server
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and Stop pure-ftpd Server
### END INIT INFO
# Source function library.

# Source networking configuration.

# Check that networking is configured.

RETVAL=0

prog="pure-ftpd"

# Path to the pure-ftp binaries.
fullpath=/usr/local/apps/pureftpd/sbin
pureftpwho=/usr/local/apps/pureftpd/sbin/pure-ftpwho
pure_config=/usr/local/apps/pureftpd/etc/pure-ftpd.conf
pid_file=/usr/local/apps/pureftpd/etc/pure-ftpd.pid
pure_launch_script=/usr/local/apps/pureftpd/sbin/pure-config.pl
lockfile=/var/lock/subsys/pure-ftpd


start() {
    echo -n $"Starting $prog: "
	if [ ! -f $pid_file ] ; then
    perl $pure_launch_script $pure_config --daemonize > /dev/null
    RETVAL=$?
        if [ $? = 0 ]; then
            if [ -d /var/lock/subsys ] ; then
                touch $lockfile 
            fi
            touch $pid_file
    		echo "[ OK ]"
        fi
	else
    	echo "$prog already running..."
    fi
    return 0          
}

stop() {
    echo -n $"Stopping $prog: "
    if [ -f $pid_file ] ; then
        PID=`cat $pid_file`
        kill $PID > /dev/null 2>&1
        if [ -f $lockfile ] ; then
			rm -rf $lockfile
		fi        
        sleep 1
        rm -rf $pid_file
        echo "[ OK ]"
    else
        echo "$prog stopped"
    fi
    return 0
}

# See how we were called.
case "$1" in
    start)
            start
            ;;
    stop)
            stop
            ;;
    restart)
            stop
            start
            ;;
    condrestart)
            if [ -f /var/lock/subsys/pure-ftpd ] ; then
                    stop
                    # avoid race
                    sleep 3
                    start
            fi
            ;;
    status) 
		if [ -f $pid_file ] && [ -f $lockfile ] ; then
			PID=`cat $pid_file`
			echo "$prog (pid $PID) is running..."
			if [ -f $pureftpwho ] ; then
				$pureftpwho
			fi
		else
			echo "$prog stopped"
		fi
		;;
    *)
            echo $"Usage: pure-ftpd {start|stop|restart|reload|condrestart|status}"
            RETVAL=1
esac
exit $RETVAL