]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | # | |
3 | # pureftpd PureFTPD server | |
4 | # | |
5 | # chkconfig: 345 85 15 | |
6 | # description: PureFTPD is fast, production-quality, standard-conformant FTP server | |
7 | # | |
8 | ||
9 | # Source function library | |
10 | . /etc/rc.d/init.d/functions | |
11 | ||
12 | # Get network config | |
13 | . /etc/sysconfig/network | |
14 | ||
15 | # Get service config | |
16 | [ -f /etc/sysconfig/pure-ftpd ] && . /etc/sysconfig/pure-ftpd | |
17 | ||
18 | # Check for available parsers | |
19 | if [ -x /usr/sbin/pure-config ] ; then | |
20 | CFG=/usr/sbin/pure-config | |
21 | elif [ -x /usr/sbin/pure-config.pl -a -x /usr/bin/perl ] ; then | |
22 | CFG=/usr/sbin/pure-config.pl | |
23 | elif [ -x /usr/sbin/pure-config.py -a -x /usr/bin/python ] ; then | |
24 | CFG=/usr/sbin/pure-config.py | |
25 | else | |
26 | echo 'Error: pure-config{,.pl,.py} not found. Giving up.' | |
27 | exit 1 | |
28 | fi | |
29 | ||
30 | # Check that networking is up. | |
31 | if is_yes "${NETWORKING}"; then | |
32 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then | |
33 | msg_network_down pure-ftpd | |
34 | exit 1 | |
35 | fi | |
36 | else | |
37 | exit 0 | |
38 | fi | |
39 | ||
40 | start() { | |
41 | # Check if the service is already running? | |
42 | if [ ! -f /var/lock/subsys/pure-ftpd ]; then | |
43 | msg_starting pure-ftpd | |
44 | rm -f /var/run/pure-ftpd/client* | |
45 | if [ x"$CFG" = "x/usr/sbin/pure-config" ] ; then | |
46 | modprobe -s capability > /dev/null 2>&1 | |
47 | daemon /usr/sbin/pure-ftpd \ | |
48 | $(/usr/sbin/pure-config -f /etc/ftpd/pureftpd.conf) \ | |
49 | --daemonize | |
50 | RETVAL=$? | |
51 | else | |
52 | daemon $CFG /etc/ftpd/pureftpd.conf --daemonize | |
53 | RETVAL=$? | |
54 | fi | |
55 | ||
56 | if [ -n "$UPLOADSCRIPT" ]; then | |
57 | msg_starting pure-uploadscript | |
58 | UPLOADSCRIPTOPTS="-B -r $UPLOADSCRIPT" | |
59 | [ -n "$UPLOADSCRIPT_UID" ] && UPLOADSCRIPTOPTS="$UPLOADSCRIPTOPTS -u $UPLOADSCRIPT_UID" | |
60 | [ -n "$UPLOADSCRIPT_GID" ] && UPLOADSCRIPTOPTS="$UPLOADSCRIPTOPTS -g $UPLOADSCRIPT_GID" | |
61 | daemon /usr/sbin/pure-uploadscript $UPLOADSCRIPTOPTS | |
62 | RETVAL=$(($RETVAL+$?)) | |
63 | fi | |
64 | ||
65 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pure-ftpd | |
66 | else | |
67 | msg_already_running pure-ftpd | |
68 | fi | |
69 | } | |
70 | ||
71 | stop() { | |
72 | # Stop daemons. | |
73 | if [ -f /var/lock/subsys/pure-ftpd ]; then | |
74 | if [ -n "$UPLOADSCRIPT" ]; then | |
75 | msg_stopping pure-uploadscript | |
76 | killproc pure-uploadscript | |
77 | fi | |
78 | ||
79 | msg_stopping pure-ftpd | |
80 | killproc pure-ftpd | |
81 | ||
82 | rm -f /var/lock/subsys/pure-ftpd > /dev/null 2>&1 | |
83 | else | |
84 | msg_not_running pure-ftpd | |
85 | fi | |
86 | } | |
87 | ||
88 | RETVAL=0 | |
89 | # See how we were called. | |
90 | case "$1" in | |
91 | start) | |
92 | start | |
93 | ;; | |
94 | stop) | |
95 | stop | |
96 | ;; | |
97 | status) | |
98 | status pure-ftpd | |
99 | status pure-uploadscript | |
100 | RETVAL=$? | |
101 | if [ $RETVAL -eq 0 ]; then | |
102 | pure-ftpwho | |
103 | fi | |
104 | ;; | |
105 | restart|force-reload) | |
106 | stop | |
107 | start | |
108 | ;; | |
109 | *) | |
110 | msg_usage "$0 {start|stop|restart|force-reload|status}" | |
111 | exit 3 | |
112 | ;; | |
113 | esac | |
114 | ||
115 | exit $RETVAL |