#!/sbin/openrc-run

name="mwhoisd"
description="MWHOIS Daemon"
command="/root/whois/mwhoisd"
command_background="yes"
pidfile="/run/${RC_SVCNAME}.pid"
start_stop_daemon_args="--chdir /root/whois"
command_user="root"

# Redirect output to files
output_log="/root/whois/mwhoisd.out"
error_log="/root/whois/mwhoisd.err"
start_stop_daemon_args="${start_stop_daemon_args} --stdout ${output_log} --stderr ${error_log}"
# Make sure we're running as root to bind to port 43
command_user="root"

depend() {
    need net
    after firewall
}

start_pre() {
    touch "${output_log}" "${error_log}"
    chmod 644 "${output_log}" "${error_log}"
    chown root:root "${output_log}" "${error_log}"
}
