Skip to content

Instantly share code, notes, and snippets.

@schtobia
Last active Aug 14, 2019
Embed
What would you like to do?
firejail aria2
#! /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; }
[ -z "$RPC_SECRET" ] && { echo "Please set \$RPC_SECRET before calling this script." >&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 \
--max-connection-per-server=4 \
--quiet=true \
--remote-time=true \
--rpc-secret="$RPC_SECRET" \
--save-session-interval=120 \
--save-session="$SESSION_FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment