summaryrefslogtreecommitdiffstats
path: root/generic/etc/init.d/proftpd
blob: 3f408d6b8f6e0fcba7ed1548c53bc309b154a8b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/sh
#
# /etc/init.d/proftpd
# Start the proftpd FTP daemon.
# 

PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/usr/sbin/proftpd
NAME=proftpd

# Defaults
RUN="no"
OPTIONS=""

PIDFILE=`grep -i 'pidfile' /etc/proftpd.conf | awk '{print($2)}'`
if [ "x$PIDFILE" = "x" ];
then
	PIDFILE=/var/run/proftpd.pid
fi

# Read config (will override defaults)
[ -r /etc/default/proftpd ] && . /etc/default/proftpd

trap "" 1
trap "" 15

test -f $DAEMON || exit 0

#
# Servertype could be inetd|standalone.
#
if egrep -qi "^[[:space:]]*ServerType.*standalone" /etc/proftpd.conf
then
	RUN="yes"
fi

start(){
  $DAEMON $OPTIONS
}

stop(){
if [ -e "$PIDFILE" ]; then
  kill `cat $PIDFILE` || { kill -9 `cat $PIDFILE` ; echo "process killed" ; rm -f $PIDFILE; echo "pidfile removed"; }
else
  echo "pid file not found - process not running"
fi
}

case "$1" in
    start)
	if [ "x$RUN" = "xyes" ] ; then
	    echo -n "Starting ProFTPD ftp daemon: "
	    start 
	    echo "Done"
	else
	    	echo "ProFTPd is configured to be started from inetd. Check your configuration."
	fi
	;;

    stop)
	if [ "x$RUN" = "xyes" ] ; then
	    echo -n "Stopping ProFTPD ftp daemon: "
	    stop
	    echo "Done"
	else
		echo "ProFTPd is configured to be started from inetd. Check your configuration."
	fi
	;;

    reload)
	echo -n "Reloading $NAME configuration..."
	if [ -e "$PIDFILE" ]; then                                                                                           
	   kill -HUP `cat $PIDFILE`
	   echo " done."
	else
	   echo "pid file not found - process not running" 
	fi
	;;

    force-reload|restart)
	if [ "x$RUN" = "xyes" ] ; then
	    echo -n "Restarting ProFTPD ftp daemon."
	    stop
	    echo -n "."
	    sleep 2
	    echo -n "."
	    start
	    echo " done."
	else
		echo "ProFTPd is configured to be started from inetd. Check your configuration."
	fi
	;;

    *)
	echo "Usage: /etc/init.d/$NAME {start|stop|reload|restart|force-reload|help}"
	exit 1
	;;
esac

exit 0