aboutsummaryrefslogtreecommitdiff
path: root/src/backuppc/backuppc.rc
blob: f3b4a027a2c7430ebd34d59a2bdea27b804ae887 (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
50
51
52
53
54
#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions
. /etc/conf.d/${0##*/}

DAEMON=/usr/share/backuppc/bin/BackupPC

PIDFILE=${PIDFILE:-/var/log/backuppc/BackupPC.pid}
DAEMON_OPTS=${DAEMON_OPTS:--d}
DAEMON_USER=${DAEMON_USER:-backuppc}
DAEMON_GROUP=${DAEMON_GROUP:-nobody}

case "$1" in
  start)
    stat_busy "Starting ${0##*/} daemon"
    if start-stop-daemon --start --quiet --pidfile "$PIDFILE" \
      -c $DAEMON_USER -g $DAEMON_GROUP --startas $DAEMON -- \
      $DAEMON_OPTS; then
        stat_done
        add_daemon ${0##*/}
        exit 0
    else
        stat_fail
        exit 1
    fi
  ;;
  stop)
    stat_busy "Stopping ${0##*/} daemon"
    if start-stop-daemon --stop --quiet --pidfile "$PIDFILE"; then
      rm_daemon ${0##*/}
      rm "$PIDFILE"
      stat_done
      exit 0
    else
      stat_fail
      exit 1
    fi
  ;;
  reload)
    stat_busy "Reloading ${0##*/} dameon"
    start-stop-daemon --stop --signal HUP --quiet --pidfile "$PIDFILE" \
      && { stat_done; exit 0; } || { stat_fail; exit 1; }
  ;;
  restart)
    $0 stop && sleep 2
    $0 start
  ;;
  *)
    echo "usage: ${0##*/} {start|stop|restart}" >&2
  ;;
esac

# vim:set ts=2 sw=2 ft=sh et: