#!/bin/sh
# $FreeBSD: branches/2020Q1/www/morty/files/morty.in 463944 2018-03-09 08:34:57Z yuri $

# PROVIDE: morty
# REQUIRE: DAEMON NETWORKING
# BEFORE: LOGIN
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable morty:
# morty_enable="YES"
#

# morty_enable (bool):	Set to YES to enable morty
#				Default: NO
# morty_conf (str):		morty configuration file
#				Default: ${PREFIX}/etc/morty.conf
# morty_user (str):		morty daemon user
#				Default: morty
# morty_group (str):		morty daemon group
#				Default: morty
# morty_flags (str):		Extra flags passed to morty

. /etc/rc.subr

name="morty"
rcvar=morty_enable

: ${morty_enable:="NO"}
: ${morty_user:="www"}
: ${morty_group:="www"}
: ${morty_flags:=""}

# daemon
pidfile="/var/run/${name}.pid"
command="/usr/local/bin/${name}"
procname="morty"
command_args=" -listen 0.0.0.0:3003 -key {{morty_secret_key}} &"
start_precmd="morty_precmd"

morty_precmd() {
	install -o ${morty_user} /dev/null ${pidfile}
}

load_rc_config $name
run_rc_command "$1"
