New sequence for aria2

This commit is contained in:
2021-03-18 00:43:09 +01:00
parent 07828f0d6f
commit ab1f9f761e
2 changed files with 86 additions and 0 deletions

8
seqs/aria2.cfg.example Normal file
View File

@@ -0,0 +1,8 @@
#!/bin/bash
ARIA2_RPC_SECRET=""
ARIA2_CONF="dir=/var/lib/aria2
file-allocation=none
enable-rpc=true
rpc-secret=$ARIA2_RPC_SECRET
rpc-listen-all=true"

78
seqs/aria2.sh Executable file
View File

@@ -0,0 +1,78 @@
#!/bin/bash
toolName=aria2
toolDeps=aria2
toolUser=aria2
# Get script working directory
# (when called from a different directory)
WDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd)"
CONFIG=0
SCRIPT_NAME=$(basename -- $0)
SCRIPT_NAME=${SCRIPT_NAME%%.*}
CONFIG_FILE_NAME="${SCRIPT_NAME}.cfg"
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
aptOpt=
step_config() {
#echo "Called once before executing steps."
## e.g. to source a config file manually:
#. "$CONFIG_FILE"
## or to use sequencer api with global config file:
initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
## or to use sequencer api with profile config file support:
#initSeqConfig -p "$SCRIPT_NAME" "$CONFIG_FILE_TEMPLATE"
if [ $? -eq 0 ] ; then
CONFIG=1
else
# End if no configuration file exists
[ $DRY -eq 0 ] && exit 1
fi
[ $QUIET -ne 0 ] && aptOpt="-y"
}
step_1_info() { echo "Install $toolName"; }
step_1_alias() { ALIAS="install"; }
step_1() {
exe apt update
exe apt install $toolDeps $aptOpt
}
step_2_info() { echo "Create $toolName configuration"; }
step_2() {
exe adduser --system --quiet "$toolUser"
if [ ! -e $ariaConfLoc ] ; then
exe mkdir -p "$(dirname $ariaConfLoc)"
addConf -s "$ARIA2_CONF" "$ariaConfLoc"
exe chown $toolUser:root "$ariaConfLoc"
exe chmod 770 "$ariaConfLoc"
fi
}
ariaConfLoc="/etc/aria2/aria2.conf"
step_3_info() { echo "Create $toolName service"; }
step_3_alias() { ALIAS="service"; }
step_3() {
addConf -s "$ariaService" "$ariaServiceLoc"
exe systemctl daemon-reload
echoseq " [I] Serive not started or enabled"
}
ariaServiceLoc="/etc/systemd/system/aria2.service"
ariaService="[Unit]
Description=Aria2
After=network-online.target
[Service]
User=$toolUser
Type=forking
ExecStart=/usr/bin/aria2c --conf-path=${ariaConfLoc} --daemon
ExecStop=/bin/kill -s STOP $MAINPID
Restart=on-failure
[Install]
WantedBy=multi-user.target"
VERSION_SEQREV=12
. /usr/local/bin/sequencer.sh