Running Duplicati on startup on Freenas / FreeBSD

I have the following rc script working for starting the service when its jail is started. This is running on a plain FreeBSD jail but should be similar for FreeNAS. My goal was to start the service with a user other than root. In its current form it will not stop the service, but with some more work it should be possible.

#!/bin/sh
#
# PROVIDE: duplicati 
# REQUIRE: NETWORKING
# KEYWORD: duplicati

. /etc/rc.subr

name="duplicati"
rcvar=`set_rcvar`

duplicati_user="duplicati"
duplicati_command="/usr/local/bin/mono /opt/duplicati/Duplicati.Server.exe"     
duplicati_command_args="--webservice-port=8200 --webservice-interface=any --server-datafolder=/opt/duplicati/data"

pidfile="/var/run/${name}/${name}.pid"

command="/usr/sbin/daemon"
command_args="-P ${pidfile} ${duplicati_command} ${duplicati_command_args}"

load_rc_config $name
run_rc_command "$1"
2 Likes