-
Notifications
You must be signed in to change notification settings - Fork 727
/
teleirc.in
58 lines (49 loc) · 1.64 KB
/
teleirc.in
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
55
56
57
58
#!/bin/sh
# PROVIDE: teleirc
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Configuration settings for teleirc in /etc/rc.conf
#
# teleirc_enable (bool): Enable teleirc. (Default=NO)
# teleirc_conf (str): Teleirc configuration file. (Default=%%PREFIX%%/etc/teleirc.conf)
# teleirc_flags (str): Flags used for teleirc. (Default=-conf ${teleirc_conf})
# teleirc_logfile (str): Log file used for teleirc. (Default=/var/log/teleirc.log)
# teleirc_program (str): Path to teleirc application. (Default=%%PREFIX%%/bin/teleirc)
# teleirc_username (str): User to run teleirc as. (Default=teleirc)
# teleirc_restart_delay_seconds (int): Supervise and restart teleirc after the specified delay if it
# has been terminated. (Default=30)
. /etc/rc.subr
name="teleirc"
desc="Bridge between IRC and Telegram"
rcvar="teleirc_enable"
start_cmd="teleirc_start"
restart_cmd="teleirc_restart"
procname=/usr/sbin/daemon
load_rc_config $name
: ${teleirc_enable:=NO}
: ${teleirc_conf:=%%PREFIX%%/etc/teleirc.conf}
: ${teleirc_flags=-conf "${teleirc_conf}"}
: ${teleirc_logfile:=/var/log/teleirc.log}
: ${teleirc_program:=%%PREFIX%%/bin/teleirc}
: ${teleirc_username:=teleirc}
: ${teleirc_restart_delay_seconds:=30}
: ${teleirc_pidfile:=/var/run/teleirc.pid}
pidfile="${teleirc_pidfile}"
teleirc_start()
{
echo "Starting ${name}." && sleep 1
${procname} \
-t "${desc}" \
-R "${teleirc_restart_delay_seconds}" \
-u "${teleirc_username}" \
-o "${teleirc_logfile}" \
-P "${pidfile}" \
${teleirc_program} ${teleirc_flags}
}
teleirc_restart()
{
run_rc_command stop &&
run_rc_command start
}
run_rc_command "$1"