summaryrefslogtreecommitdiff
path: root/network/pure-ftpd/config/rc.pure-ftpd
blob: e7ef9434abf00e1e70c0cb7f0687d7da9fa8b8bf (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
#!/bin/sh
# Start/stop/restart pure-ftpd ftp daemon

configfile=/etc/pure-ftpd/pure-ftpd.conf
pidfile=/var/run/pure-ftpd.pid

pureftpd_start() {
  if [ -x /usr/sbin/pure-ftpd -a -r "$configfile" ]; then
    echo "Starting pure-ftpd daemon: "
    echo "/usr/sbin/pure-ftpd $configfile"
    /usr/sbin/pure-ftpd $configfile
  fi
}

pureftpd_stop() {
  killall pure-ftpd 2> /dev/null
  /usr/bin/rm $pidfile 2> /dev/null
}

pureftpd_restart() {
  if [ -r "$pidfile" ]; then
    echo "WARNING: killing listener process only.  To kill every pure-ftpd process, you must"
    echo "         use 'rc.pure-ftpd stop'.  'rc.pure-ftpd restart' kills only the parent pure-ftpd"
    echo "         to preserve existing connections. If pure-ftpd has been upgraded, new connections"
    echo "         will now use the new version, which should be a safe enough approach."
    kill `cat $pidfile`
  else
    echo "WARNING: There does not appear to be a parent instance of pure-ftpd running."
    echo "         If you really want to kill all running instances of pure-ftpd (including"
    echo "         any sessions currently in use), run '/etc/rc.d/rc.pure-ftpd stop' instead."
    exit 1
  fi
  sleep 1
  pureftpd_start
}

case "$1" in
'start')
  pureftpd_start
  ;;
'stop')
  pureftpd_stop
  ;;
'restart')
  pureftpd_restart
  ;;
*)
  echo "usage $0 start|stop|restart"
esac