]> git.pld-linux.org Git - packages/pure-ftpd.git/blame - pure-ftpd.init
- use functions
[packages/pure-ftpd.git] / pure-ftpd.init
CommitLineData
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
15# Get service config
16[ -f /etc/sysconfig/pure-ftpd ] && . /etc/sysconfig/pure-ftpd
17
2b83cc9c 18# Check for available parsers
19if [ -x /usr/sbin/pure-config ] ; then
20 CFG=/usr/sbin/pure-config
81c4c6f8 21elif [ -x /usr/sbin/pure-config.pl -a -x /usr/bin/perl ] ; then
2b83cc9c 22 CFG=/usr/sbin/pure-config.pl
23elif [ -x /usr/sbin/pure-config.py -a -x /usr/bin/python ] ; then
24 CFG=/usr/sbin/pure-config.py
25else
37028358 26 echo 'Error: pure-config{,.pl,.py} not found. Giving up.'
2b83cc9c 27 exit 1
81c4c6f8 28fi
2b83cc9c 29
e61da7a2 30# Check that networking is up.
8d60cf00 31if is_yes "${NETWORKING}"; then
8e007219 32 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
8d60cf00 33 msg_network_down pure-ftpd
34 exit 1
35 fi
36else
37 exit 0
e61da7a2
AM
38fi
39
c4fc8677 40start() {
e61da7a2 41 # Check if the service is already running?
8d60cf00 42 if [ ! -f /var/lock/subsys/pure-ftpd ]; then
e61da7a2 43 msg_starting pure-ftpd
469b4406 44 rm -f /var/run/pure-ftpd/client*
2b83cc9c 45 if [ x"$CFG" = "x/usr/sbin/pure-config" ] ; then
46 daemon /usr/sbin/pure-ftpd \
47 $(/usr/sbin/pure-config -f /etc/ftpd/pureftpd.conf) \
48 --daemonize
49 RETVAL=$?
50 else
51 daemon $CFG /etc/ftpd/pureftpd.conf --daemonize
52 RETVAL=$?
53 fi
b99c8afc 54
55 if [ -n "$UPLOADSCRIPT" ]; then
56 msg_starting pure-uploadscript
57 UPLOADSCRIPTOPTS="-B -r $UPLOADSCRIPT"
58 [ -n "$UPLOADSCRIPT_UID" ] && UPLOADSCRIPTOPTS="$UPLOADSCRIPTOPTS -u $UPLOADSCRIPT_UID"
59 [ -n "$UPLOADSCRIPT_GID" ] && UPLOADSCRIPTOPTS="$UPLOADSCRIPTOPTS -g $UPLOADSCRIPT_GID"
60 daemon /usr/sbin/pure-uploadscript $UPLOADSCRIPTOPTS
61 RETVAL=$(($RETVAL+$?))
62 fi
63
8d60cf00 64 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pure-ftpd
e61da7a2 65 else
8d60cf00 66 msg_already_running pure-ftpd
e61da7a2 67 fi
c4fc8677
ER
68}
69
70stop() {
8d60cf00 71 # Stop daemons.
e61da7a2 72 if [ -f /var/lock/subsys/pure-ftpd ]; then
b99c8afc 73 if [ -n "$UPLOADSCRIPT" ]; then
74 msg_stopping pure-uploadscript
75 killproc pure-uploadscript
76 fi
77
8d60cf00 78 msg_stopping pure-ftpd
79 killproc pure-ftpd
b99c8afc 80
8d60cf00 81 rm -f /var/lock/subsys/pure-ftpd > /dev/null 2>&1
82 else
83 msg_not_running pure-ftpd
e61da7a2 84 fi
c4fc8677
ER
85}
86
87RETVAL=0
88# See how we were called.
89case "$1" in
90 start)
91 start
92 ;;
93 stop)
94 stop
e61da7a2
AM
95 ;;
96 status)
97 status pure-ftpd
b99c8afc 98 status pure-uploadscript
e61da7a2
AM
99 RETVAL=$?
100 if [ $RETVAL -eq 0 ]; then
8d60cf00 101 pure-ftpwho
e61da7a2 102 fi
e61da7a2 103 ;;
40382493 104 restart|force-reload)
c4fc8677
ER
105 stop
106 start
e61da7a2
AM
107 ;;
108 *)
40382493 109 msg_usage "$0 {start|stop|restart|force-reload|status}"
110 exit 3
e61da7a2
AM
111 ;;
112esac
113
114exit $RETVAL
This page took 0.095139 seconds and 4 git commands to generate.