๐Ÿ“— Ansible playbooks and roles for building an idempotent, interconnected and scalable infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

37 lines
1.2 KiB

#!/sbin/openrc-run
{% set ns = namespace(single_args=[], multi_args=[], remote_args=[]) -%}
{% for arg in (rclone_single_args | d([])) -%}
{% set ns.single_args = ns.single_args + ['--' ~ arg] -%}
{% endfor -%}
{% for arg in (rclone_multi_args | d({}) | dict2items) -%}
{% set ns.multi_args = ns.multi_args + ['--' ~ arg.key ~ ' ' ~ (arg.value | quote)] -%}
{% endfor -%}
{% for arg in (remote.args | d([])) -%}
{% set ns.remote_args = ns.remote_args + ['--' ~ arg] -%}
{% endfor -%}
name="$SVCNAME"
directory="{{ rclone_mount_dir }}"
command="/usr/bin/rclone"
command_user="{{ rclone_user }}:{{ rclone_group }}"
command_args="mount {{ remote.name }}: {{ (rclone_mount_dir ~ '/' ~ remote.name) | quote }} --config {{ (rclone_conf_dir ~ '/' ~ remote.name ~ '.conf') | quote }} {{ ns.single_args | join(' ') }} {{ ns.multi_args | join(' ') }} {{ ns.remote_args | join(' ') }}"
pidfile="/var/run/$SVCNAME.pid"
command_background=true
start_stop_daemon_args="--stdout-logger logger --stderr-logger logger"
depend() {
need net
use dns
}
start_pre() {
fusermount -u {{ (rclone_mount_dir ~ '/' ~ remote.name) | quote }} > /dev/null 2>&1 || true
}