rc script to daemonize prosody-filer on FreeBSD

[linkstandalone]

Happy new year and best wishes to you, reader!

I was searching for a rc script to daemonizeprosody-filer on FreeBSD but didn't find anything, so I decided to make my own. Here's the script below, it worked for me with a non-root user with disabled password and it's shell set to /usr/sbin/nologin:

#!/bin/sh

# PROVIDE: prosody_filer
# REQUIRE: FILESYSTEMS networking
# KEYWORDS: http upload

. /etc/rc.subr

name="prosody_filer"
program_name="prosody-filer"
title="Prosody-Filer"
rcvar=prosody_filer_enable
prosody_filer_user="prosodyfiler"  # créez l'utilisateur et le groupe
prosody_filer_group="prosodyfiler" # au préalable !
prosody_filer_chdir="/home/prosodyfiler/"

pidfile="/home/prosodyfiler/${program_name}.pid"
required_files="/home/prosodyfiler/config.toml"
exec_path="/home/prosodyfiler/${program_name}"
output_file="/var/log/${program_name}.log"

command="/usr/sbin/daemon"
command_args="-r -t ${title} -o ${output_file} -P ${pidfile} -f ${exec_path}"

load_rc_config $name
: ${prosody_filer_enable="NO"}

run_rc_command "$1"

You can then execute sysrc prosody_filer_enable=YES to enable the service and start it with service prosody_filer start.