Created
August 4, 2010 22:12
-
-
Save dtjm/508889 to your computer and use it in GitHub Desktop.
A patched init script for vsftpd that will create PID files under /var/run/vsftpd. If you have a configuration file /etc/vsftpd/vsftpd-foo.conf, it will create the PID file /var/run/vsftpd/vsftpd-foo.pid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment