1#!/bin/sh
2#
3# DESCRIPTION
4#
5#   Startup init script for BackupPC on Redhat linux.
6#
7# Distributed with BackupPC version 4.4.0, released 20 Jun 2020.
8#
9# chkconfig: - 91 35
10# description: Starts and stops the BackupPC server
11
12# Source function library.
13if [ -f /etc/init.d/functions ] ; then
14  . /etc/init.d/functions
15elif [ -f /etc/rc.d/init.d/functions ] ; then
16  . /etc/rc.d/init.d/functions
17else
18  exit 0
19fi
20
21RETVAL=0
22
23start() {
24    #
25    # You can set the SMB share password here is you wish.  Otherwise
26    # you should put it in the config.pl script.
27    # If you put it here make sure this file has no read permissions
28    # for normal users!  See the documentation for more information.
29    #
30    # Replace the daemon line below with this:
31    #
32    #  daemon --user __BACKUPPCUSER__ /usr/bin/env BPC_SMB_PASSWD=xxxxx \
33    #				__INSTALLDIR__/bin/BackupPC -d
34    #
35    echo -n "Starting BackupPC: "
36    daemon --user __BACKUPPCUSER__ __INSTALLDIR__/bin/BackupPC -d
37    RETVAL=$?
38    echo
39    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/backuppc || \
40       RETVAL=1
41    return $RETVAL
42}
43
44stop() {
45    echo -n "Shutting down BackupPC: "
46    killproc __INSTALLDIR__/bin/BackupPC
47    RETVAL=$?
48    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/backuppc
49    echo ""
50    return $RETVAL
51}
52
53restart() {
54    stop
55    start
56}
57
58reload() {
59    echo -n "Reloading config.pl file: "
60    killproc __INSTALLDIR__/bin/BackupPC -HUP
61    RETVAL=$?
62    echo
63    return $RETVAL
64}
65
66rhstatus() {
67    status __INSTALLDIR__/bin/BackupPC
68}
69
70case "$1" in
71  start)
72  	start
73	;;
74  stop)
75  	stop
76	;;
77  restart)
78  	restart
79	;;
80  reload)
81  	reload
82	;;
83  status)
84  	rhstatus
85	;;
86  *)
87	echo "Usage: $0 {start|stop|restart|reload|status}"
88	exit 1
89esac
90
91exit $?
92