Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.
Western Digital Drives - The Preferred Drives of FreeNAS and TrueNAS CORE
Resource icon

Duplicati Running in an iocage

Hi - I’ve been working on some scripts/commands and now have Duplicati running in iocage as a ‘service’ on my FreeNAS server.

Thanks to Pentaflake's guide - I've borrowed heavily from his scripts.



#destroy previous iocage
iocage destroy duplicati

#create duplicati iocage
echo '{"pkgs":["mono","py27-sqlite3","curl","ca_root_nss"]}' > /tmp/pkg.json
iocage create -n "duplicati" -p /tmp/pkg.json -r 11.1-RELEASE ip4_addr="vnet0|192.168.1.17/24" defaultrouter="192.168.1.1" vnet="on" allow_raw_sockets="1" boot="on"
rm /tmp/pkg.json

#create config directory outside iocage
mkdir /mnt/Volume1/apps/duplicati
iocage fstab -a duplicati /mnt/Volume1/apps/duplicati /config nullfs rw 0 0

#mount media directory to iocage
iocage exec duplicati mkdir /mnt/Media
iocage fstab -a duplicati /mnt/Volume1/Media /mnt/Media nullfs rw 0 0

#additional setup setup steps
iocage exec duplicati ln -s /usr/local/bin/mono /usr/bin/mono
iocage exec duplicati mkdir /usr/local/share/duplicati

#Download the duplicati zip file https://updates.duplicati.com/beta/duplicati-2.0.3.3_beta_2018-04-02.zip and extract
cp -rf /root/Projects/Duplicati/2.0.2.Beta/* /mnt/iocage/jails/duplicati/root/usr/local/share/duplicati

#create user and group
iocage exec duplicati "pw user add duplicati -c duplicati -u 818 -d /nonexistent -s /usr/bin/nologin"
iocage exec duplicati chown -R duplicati:duplicati /usr/local/share/duplicati /config

#create service directory
iocage exec duplicati mkdir /usr/local/etc/rc.d



Create an rc file for duplicati using your favorite editor at /mnt/iocage/jails/duplicati/root/usr/local/etc/rc.d/duplicati


#!/bin/sh

# $FreeBSD$
#
# PROVIDE: duplicati
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# duplicati_enable: Set to YES to enable duplicati
# Default: NO
# duplicati_user: The user account used to run the duplicati daemon.
# This is optional, however do not specifically set this to an
# empty string as this will cause the daemon to run as root.
# Default: media
# duplicati_group: The group account used to run the duplicati daemon.
# This is optional, however do not specifically set this to an
# empty string as this will cause the daemon to run with group wheel.
# Default: media
# duplicati_data_dir: Directory where duplicati configuration
# data is stored.
# Default: /var/db/duplicati

. /etc/rc.subr
name=duplicati
rcvar=${name}_enable
load_rc_config $name

: ${duplicati_enable:="NO"}
: ${duplicati_user:="duplicati"}
: ${duplicati_group:="duplicati"}
: ${duplicati_data_dir:="/config"}

command="/usr/sbin/daemon"
procname="/usr/local/bin/mono"
command_args="-p ${duplicati_data_dir}/duplicati.pid -f ${procname} /usr/local/share/duplicati/Duplicati.Server.exe --webservice-port=8200 --webservice-interface=any --webservice-password=*useyourpassword* -d ${duplicati_data_dir}"

start_precmd=duplicati_precmd
duplicati_precmd() {
export USER=${duplicati_user}
if [ ! -d ${duplicati_data_dir} ]; then
install -d -o ${duplicati_user} -g ${duplicati_group} ${duplicati_data_dir}
fi

export XDG_CONFIG_HOME=${duplicati_data_dir}
}

run_rc_command "$1"



Now execute the following to start the service.


#Start duplicati service
iocage exec duplicati chmod u+x /usr/local/etc/rc.d/duplicati
iocage exec duplicati sysrc "duplicati_enable=YES"
iocage exec duplicati service duplicati restart



Duplicati should then be available at http://<jailip>:8200
Author
Mark WatIng
Views
1,231
First release
Last update
Rating
5.00 star(s) 1 ratings

Latest reviews

Works like a charm. Only the rc file needs to be created with something different than Nano. EE worked fine with it.
Top