diff options
Diffstat (limited to 'user/aria2/aria2.initd')
-rw-r--r-- | user/aria2/aria2.initd | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/user/aria2/aria2.initd b/user/aria2/aria2.initd new file mode 100644 index 000000000..a23b6eb0d --- /dev/null +++ b/user/aria2/aria2.initd @@ -0,0 +1,42 @@ +#!/sbin/openrc-run + +: ${cfgfile:="/etc/aria2/aria2.conf"} +: ${logfile:="/var/log/aria2.log"} +: ${command_user:="aria2"} + +command="/usr/bin/aria2c" +command_args=" + --enable-rpc=true + --quiet=true + --log=$logfile + --conf-path=$cfgfile + ${command_args:-}" +command_background="yes" + +pidfile="/run/$RC_SVCNAME.pid" +output_log="/dev/null" +error_log="/dev/null" +start_stop_daemon_args="--env XDG_CACHE_HOME=/var/cache" + +required_files="$cfgfile" + +depend() { + need net + use dns netmount +} + +start_pre() { + local _logfile=$(sed -En 's|^log=([^#]+)|\1|p' "$cfgfile") + + checkpath -f -m 640 -o "$command_user" "${_logfile:-$logfile}" + + # Session + local _inputfile=$(sed -En 's|^input-file=([^#]+)|\1|p' "$cfgfile") + + if [ "$_inputfile" != "" ]; then + checkpath -f -m 644 -o "$command_user" "$_inputfile" + fi + + # DHT + checkpath -d -m 755 -o "$command_user" "/var/cache/$command_user" +} |