pyload-ng - new sequence
This commit is contained in:
5
seqs/pyload-ng.cfg.example
Normal file
5
seqs/pyload-ng.cfg.example
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
sc_pyloadUser="pyload"
|
||||
sc_pyloadHome="/home/pyload"
|
||||
sc_pyloadDir="/opt/pyload" # Place for the venv
|
110
seqs/pyload-ng.sh
Executable file
110
seqs/pyload-ng.sh
Executable file
@@ -0,0 +1,110 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
readonly toolName=pyload
|
||||
readonly toolDeps=(python3 python3-pip python3-pil python3-openssl libcurl4-openssl-dev libssl-dev p7zip ffmpeg tesseract-ocr)
|
||||
|
||||
sq_aptOpt=
|
||||
sq_config=0
|
||||
|
||||
seq_config() {
|
||||
checkVpn
|
||||
|
||||
if initSeqConfig "${seq_configName:?}" "${seq_configTemplate:?}" ; then
|
||||
sq_config=1
|
||||
else
|
||||
# End if no configuration file exists
|
||||
dry || return 1
|
||||
fi
|
||||
|
||||
## Apt cmdline option to suppress user interaction
|
||||
interactive || sq_aptOpt="-y"
|
||||
|
||||
## Disable error checks if external scripts are used
|
||||
## e.g. error on unbound variables
|
||||
#disableErrorCheck
|
||||
|
||||
## Return of non zero value will abort the sequence
|
||||
return 0
|
||||
}
|
||||
|
||||
step_1_info() { echo "Show status"; }
|
||||
step_1_alias() { echo "status"; }
|
||||
step_1() {
|
||||
local version=$(${sc_pyloadDir}/bin/pip list | grep pyload)
|
||||
info "Status of ${toolName}-ng ${version##p* }"
|
||||
exe systemctl -n0 status ${toolName}
|
||||
}
|
||||
|
||||
step_10_info() {
|
||||
echo "Install apt dependencies:";
|
||||
echoinfo "${toolDeps[@]}";
|
||||
}
|
||||
#step_10_options() { echo "[OPTIONS]"; }
|
||||
step_10_alias() { echo "install"; }
|
||||
step_10() {
|
||||
exe apt install "${toolDeps[@]}" ${sq_aptOpt}
|
||||
}
|
||||
|
||||
step_11_info() {
|
||||
echo "Create virtual python environment.";
|
||||
}
|
||||
step_11() {
|
||||
if [ ! -e "$sc_pyloadDir/bin" ]; then
|
||||
exe python3 -m venv ${sc_pyloadDir}
|
||||
endReturn "Creating virtual environment failed"
|
||||
else
|
||||
warning "Virtual env. ${sc_pyloadDir} already exists"
|
||||
fi
|
||||
exe ${sc_pyloadDir}/bin/pip install --pre pyload-ng[all]
|
||||
}
|
||||
|
||||
step_12_info() { echo "Create system user ${sc_pyloadUser:-'pyload'}"; }
|
||||
step_12() {
|
||||
if ! id ${sc_pyloadUser} &>/dev/null; then
|
||||
exe adduser --home "${sc_pyloadHome:?}" --disabled-password --disabled-login --gecos "" "${sc_pyloadUser:?}"
|
||||
info "Granting write access to network folder"
|
||||
exe usermod -aG debian-transmission pyload
|
||||
else
|
||||
warning "User ${sc_pyloadUser} already exists"
|
||||
fi
|
||||
}
|
||||
|
||||
step_13_info() { echo "Create systemd service: ${toolServiceLoc##*/}"; }
|
||||
step_13() {
|
||||
local lService=`eval "echo \"$toolService\""`
|
||||
addConf -c "$lService" "$toolServiceLoc"
|
||||
exe systemctl daemon-reload
|
||||
exe systemctl disable "${toolServiceLoc##*/}"
|
||||
}
|
||||
toolServiceLoc="/etc/systemd/system/pyload.service"
|
||||
toolService="[Unit]
|
||||
Description=Python Downloader
|
||||
After=network-online.target nss-lookup.target local-fs.target remote-fs.target
|
||||
|
||||
[Service]
|
||||
User=pyload
|
||||
ExecStart=\${sc_pyloadDir}/bin/pyload
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target"
|
||||
|
||||
step_20_info() { echo "Upgrade ${toolName}"; }
|
||||
step_20_alias() { echo "upgrade"; }
|
||||
step_20() {
|
||||
exe service ${toolName} stop
|
||||
exe ${sc_pyloadDir}/bin/pip install --upgrade pip
|
||||
exe ${sc_pyloadDir}/bin/pip install --pre pyload-ng[all] -U
|
||||
}
|
||||
|
||||
checkVpn() {
|
||||
if ip -br a | grep tun >>/dev/null 2>&1 ; then
|
||||
[ $? -eq 0 ] && warning "A VPN connection is possibly active. Consider deactivating it befor any apt operation."
|
||||
fi
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2034 # Appears unused
|
||||
readonly sqr_minVersion=16
|
||||
# shellcheck disable=SC1091 # Don't follow this source
|
||||
. /usr/local/bin/sequencer.sh
|
Reference in New Issue
Block a user