summaryrefslogtreecommitdiff
path: root/frontends/etc/rc.d/dserver.tpl
blob: 76e79a57dffbfba1e50ba2eddeffa725e414974d (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
#!/bin/ksh

daemon="/usr/local/bin/dserver"
daemon_flags="-cfg /etc/dserver/dtail.json"
daemon_user="_dserver"

. /etc/rc.d/rc.subr

rc_reload=NO
# dserver does not daemonize itself — let rc.subr start it in the background
# (rc_bg) instead of backgrounding the whole rc_cmd invocation, which would
# hide rc_pre failures and the start result from rcctl.
rc_bg=YES

rc_pre() {
    # /var/run is wiped by /etc/rc at boot — recreate the runtime dirs and
    # repopulate the SSH key cache on every service start (a daily cron job
    # keeps it fresh afterwards). The SSH host key lives in persistent
    # /var/db/dserver so it survives reboots (a regenerated host key would
    # break clients' known_hosts).
    # install -d applies -o only to the final directory, so create the
    # parent /var/run/dserver (the _dserver home dir) explicitly with the
    # right ownership instead of letting it appear implicitly as root:wheel.
    install -d -o _dserver /var/log/dserver
    install -d -o _dserver /var/run/dserver
    install -d -o _dserver /var/run/dserver/cache
    install -d -o _dserver -m 0700 /var/db/dserver
    if [ -x /usr/local/bin/dserver-update-key-cache.sh ]; then
        /usr/local/bin/dserver-update-key-cache.sh
    fi
}

rc_cmd "$1"