aboutsummaryrefslogtreecommitdiffhomepage
path: root/rcd/rustdesk-hbbs
blob: d9fea219ce53f2dd917c795c1e6935cb5a4036f6 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh

# PROVIDE: rustdesk_hbbs
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# rustdesk_hbbs_enable (bool):            Set to NO by default.
#               Set it to YES to enable rustdesk_hbbs.
# rustdesk_hbbs_args (string):            Set extra arguments to pass to rustdesk_hbbs
#               Default is "-r ${rustdesk_hbbs_ip} -k _".
# rustdesk_hbbs_user (string):            Set user that rustdesk_hbbs will run under
#               Default is "root".
# rustdesk_hbbs_group (string):           Set group that rustdesk_hbbs will run under
#               Default is "wheel".

. /etc/rc.subr

name=rustdesk_hbbs
desc="Rustdesk ID/Rendezvous Server"
rcvar=rustdesk_hbbs_enable

load_rc_config $name

: ${rustdesk_hbbs_enable:=NO}
: ${rustdesk_hbbs_ip:=127.0.0.1}
: ${rustdesk_hbbs_args="-r ${rustdesk_hbbs_ip} -k _"}
: ${rustdesk_hbbs_user:=rustdesk}
: ${rustdesk_hbbs_group:=rustdesk}

pidfile=/var/run/rustdesk_hbbs.pid
command=/usr/sbin/daemon
procname=/usr/local/sbin/hbbs
rustdesk_hbbs_chdir=/var/db/rustdesk-server
command_args="-p ${pidfile} -o /var/log/rustdesk-hbbs.log ${procname} ${rustdesk_hbbs_args}"
## If you want the daemon to do its log over syslog, comment out the above line and remove the comment from the below replacement
#command_args="-p ${pidfile} -T ${name} ${procname} ${rustdesk_hbbs_args}"

start_precmd=rustdesk_hbbs_startprecmd

rustdesk_hbbs_startprecmd()
{
    if [ -e ${pidfile} ]; then
        chown ${rustdesk_hbbs_user}:${rustdesk_hbbs_group} ${pidfile};
    else
        install -o ${rustdesk_hbbs_user} -g ${rustdesk_hbbs_group} /dev/null ${pidfile};
    fi
    if [ -e ${rustdesk_hbbs_chdir} ]; then
        chown -R ${rustdesk_hbbs_user}:${rustdesk_hbbs_group} ${rustdesk_hbbs_chdir};
        chmod -R 770 ${rustdesk_hbbs_chdir};
    else
        mkdir -m 770 ${rustdesk_hbbs_chdir};
        chown ${rustdesk_hbbs_user}:${rustdesk_hbbs_group} ${rustdesk_hbbs_chdir};
    fi
    if [ -e /var/log/rustdesk-hbbs.log ]; then
        chown -R ${rustdesk_hbbs_user}:${rustdesk_hbbs_group} /var/log/rustdesk-hbbs.log;
        chmod 660 /var/log/rustdesk-hbbs.log;
    else
        install -o ${rustdesk_hbbs_user} -g ${rustdesk_hbbs_group} /dev/null /var/log/rustdesk-hbbs.log;
        chmod 660 /var/log/rustdesk-hbbs.log;
    fi
}

run_rc_command "$1"