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