vsftpd/vsftpd.init

101 lines
2.2 KiB
Plaintext
Raw Normal View History

#!/bin/bash
#
# vsftpd This shell script takes care of starting and stopping
# standalone vsftpd. Customized to be used with CentOS 5.4
# and Monit by creating PID files for each process
#
# chkconfig: - 60 50
# description: Vsftpd is a ftp daemon, which is the program \
# that answers incoming ftp service requests.
# processname: vsftpd
# config: /etc/vsftpd/vsftpd.conf
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
pidfileFromConf() {
echo /var/run/vsftpd/`basename $1 .conf`.pid
}
pidFromConf() {
ps auxf | grep -v grep | grep $1 | awk '{print $2}'
}
RETVAL=0
prog="vsftpd"
# Create the vsftpd pid folder if it doesn't exist
[ -d /var/run/vsftpd ] || mkdir /var/run/vsftpd
start() {
# Start daemons.
[ -x /usr/sbin/vsftpd ] || exit 4
CONFS=`ls /etc/vsftpd/*.conf 2>/dev/null`
[ -z "$CONFS" ] && exit 6
for i in $CONFS; do
site=`basename $i .conf`
echo -n $"Starting $prog for $site: "
daemon /usr/sbin/vsftpd $i
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
echo
echo -n "Creating pidfile for $site: "
echo `pidFromConf $i` > `pidfileFromConf $i`
[ $? -eq 0 ] && success || failure
echo
done
return $RETVAL
}
stop() {
# Stop daemons.
echo -n $"Shutting down $prog: "
killproc $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
echo -n "Deleting pidfiles: "
rm -f /var/run/vsftpd/*.pid
[ $? -eq 0 ] && success || failure
echo
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
RETVAL=$?
;;
condrestart)
if [ -f /var/lock/subsys/$prog ]; then
stop
start
RETVAL=$?
fi
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
exit 2
esac
exit $RETVAL