summaryrefslogtreecommitdiff
path: root/chat/znc/files/znc.sh
blob: b5deb917f19e5febe07bac566bc168c3748461a3 (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
#!/bin/sh
#
# $NetBSD: znc.sh,v 1.1 2018/12/16 02:05:24 nia Exp $
#
# RC-script for znc 1.0
#

# PROVIDE: znc
# REQUIRE: NETWORKING
# KEYWORD: shutdown

${_rc_subr_loaded} . /etc/rc.subr

name="znc"
rcvar="${name}"
command="@PREFIX@/bin/${name}"
saveconf_cmd="${name}_saveconf"
makeconf_cmd="${name}_makeconf"

conf_dir="@PKG_SYSCONFDIR@"
conf_file="${conf_dir}/configs/${name}.conf"

sig_saveconf="-USR1"

required_files="${conf_file}"
extra_commands="reload saveconf makeconf"
command_args="-d ${conf_dir}"

znc_saveconf(){
        pids="$(check_process ${command})"
        if [ -n "$pids" ]; then
                echo -n "Saving znc config files"
                for pid in $pids; do
                        kill $sig_saveconf $pid
                done
                echo "."
        fi
}

znc_makeconf(){
	su -m ${znc_user} -c ${command} -d ${conf_dir} -r --makeconf
}

load_rc_config "${name}"
run_rc_command "${1}"