dotfiles/.local/share/aria2/aria2.daemon
2019-02-15 10:51:56 +01:00

34 lines
1.3 KiB
Bash
Executable file

#! /bin/bash
RUNDIR="${XDG_DOCUMENTS_DIR:-$HOME/.local/share}/aria2"
SESSION_FILE="$RUNDIR/aria2.session"
LOG_FILE="${LOG_FILE:-$RUNDIR/aria2.log}"
[ ! -d $RUNDIR ] && mkdir $RUNDIR
[ ! -d $RUNDIR ] && { echo "Cannot create runtime dir $RUNDIR." >&2; exit 1; }
# if log size is not readable or too large, recreate it empty
[ "$LOG_FILE" != "-" ] && truncate -s0 $LOG_FILE
[ ! -r $LOG_FILE -a "$LOG_FILE" != "-" ] && { echo "Cannot create log file $LOG_FILE." >&2; exit 1; }
[ ! -r $SESSION_FILE ] && touch $SESSION_FILE
[ ! -r $SESSION_FILE ] && { echo "Cannot create session file $SESSION_FILE." >&2; exit 1; }
exec firejail --name=aria2 --ignore=netfilter --ignore=private-cache --private-etc=ca-certificates,ssl,nsswitch.conf,resolv.conf,hosts aria2c \
--async-dns=false \
--bt-enable-lpd=true \
--check-integrity=true \
--continue \
--dir="$HOME"/Downloads \
--disable-ipv6 \
--enable-http-pipelining=true \
--enable-rpc=true \
--file-allocation=falloc \
--http-accept-gzip=true \
--input-file="$SESSION_FILE" \
--log="$LOG_FILE" \
--log-level=notice \
--max-concurrent-downloads=3 \
--quiet=true \
--remote-time=true \
--rpc-secret=t4fGJIbc8Rruik2hki87R6UiVUPUwmEX2Mr7gadVYBQz7BJtplDof1CNfzZCqPR2zxteycSvlC8OhC4kOokrBY15pjjvlWsIqkDX \
--save-session-interval=120 \
--save-session="$SESSION_FILE"