#!/bin/sh

# PROVIDE: backuppc
# REQUIRE: DAEMON
# KEYWORD: shutdown

if [ -f /etc/rc.subr ]
then
        . /etc/rc.subr
fi

name="backuppc"
rcvar=$name
start_precmd="backuppc_precmd"
reload_cmd="backuppc_reload"
backuppc_user="backuppc"
backuppc_group="backuppc"
extra_commands="reload"
command="/usr/pkg/share/BackupPC/bin/BackupPC"
command_args="-d"
command_interpreter="/usr/pkg/bin/perl"

load_rc_config $name

backuppc_precmd() {
    mkdir -p "/var/run/BackupPC"
    chown "${backuppc_user}:${backuppc_group}" "/var/run/BackupPC"
    chmod 750 "/var/run/BackupPC"
}

backuppc_reload()
{
    pkill -1 -f "/usr/pkg/share/BackupPC/bin/BackupPC -d"
    echo "${name} reloaded"
}

run_rc_command "$1"
