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