Introduce configuration file
This commit is contained in:
5
seqs/downloader.cfg.example
Normal file
5
seqs/downloader.cfg.example
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
DLD_USER="dluser"
|
||||
DLD_DIR="/opt/downloaders"
|
||||
DLD_CONFDIR="/opt/downloaders.conf"
|
@@ -1,10 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
toolName=mytool
|
||||
DLDUSER=dluser
|
||||
DL_DIR="/opt/downloaders"
|
||||
DL_CONF_DIR="/opt/downloaders.conf"
|
||||
|
||||
# Get script working directory
|
||||
# (when called from a different directory)
|
||||
WDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd)"
|
||||
@@ -17,19 +12,14 @@ CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
|
||||
|
||||
step_config() {
|
||||
checkVpn
|
||||
#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 ] && return -1
|
||||
#fi
|
||||
|
||||
initSeqConfig -t "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
|
||||
if [ $? -eq 0 ] ; then
|
||||
CONFIG=1
|
||||
else
|
||||
# End if no configuration file exists
|
||||
[ $DRY -eq 0 ] && return -1
|
||||
fi
|
||||
[ $QUIET -ne 0 ] && APTOPT="-y"
|
||||
return 0
|
||||
}
|
||||
@@ -60,7 +50,7 @@ step_2() {
|
||||
|
||||
step_3_info() { echo "Add system user"; }
|
||||
step_3() {
|
||||
exe adduser --system $DLDUSER --group --home "${DL_DIR}"
|
||||
exe adduser --system $DLD_USER --group --home "${DLD_CONFDIR}"
|
||||
}
|
||||
|
||||
step_4_info() { echo "Install sonarr"
|
||||
@@ -86,21 +76,22 @@ step_5() {
|
||||
exe curl -sL "https://radarr.servarr.com/v1/update/master/updatefile?os=linux&runtime=netcore&arch=arm64" \
|
||||
-o /tmp/Radarr.tgz
|
||||
|
||||
exe tar xvzf /tmp/Radarr.tgz -C "${DL_DIR}/"
|
||||
exe mv ${DL_DIR}/Radarr "${DL_DIR}/radarr"
|
||||
exe chown -R ${DLDUSER}:${DLDUSER} "${DL_DIR}/radarr"
|
||||
exe tar xvzf /tmp/Radarr.tgz -C "${DLD_DIR}/"
|
||||
exe mv ${DLD_DIR}/Radarr "${DLD_DIR}/radarr"
|
||||
exe chown -R ${DLD_USER}:${DLD_USER} "${DLD_DIR}/radarr"
|
||||
}
|
||||
|
||||
step_6_info() { echo "Create radarr service"; }
|
||||
step_6() {
|
||||
local radarrConf="${DLD_CONFDIR}/radarr"
|
||||
local radarrServiceLoc="/etc/systemd/system/radarr.service"
|
||||
|
||||
exe mkdir -p "$radarrConf"
|
||||
exe chown -R $DLDUSER: "$radarrConf"
|
||||
exe chown -R $DLD_USER: "$radarrConf"
|
||||
|
||||
addConf -s "$radarrService" "$radarrServiceLoc"
|
||||
exe systemctl daemon-reload
|
||||
}
|
||||
radarrConf="${DL_CONF_DIR}/radarr"
|
||||
radarrServiceLoc="/etc/systemd/system/radarr.service"
|
||||
radarrService="[Unit]
|
||||
Description=Radarr Daemon
|
||||
After=syslog.target network.target
|
||||
@@ -108,12 +99,12 @@ Wants=transmission.service jackett.service nzbget.service
|
||||
StartLimitIntervalSec=0
|
||||
|
||||
[Service]
|
||||
User=$DLDUSER
|
||||
Group=$DLDUSER
|
||||
User=\$DLD_USER
|
||||
Group=\$DLD_USER
|
||||
|
||||
Type=simple
|
||||
|
||||
ExecStart=${DL_DIR}/radarr/Radarr -nobrowser -data=$radarrConf
|
||||
ExecStart=\${DLD_DIR}/radarr/Radarr -nobrowser -data=\$radarrConf
|
||||
TimeoutStopSec=20
|
||||
KillMode=process
|
||||
Restart=on-failure
|
||||
@@ -133,32 +124,33 @@ step_7() {
|
||||
|
||||
[ ! -e "$jTar" ] && exe curl -sL "$jUrl" -o "$jTar"
|
||||
|
||||
exe tar xvzf "$jTar" -C "${DL_DIR}"
|
||||
exe mv "${DL_DIR}/Jackett" "${DL_DIR}/jackett"
|
||||
exe chown -R ${DLDUSER}:${DLDUSER} "${DL_DIR}/jackett"
|
||||
exe tar xvzf "$jTar" -C "${DLD_DIR}"
|
||||
exe mv "${DLD_DIR}/Jackett" "${DLD_DIR}/jackett"
|
||||
exe chown -R ${DLD_USER}:${DLD_USER} "${DLD_DIR}/jackett"
|
||||
}
|
||||
|
||||
step_8_info() { echo "Create jackett service"; }
|
||||
step_8() {
|
||||
addConf -s "$jackettService" "$jackettServiceLoc"
|
||||
local jackettServiceLoc="/etc/systemd/system/jackett.service"
|
||||
local lService=`eval "echo \"$jackettService\""`
|
||||
addConf -s "$lService" "$jackettServiceLoc"
|
||||
exe systemctl daemon-reload
|
||||
}
|
||||
jackettServiceLoc="/etc/systemd/system/jackett.service"
|
||||
jackettService="[Unit]
|
||||
Description=Jackett Daemon
|
||||
After=syslog.target network.target
|
||||
StartLimitIntervalSec=0
|
||||
|
||||
[Service]
|
||||
User=$DLDUSER
|
||||
Group=$DLDUSER
|
||||
User=\$DLD_USER
|
||||
Group=\$DLD_USER
|
||||
|
||||
Type=simple
|
||||
SyslogIdentifier=jackett
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
WorkingDirectory=${DL_DIR}/jackett
|
||||
ExecStart=/bin/sh ${DL_DIR}/jackett/jackett_launcher.sh
|
||||
WorkingDirectory=\${DLD_DIR}/jackett
|
||||
ExecStart=/bin/sh \${DLD_DIR}/jackett/jackett_launcher.sh
|
||||
TimeoutStopSec=30
|
||||
|
||||
[Install]
|
||||
@@ -173,24 +165,25 @@ step_9() {
|
||||
exe wget -q https://nzbget.net/download/nzbget-latest-bin-linux.run -O /tmp/nzbget-latest-bin-linux.run
|
||||
|
||||
# you can skip --arch aarch64 to auto-detect the architecture
|
||||
exe sh /tmp/nzbget-latest-bin-linux.run --destdir "${DL_DIR}/nzbget" --arch aarch64
|
||||
exe sh /tmp/nzbget-latest-bin-linux.run --destdir "${DLD_DIR}/nzbget" --arch aarch64
|
||||
|
||||
exe chown -R ${DLDUSER}:${DLDUSER} "${DL_DIR}/nzbget"
|
||||
exe chown -R ${DLD_USER}:${DLD_USER} "${DLD_DIR}/nzbget"
|
||||
}
|
||||
|
||||
step_10_info() { echo "Create NZBGet service"; }
|
||||
step_10() {
|
||||
local nzbConfOri="${DL_DIR}/nzbget/nzbget.conf"
|
||||
local nzbConf="${DL_CONF_DIR}/nzbget/nzbget.conf"
|
||||
local nzbServiceLoc="/etc/systemd/system/nzbget.service"
|
||||
local lService=`eval "echo \"$nzbService\""`
|
||||
local nzbConfOri="${DLD_DIR}/nzbget/nzbget.conf"
|
||||
local nzbConf="${DLD_CONFDIR}/nzbget/nzbget.conf"
|
||||
exe mkdir -p "$(dirname "$nzbConf")"
|
||||
exe chown -R $DLDUSER: "$(dirname "$nzbConf")"/..
|
||||
exe chown -R $DLD_USER: "$(dirname "$nzbConf")"/..
|
||||
|
||||
addConf -s "$nzbService" "$nzbServiceLoc"
|
||||
addConf -s "$lService" "$nzbServiceLoc"
|
||||
exe systemctl daemon-reload
|
||||
|
||||
exe cp -n "$nzbConfOri" "$nzbConf"
|
||||
}
|
||||
nzbServiceLoc="/etc/systemd/system/nzbget.service"
|
||||
nzbService="[Unit]
|
||||
Description=NZBGet Daemon
|
||||
After=syslog.target network.target
|
||||
@@ -198,22 +191,22 @@ StartLimitIntervalSec=0
|
||||
|
||||
[Service]
|
||||
# Change the user and group variables here.
|
||||
User=$DLDUSER
|
||||
Group=$DLDUSER
|
||||
User=\$DLD_USER
|
||||
Group=\$DLD_USER
|
||||
|
||||
Type=forking
|
||||
|
||||
# Pass any command line arguments etc.
|
||||
ExecStart=${DL_DIR}/nzbget/nzbget -D -c ${DL_CONF_DIR}/nzbget/nzbget.conf
|
||||
ExecStop=${DL_DIR}/nzbget/nzbget -Q -c ${DL_CONF_DIR}/nzbget/nzbget.conf
|
||||
ExecReload=${DL_DIR}/nzbget/nzbget -O -c ${DL_CONF_DIR}/nzbget/nzbget.conf
|
||||
ExecStart=\${DLD_DIR}/nzbget/nzbget -D -c \${DLD_CONFDIR}/nzbget/nzbget.conf
|
||||
ExecStop=\${DLD_DIR}/nzbget/nzbget -Q -c \${DLD_CONFDIR}/nzbget/nzbget.conf
|
||||
ExecReload=\${DLD_DIR}/nzbget/nzbget -O -c \${DLD_CONFDIR}/nzbget/nzbget.conf
|
||||
TimeoutStopSec=20
|
||||
KillMode=process
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
|
||||
# Sandboxing ... (see https://www.freedesktop.org/software/systemd/man/systemd.exec.html for more info)
|
||||
ReadWritePaths=${DL_DIR}/nzbget ${DL_CONF_DIR}/nzbget /mnt
|
||||
ReadWritePaths=\${DLD_DIR}/nzbget \${DLD_CONFDIR}/nzbget /mnt
|
||||
ProtectSystem=strict
|
||||
PrivateDevices=true
|
||||
ProtectHome=true
|
||||
@@ -235,21 +228,22 @@ step_11() {
|
||||
|
||||
exe apt install $lidarrDeps $APTOPT
|
||||
|
||||
exe tar xvzf /tmp/Lidarr.tgz -C "${DL_DIR}/"
|
||||
exe mv "${DL_DIR}/Lidarr" "${DL_DIR}/lidarr"
|
||||
exe chown -R ${DLDUSER}:${DLDUSER} "${DL_DIR}/lidarr"
|
||||
exe tar xvzf /tmp/Lidarr.tgz -C "${DLD_DIR}/"
|
||||
exe mv "${DLD_DIR}/Lidarr" "${DLD_DIR}/lidarr"
|
||||
exe chown -R ${DLD_USER}:${DLD_USER} "${DLD_DIR}/lidarr"
|
||||
}
|
||||
|
||||
step_12_info() { echo "Create lidarr service"; }
|
||||
step_12() {
|
||||
local lidarrConf="${DLD_CONFDIR}/lidarr"
|
||||
local lidarrServiceLoc="/etc/systemd/system/lidarr.service"
|
||||
local lService=`eval "echo \"$lidarrService\""`
|
||||
exe mkdir -p "$lidarrConf"
|
||||
exe chown -R $DLDUSER: "$lidarrConf"
|
||||
exe chown -R $DLD_USER: "$lidarrConf"
|
||||
|
||||
addConf -s "$lidarrService" "$lidarrServiceLoc"
|
||||
addConf -s "$lService" "$lidarrServiceLoc"
|
||||
exe systemctl daemon-reload
|
||||
}
|
||||
lidarrConf="${DL_CONF_DIR}/lidarr"
|
||||
lidarrServiceLoc="/etc/systemd/system/lidarr.service"
|
||||
lidarrService="[Unit]
|
||||
Description=Lidarr Daemon
|
||||
After=syslog.target network.target
|
||||
@@ -257,12 +251,12 @@ Wants=transmission.service jackett.service nzbget.service
|
||||
StartLimitIntervalSec=0
|
||||
|
||||
[Service]
|
||||
User=$DLDUSER
|
||||
Group=$DLDUSER
|
||||
User=\$DLD_USER
|
||||
Group=\$DLD_USER
|
||||
|
||||
Type=simple
|
||||
|
||||
ExecStart=${DL_DIR}/lidarr/Lidarr -nobrowser -data=$lidarrConf
|
||||
ExecStart=\${DLD_DIR}/lidarr/Lidarr -nobrowser -data=\$lidarrConf
|
||||
TimeoutStopSec=20
|
||||
KillMode=process
|
||||
Restart=on-failure
|
||||
@@ -275,31 +269,32 @@ Alias=lidarr.service"
|
||||
|
||||
step_13_info() { echo "Install bazarr dependencies"; }
|
||||
step_13() {
|
||||
local bazarrDeps="python3-pip python3-distutils python3-venv"
|
||||
#local bazarrDeps+=" libxml2-dev libxslt1-dev python3-libxml2 python3-lxml libatlas-base-dev" #ffmpeg
|
||||
local bazarrDeps="python3-pip python3-distutils python3-venv ffmpeg"
|
||||
#local bazarrDeps+=" libxml2-dev libxslt1-dev python3-libxml2 python3-lxml libatlas-base-dev"
|
||||
|
||||
exe apt install $bazarrDeps $APTOPT
|
||||
}
|
||||
|
||||
step_14_info() { echo "Install bazarr"; }
|
||||
step_14() {
|
||||
local bazarrVenv="${DL_DIR}/bazarr"
|
||||
local bazarrServiceLoc="/etc/systemd/system/bazarr.service"
|
||||
local lService=`eval "echo \"$bazarrService\""`
|
||||
local bazarrVenv="${DLD_DIR}/bazarr"
|
||||
local bazarrDir="${bazarrVenv}/bazarr"
|
||||
|
||||
local bazarrGitUrl="https://github.com/morpheus65535/bazarr.git"
|
||||
|
||||
#exe python3 -m venv "$bazarrVenv"
|
||||
#endReturn -o $? "Creating virtual environment failed"
|
||||
exe python3 -m venv "$bazarrVenv"
|
||||
endReturn -o $? "Creating virtual environment failed"
|
||||
|
||||
#exe git clone $bazarrGitUrl "$bazarrDir"
|
||||
#exe chown -R $DLDUSER: "$bazarrVenv"
|
||||
#exe sudo -u $DLDUSER ${bazarrVenv}/bin/pip install --upgrade pip
|
||||
#exe sudo -u $DLDUSER ${bazarrVenv}/bin/pip install -r ${bazarrDir}/requirements.txt
|
||||
exe git clone $bazarrGitUrl "$bazarrDir"
|
||||
exe chown -R $DLD_USER: "$bazarrVenv"
|
||||
exe sudo -u $DLD_USER ${bazarrVenv}/bin/pip install --upgrade pip
|
||||
exe sudo -u $DLD_USER ${bazarrVenv}/bin/pip install -r ${bazarrDir}/requirements.txt
|
||||
|
||||
addConf -s "$bazarrService" "$bazarrServiceLoc"
|
||||
addConf -s "$lService" "$bazarrServiceLoc"
|
||||
exe systemctl daemon-reload
|
||||
}
|
||||
bazarrServiceLoc="/etc/systemd/system/bazarr.service"
|
||||
bazarrService="[Unit]
|
||||
Description=Bazarr
|
||||
After=syslog.target network.target
|
||||
@@ -307,12 +302,12 @@ Wants=sonarr.service radarr.service
|
||||
StartLimitIntervalSec=0
|
||||
|
||||
[Service]
|
||||
User=$DLDUSER
|
||||
Group=$DLDUSER
|
||||
User=\$DLD_USER
|
||||
Group=\$DLD_USER
|
||||
|
||||
Type=simple
|
||||
|
||||
ExecStart=${DL_DIR}/bazarr/bin/python3 ${DL_DIR}/bazarr/bazarr/bazarr.py
|
||||
ExecStart=\${DLD_DIR}/bazarr/bin/python3 \${DLD_DIR}/bazarr/bazarr/bazarr.py
|
||||
TimeoutStopSec=20
|
||||
#KillMode=process
|
||||
Restart=always
|
||||
|
Reference in New Issue
Block a user