document new archive host ASA extension
[BackupPC.git] / init.d / src / freebsd-backuppc
1 #!/bin/sh
2
3 # PROVIDE: backuppc
4 # REQUIRE: DAEMON
5 # BEFORE:  LOGIN
6 # KEYWORD: shutdown
7
8 #
9 # Copy to /usr/local/etc/rc.d/backuppc and make execuatble
10 #
11 # Add the following line to /etc/rc.conf to enable BackupPC:
12 # backuppc_enable=(bool):   Set to "NO" by default.
13 #                           Set it to "YES" to enable BackupPC.
14 #
15 # Example:
16 #
17 #       backuppc_enable="YES"
18 #
19 # It accepts : start, stop, restart, reload, status
20 #
21 # Provided by : Gabriel Rossetti
22 #
23
24 . /etc/rc.subr
25
26 name="backuppc"
27 rcvar=`set_rcvar`
28 start_cmd="backuppc_start"
29 restart_cmd="backuppc_restart"
30 stop_cmd="backuppc_stop"
31 status_cmd="backuppc_status"
32 reload_cmd="backuppc_reload"
33
34 load_rc_config $name
35 eval "${rcvar}=\${${rcvar}:-'NO'}"
36
37 : ${backuppc_enable="NO"}
38 #backuppc_enable=${backuppc_enable:-"NO"}
39
40 backuppc_start()
41 {
42     su backuppc -c '__INSTALLDIR__/bin/BackupPC -d'
43     echo "${name} started"
44 }
45
46 backuppc_restart()
47 {
48     backuppc_stop
49     sleep 1
50     backuppc_start
51 }
52
53 backuppc_stop()
54 {
55     /usr/bin/pkill -f "__INSTALLDIR__/bin/BackupPC -d"
56     echo "${name} stopped"
57 }
58
59 backuppc_status()
60 {
61     if [ "`ps ax | grep "BackupPC -d" | grep perl`" = "" ] ; then
62         echo "${name} not running"
63     else
64         echo "${name} running"
65     fi
66 }    
67
68 backuppc_reload()
69 {
70     /usr/bin/pkill -1 -f "__INSTALLDIR__/bin/BackupPC -d"
71     echo "${name} reloaded"
72 }
73
74 extra_commands="reload status"
75 run_rc_command "$1"