#!/bin/bash # # proftpd This shell script takes care of starting and stopping # the proftpd Server (proftpd) in RedHat environments. # # description: proftpd ftp server. # processname: proftpd # mailto: proftpd_init.d@woerstenfeld.de # # Source function library. . /etc/rc.d/init.d/functions ###Config### prog="Proftpd" datadir=/www/vhosts/ftp datadir_owner=www configfile=/www/conf/proftpd.conf lockfile=/var/lock/subsys/proftpd pidfile=/var/run/proftpd/proftpd.pid ###Script### start(){ /usr/local/sbin/proftpd -t -c $configfile # >/dev/null 2>&1 & ret=$? if [ $ret -eq 0 ]; then action $"Pruefe $prog Konfiguration: " /bin/true if [ ! -d $datadir ] ; then action $"Suche $prog-Daten-Verzeichnis ($datadir) : " /bin/false ret=$? if [ $ret -ne 0 ] ; then return $ret fi fi chown -R $datadir_owner $datadir chmod 0755 $datadir if [ -a $lockfile ] ; then action $"Starte $prog ($prog laueft schon!): " /bin/false else /usr/local/sbin/proftpd -c $configfile >/dev/null 2>&1 ret=$? if [ $ret -eq 0 ]; then touch $lockfile action $"Starte $prog: " /bin/true else action $"Starte $prog: " /bin/false fi fi else action $"Pruefe $prog Konfiguration: " /bin/false fi } stop(){ if [ -a $lockfile ] ; then /bin/kill `cat $pidfile 2> /dev/null ` > /dev/null 2>&1 ret=$? if [ $ret -eq 0 ]; then action $"Stoppe $prog: " /bin/true else action $"Stoppe $prog: " /bin/false fi /bin/rm -f $lockfile >/dev/null 2>&1 & else action $"Stoppe $prog: " /bin/false fi } restart(){ stop start } status(){ if [ -a $lockfile ] ; then echo "Prozesse:" /bin/ps -ef |/bin/grep proftpd |/bin/grep -v bash |/bin/grep -v grep echo "Verbindungen:" /usr/local/bin/ftpwho -v else action $"$prog laeuft nicht! - Status: " /bin/false ret=$? if [ $ret -ne 0 ] ; then return $ret fi fi } reload() { /usr/local/sbin/proftpd -t -c $configfile # >/dev/null 2>&1 & ret=$? if [ $ret -eq 0 ]; then action $"Pruefe $prog Konfiguration: " /bin/true if [ -a $lockfile ] ; then /bin/kill -SIGHUP `cat $pidfile 2> /dev/null` > /dev/null 2>&1 ret=$? if [ $ret -eq 0 ]; then action $"Lade $prog Konfiguration neu: " /bin/true else action $"Lade $prog Konfiguration neu: " /bin/false fi else action $"$prog laeuft nicht! - Status: " /bin/false ret=$? if [ $ret -ne 0 ] ; then return $ret fi fi else action $"Pruefe $prog Konfiguration: " /bin/false fi } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status ;; restart) restart ;; reload) reload ;; *) echo $"Usage: $0 {start|stop|status|restart|reload}" exit 1 esac exit $?