#!/bin/bash
#by:key1088
#description:vsftpd
#conf:/etc/vsftpd/vsftp.conf
#cp vsftpd /etc/init.d/vsftpd
#chmod 755 /etc/init.d/vsftpd
#chkconfig --add vsftpd
#chkconfig vsftpd on
if [ -f /etc/init.d/functions ]
then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ]
then
. /etc/rc.d/init.d/functions
else
exit 0
fi
vsftpd=/usr/local/sbin/vsftpd
ftpconf=/etc/vsftpd/vsftpd.conf
prog=vsftpd
RETVAL=0
start() {
if [ -n "`/sbin/pidof $prog`" ]
then
echo "$prog: already running"
return 1
fi
echo "Starting $prog:"
base=$prog
$vsftpd $ftpconf&
if [ -z "`/sbin/pidof $prog`" ]
then
RETVAL=1
fi
if [ $RETVAL -ne 0 ]
then
echo "Startup failure"
else
echo "Startup success"
fi
return $RETVAL
}
stop() {
if [ -z "`/sbin/pidof $prog`" ]
then
RETVAL=1
fi
if [ $RETVAL -ne 0 ]
then
echo "vsftpd no have run"
else
echo "Stopping $prog:"
killall $vsftpd
RETVAL=$?
if [ $RETVAL -ne 0 ]
then
echo "Shutdown failure"
else
echo "Shutdown success"
fi
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $vsftpd
RETVAL=$?
;;
restart)
stop
start
;;
*)
echo "Usage: $prog {start|stop|restart|status}"
exit 1
esac
exit $RETVAL