132 lines
3.8 KiB
Bash
Executable File
132 lines
3.8 KiB
Bash
Executable File
#!/bin/bash
|
|
readonly toolName="pyload"
|
|
readonly toolBranch="stable"
|
|
readonly toolDownload="https://github.com/pyload/pyload.git"
|
|
readonly toolDeps="git liblept5 python python-crypto python-pycurl python-imaging python-sleekxmpp tesseract-ocr zip unzip python-openssl libmozjs-24-bin"
|
|
# python-cryptography shall be implemented in future releases and replace pyhton-crypto
|
|
readonly toolDepsDebian="sudo git python-crypto python-pycurl python-pil python-sleekxmpp tesseract-ocr zip unzip pyhton-openssl libmozjs-60-dev"
|
|
readonly toolBuildDeps="rar unrar-nonfree"
|
|
|
|
sq_aptOpt=
|
|
|
|
seq_config() {
|
|
if ! initSeqConfig "${seq_configName:?}" "${seq_configTemplate:?}" ; then
|
|
# End if no configuration file exists
|
|
dry || return 1
|
|
fi
|
|
|
|
interactive || sq_aptOpt="-y"
|
|
|
|
return 0
|
|
}
|
|
|
|
step_1_info() { echo "Apt sources.list check and update"; }
|
|
step_1_alias() { echo "install"; }
|
|
step_1() {
|
|
echo "Make sure you have the \"deb-src\" entry active in your /etc/apt/sources.list"
|
|
echo "Especially check for \"non-free\""
|
|
exe read -p "Press Enter to continue: "
|
|
exe vi /etc/apt/sources.list
|
|
exe apt update
|
|
}
|
|
|
|
step_2_info() { echo "Install unrar-nonfree from source"; }
|
|
step_2() {
|
|
exe apt-get build-dep ${toolBuildDeps} ${sq_aptOpt}
|
|
exe cd /tmp
|
|
exe apt-get source -b unrar-nonfree
|
|
saveReturn $?
|
|
endReturn
|
|
exe dpkg -i unrar_*_armhf.deb
|
|
exe rm -rf unrar-*
|
|
}
|
|
|
|
step_3_info() {
|
|
echo "Install dependencies"
|
|
echoinfo " [TARGET] (default: raspi)"
|
|
echoinfo " raspi: Raspberry Pi OS"
|
|
echoinfo " debian: Debian"
|
|
}
|
|
step_3_options() { echo "[TARGET]"; }
|
|
step_3_alias() { echo "deps"; }
|
|
step_3() {
|
|
shift
|
|
local lDeps="$toolDeps"
|
|
case "${1:-}" in
|
|
debian)
|
|
lDeps="$toolDepsDebian";;
|
|
raspi);;
|
|
*)
|
|
error -e "Unrecognized target"
|
|
return 1;;
|
|
esac
|
|
exe apt-get install ${lDeps} ${sq_aptOpt}
|
|
saveReturn $?
|
|
endReturn
|
|
case "${1:-}" in
|
|
raspi)
|
|
exe cd /usr/bin
|
|
exe ln -s js24 js;;
|
|
debian)
|
|
exe cd /usr/bin
|
|
exe ln -s js60 js;;
|
|
esac
|
|
}
|
|
|
|
step_4_info() { echo "Get $toolName from $toolDownload and create dedicated user"; }
|
|
step_4() {
|
|
exe git clone -b $toolBranch $toolDownload "$PYL_INSTALL_DIR"
|
|
endReturn "Git clone failed"
|
|
exe adduser --system --home "$PYL_CONFIG_DIR" "$PYL_USER"
|
|
}
|
|
|
|
step_5_info() { echo "Make initial configuration"; }
|
|
step_5() {
|
|
echo "Webinterface server \"threaded\" is recommended on a raspberry pi."
|
|
exe read -p "Press Enter to continue: "
|
|
exe cd "$PYL_INSTALL_DIR"
|
|
exe sudo -u $PYL_USER python pyLoadCore.py
|
|
}
|
|
|
|
step_6_info() { echo "Create systemd service"; }
|
|
step_6() {
|
|
local lService=`eval "echo \"$toolService\""`
|
|
addConf -c "$lService" "$toolServiceLoc"
|
|
}
|
|
toolServiceLoc="/etc/systemd/system/pyload.service"
|
|
toolService="[Unit]
|
|
Description=Python Downloader
|
|
After=network.target
|
|
|
|
[Service]
|
|
User=pyload
|
|
ExecStart=/usr/bin/python \${PYL_INSTALL_DIR}/pyLoadCore.py
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target"
|
|
|
|
step_7_info() { echo "Add ufw rules"; }
|
|
step_7_alias() { echo "ufw"; }
|
|
step_7() {
|
|
info "Port 9666 needs to be forwarded to the target machine with ssh"
|
|
info " ssh -L 9666:localhost:9666 user@host -N"
|
|
exe ufw allow in on eth0 to any port 8000 proto tcp comment "pyload webinterface"
|
|
exe ufw allow in on eth0 to any port 7227 proto tcp comment "pyload remotes"
|
|
exe ufw allow out on eth0 to 192.168.23.20 port 5222 proto tcp comment "XMPP Connection"
|
|
}
|
|
|
|
step_10_info() { echo "Upgrade to latest version of branch $toolBranch"; }
|
|
step_10_alias() { echo "upgrade"; }
|
|
step_10() {
|
|
exe service $toolName stop
|
|
exe cd "$PYL_INSTALL_DIR"
|
|
exe git pull
|
|
info "Service is not started automatically"
|
|
echo " Do so manually with: service $toolName start"
|
|
}
|
|
|
|
# shellcheck disable=SC2034 # Appears unused
|
|
readonly sqr_minVersion=16
|
|
# shellcheck disable=SC1091 # Don't follow this source
|
|
. /usr/local/bin/sequencer.sh
|