]>
Commit | Line | Data |
---|---|---|
e61da7a2 AM |
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 | ||
66b65574 AM |
15 | PURE_FTPD_CONF=/etc/ftpd/pureftpd.conf |
16 | [ -f /etc/pure-ftpd/conf/pureftpd.conf ] && PURE_FTPD_CONF=/etc/pure-ftpd/conf/pureftpd.conf | |
17 | ||
23e4e26e | 18 | PURE_AUTH_SCRIPT=/etc/pure-ftpd/authd/auth.script |
cc332e9f | 19 | PURE_AUTH_SOCKET=/var/run/pure-authd/socket |
23e4e26e | 20 | PURE_CERT_SCRIPT=/etc/pure-ftpd/certd/cert.script |
c91bab60 | 21 | PURE_CERT_SOCKET=/var/run/pure-certd/socket |
cc332e9f | 22 | |
e61da7a2 AM |
23 | # Get service config |
24 | [ -f /etc/sysconfig/pure-ftpd ] && . /etc/sysconfig/pure-ftpd | |
25 | ||
26 | # Check that networking is up. | |
8d60cf00 | 27 | if is_yes "${NETWORKING}"; then |
8e007219 | 28 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then |
8d60cf00 | 29 | msg_network_down pure-ftpd |
30 | exit 1 | |
31 | fi | |
32 | else | |
33 | exit 0 | |
e61da7a2 AM |
34 | fi |
35 | ||
c4fc8677 | 36 | start() { |
e61da7a2 | 37 | # Check if the service is already running? |
8d60cf00 | 38 | if [ ! -f /var/lock/subsys/pure-ftpd ]; then |
cc332e9f AM |
39 | RETVAL=0 |
40 | if [ -x "$PURE_AUTH_SCRIPT" ]; then | |
41 | PURE_AUTH=yes | |
42 | msg_starting pure-authd | |
c91bab60 | 43 | |
cc332e9f | 44 | # 326/326 - authd/authd |
c91bab60 | 45 | |
cc332e9f AM |
46 | mkdir -p /var/run/pure-authd |
47 | chown ftpauth:root /var/run/pure-authd | |
48 | chmod 750 /var/run/pure-authd | |
c91bab60 | 49 | |
cc332e9f AM |
50 | daemon /usr/sbin/pure-authd --uid 326 --gid 326 --pid /var/run/pure-authd.pid \ |
51 | --run "$PURE_AUTH_SCRIPT" --socket "$PURE_AUTH_SOCKET" --daemonize | |
2b83cc9c | 52 | RETVAL=$? |
53 | fi | |
c91bab60 AM |
54 | if [ $RETVAL -eq 0 -a -x "$PURE_CERT_SCRIPT" ]; then |
55 | PURE_CERT=yes | |
56 | msg_starting pure-certd | |
57 | ||
58 | # 335/335 - certd/certd | |
59 | ||
60 | mkdir -p /var/run/pure-certd | |
61 | chown ftpcert:root /var/run/pure-certd | |
62 | chmod 750 /var/run/pure-certd | |
63 | ||
64 | daemon /usr/sbin/pure-certd --uid 335 --gid 335 --pid /var/run/pure-certd.pid \ | |
65 | --run "$PURE_CERT_SCRIPT" --socket "$PURE_CERT_SOCKET" --daemonize | |
66 | RETVAL=$? | |
c91bab60 | 67 | fi |
cc332e9f AM |
68 | if [ $RETVAL -eq 0 ]; then |
69 | msg_starting pure-ftpd | |
70 | rm -f /var/run/pure-ftpd/client* | |
796cd365 | 71 | modprobe -s capability > /dev/null 2>&1 |
66b65574 | 72 | daemon /usr/sbin/pure-ftpd ${PURE_FTPD_CONF} \ |
796cd365 | 73 | $([ "$PURE_AUTH" = "yes" ] && echo "-lextauth:$PURE_AUTH_SOCKET") \ |
23e4e26e | 74 | $([ "$PURE_CERT" = "yes" ] && echo "--extcert=$PURE_CERT_SOCKET") \ |
796cd365 AM |
75 | --daemonize |
76 | RETVAL=$? | |
c91bab60 | 77 | |
cc332e9f AM |
78 | if [ -n "$UPLOADSCRIPT" ]; then |
79 | msg_starting pure-uploadscript | |
80 | UPLOADSCRIPTOPTS="-B -r $UPLOADSCRIPT" | |
81 | [ -n "$UPLOADSCRIPT_UID" ] && UPLOADSCRIPTOPTS="$UPLOADSCRIPTOPTS -u $UPLOADSCRIPT_UID" | |
82 | [ -n "$UPLOADSCRIPT_GID" ] && UPLOADSCRIPTOPTS="$UPLOADSCRIPTOPTS -g $UPLOADSCRIPT_GID" | |
83 | daemon /usr/sbin/pure-uploadscript $UPLOADSCRIPTOPTS | |
84 | RETVAL=$(($RETVAL+$?)) | |
85 | fi | |
c91bab60 AM |
86 | else |
87 | msg_starting pure-ftpd | |
88 | deltext | |
89 | fail | |
b99c8afc | 90 | fi |
91 | ||
8d60cf00 | 92 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pure-ftpd |
e61da7a2 | 93 | else |
8d60cf00 | 94 | msg_already_running pure-ftpd |
e61da7a2 | 95 | fi |
c4fc8677 ER |
96 | } |
97 | ||
98 | stop() { | |
8d60cf00 | 99 | # Stop daemons. |
e61da7a2 | 100 | if [ -f /var/lock/subsys/pure-ftpd ]; then |
b99c8afc | 101 | if [ -n "$UPLOADSCRIPT" ]; then |
102 | msg_stopping pure-uploadscript | |
103 | killproc pure-uploadscript | |
104 | fi | |
105 | ||
cc332e9f AM |
106 | if [ -x "$PURE_AUTH_SCRIPT" -o -r /var/run/pure-authd.pid ]; then |
107 | msg_stopping pure-authd | |
108 | killproc pure-authd | |
109 | fi | |
110 | ||
c91bab60 AM |
111 | if [ -x "$PURE_CERT_SCRIPT" -o -r /var/run/pure-certd.pid ]; then |
112 | msg_stopping pure-certd | |
113 | killproc pure-certd | |
114 | fi | |
115 | ||
8d60cf00 | 116 | msg_stopping pure-ftpd |
117 | killproc pure-ftpd | |
b99c8afc | 118 | |
8d60cf00 | 119 | rm -f /var/lock/subsys/pure-ftpd > /dev/null 2>&1 |
120 | else | |
121 | msg_not_running pure-ftpd | |
e61da7a2 | 122 | fi |
c4fc8677 ER |
123 | } |
124 | ||
125 | RETVAL=0 | |
126 | # See how we were called. | |
127 | case "$1" in | |
128 | start) | |
129 | start | |
130 | ;; | |
131 | stop) | |
132 | stop | |
e61da7a2 AM |
133 | ;; |
134 | status) | |
135 | status pure-ftpd | |
b99c8afc | 136 | status pure-uploadscript |
e61da7a2 AM |
137 | RETVAL=$? |
138 | if [ $RETVAL -eq 0 ]; then | |
8d60cf00 | 139 | pure-ftpwho |
e61da7a2 | 140 | fi |
e61da7a2 | 141 | ;; |
40382493 | 142 | restart|force-reload) |
c4fc8677 ER |
143 | stop |
144 | start | |
e61da7a2 AM |
145 | ;; |
146 | *) | |
40382493 | 147 | msg_usage "$0 {start|stop|restart|force-reload|status}" |
148 | exit 3 | |
e61da7a2 AM |
149 | ;; |
150 | esac | |
151 | ||
152 | exit $RETVAL |