summaryrefslogtreecommitdiff
path: root/sysutils/goaccess/files/goaccess.in
blob: 6c7bd146b66d462d77660ca59a78fadc456592ea (plain) (blame)
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
#!/bin/sh

# PROVIDE: goaccess
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# To enable the goaccess daemon, add `goaccess_enable="YES"`' to
# your /etc/rc.conf or /etc/rc.conf.local
#
# Optional settings:
# goaccess_html (path):   Output file (/var/run/goaccess/goaccess.html)
# goaccess_log (path):    Input log   (/var/log/httpd-access.log)
# goaccess_config (path): Default: %%ETCDIR%%/goaccess.conf

. /etc/rc.subr

name=goaccess
rcvar=goaccess_enable

load_rc_config $name

: ${goaccess_enable:=NO}
: ${goaccess_html:=/var/run/goaccess/goaccess.html}
: ${goaccess_log:=/var/log/httpd-access.log}
: ${goaccess_config:=%%ETCDIR%%/goaccess.conf}

command=%%PREFIX%%/bin/${name}
pidfile=/var/run/${name}.pid

start_precmd=start_precmd
start_precmd()
{
    htmldir=$(dirname "$goaccess_html")
    if ! [ -d "$htmldir" ]; then
        echo "Creating HTML output dir $htmldir."
        mkdir "$htmldir"
    fi
}

command_args="--daemonize --real-time-html --pid-file='$pidfile' -p '$goaccess_config' -o '$goaccess_html'"
run_rc_command "$1"