Update to support also debian as target system
This commit is contained in:
5
seqs/pyload.cfg.example
Normal file
5
seqs/pyload.cfg.example
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PYL_USER="pyload"
|
||||||
|
PYL_INSTALL_DIR="/opt/pyload"
|
||||||
|
PYL_CONFIG_DIR="/home/pyload"
|
107
seqs/pyload.sh
107
seqs/pyload.sh
@@ -1,12 +1,33 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
toolName="pyload"
|
toolName="pyload"
|
||||||
toolUser="${toolName}"
|
|
||||||
toolBranch="stable"
|
toolBranch="stable"
|
||||||
toolLoc=/opt/pyload
|
|
||||||
toolDownload="https://github.com/pyload/pyload.git"
|
toolDownload="https://github.com/pyload/pyload.git"
|
||||||
toolDeps="git liblept5 python python-crypto python-pycurl python-imaging python-sleekxmpp tesseract-ocr zip unzip python-openssl libmozjs-24-bin"
|
toolDeps="git liblept5 python python-crypto python-pycurl python-imaging python-sleekxmpp tesseract-ocr zip unzip python-openssl libmozjs-24-bin"
|
||||||
|
toolDepsDebian="sudo git python-cryptodome python-pycurl python-pil python-sleekxmpp tesseract-ocr zip unzip pyhton-openssl libmozjs-60-dev"
|
||||||
toolBuildDeps="rar unrar-nonfree"
|
toolBuildDeps="rar unrar-nonfree"
|
||||||
|
|
||||||
|
# Get script working directory
|
||||||
|
# (when called from a different directory)
|
||||||
|
WDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd)"
|
||||||
|
APTOPT=
|
||||||
|
CONFIG=0
|
||||||
|
SCRIPT_NAME=$(basename -- $0)
|
||||||
|
SCRIPT_NAME=${SCRIPT_NAME%%.*}
|
||||||
|
CONFIG_FILE_NAME="${SCRIPT_NAME}.cfg"
|
||||||
|
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
|
||||||
|
|
||||||
|
step_config() {
|
||||||
|
initSeqConfig "$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
|
||||||
|
}
|
||||||
|
|
||||||
step_1_info() { echo "Apt sources.list check and update"; }
|
step_1_info() { echo "Apt sources.list check and update"; }
|
||||||
step_1_alias() { ALIAS="install"; }
|
step_1_alias() { ALIAS="install"; }
|
||||||
step_1() {
|
step_1() {
|
||||||
@@ -17,15 +38,10 @@ step_1() {
|
|||||||
exe apt update
|
exe apt update
|
||||||
}
|
}
|
||||||
|
|
||||||
step_2_info() { echo "Install dependencies $toolDeps $toolBuildDeps"; }
|
step_2_info() { echo "Install unrar-nonfree from source"; }
|
||||||
step_2() {
|
step_2() {
|
||||||
exe apt-get install ${toolDeps}
|
exe apt-get build-dep ${toolBuildDeps} $APTOPT
|
||||||
exe apt-get build-dep ${toolBuildDeps}
|
exe cd /tmp
|
||||||
saveReturn $?
|
|
||||||
endReturn
|
|
||||||
cd /usr/bin
|
|
||||||
exe ln -s js24 js
|
|
||||||
cd /tmp
|
|
||||||
exe apt-get source -b unrar-nonfree
|
exe apt-get source -b unrar-nonfree
|
||||||
saveReturn $?
|
saveReturn $?
|
||||||
endReturn
|
endReturn
|
||||||
@@ -33,47 +49,88 @@ step_2() {
|
|||||||
exe rm -rf unrar-*
|
exe rm -rf unrar-*
|
||||||
}
|
}
|
||||||
|
|
||||||
step_3_info() { echo "Get $toolName from $toolDownload and create dedicated user"; }
|
step_3_info() {
|
||||||
|
echo "Install dependencies for [TARGET]"
|
||||||
|
echoinfo " [TARGET] (default: raspi)"
|
||||||
|
echoinfo " raspi: Raspberry Pi OS"
|
||||||
|
echoinfo " debian: Debian"
|
||||||
|
}
|
||||||
|
step_3_alias() { ALIAS="deps"; }
|
||||||
step_3() {
|
step_3() {
|
||||||
exe git clone -b $toolBranch $toolDownload "$toolLoc"
|
shift
|
||||||
endReturn -o $? "Git clone failed"
|
local lDeps="$toolDeps"
|
||||||
exe adduser --system "$toolUser"
|
case "$1" in
|
||||||
|
debian)
|
||||||
|
lDeps="$toolDepsDebian";;
|
||||||
|
raspi);;
|
||||||
|
*)
|
||||||
|
echoerr " [E] Unrecognized target"
|
||||||
|
return 1;;
|
||||||
|
esac
|
||||||
|
exe apt-get install ${lDeps} $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 "Make initial configuration"; }
|
step_4_info() { echo "Get $toolName from $toolDownload and create dedicated user"; }
|
||||||
step_4() {
|
step_4() {
|
||||||
|
exe git clone -b $toolBranch $toolDownload "$PYL_INSTALL_DIR"
|
||||||
|
endReturn -o $? "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."
|
echo "Webinterface server \"threaded\" is recommended on a raspberry pi."
|
||||||
exe read -p "Press Enter to continue: "
|
exe read -p "Press Enter to continue: "
|
||||||
exe cd "$toolLoc"
|
exe cd "$PYL_INSTALL_DIR"
|
||||||
exe sudo -u $toolUser python pyLoadCore.py
|
exe sudo -u $PYL_USER python pyLoadCore.py
|
||||||
}
|
}
|
||||||
|
|
||||||
step_5_info() { echo "Create systemd service"; }
|
step_6_info() { echo "Create systemd service"; }
|
||||||
step_5() {
|
step_6() {
|
||||||
addConf -c "$toolService" "$toolServiceLoc"
|
local lService=`eval "echo \"$toolService\""`
|
||||||
|
addConf -c "$lService" "$toolServiceLoc"
|
||||||
}
|
}
|
||||||
toolServiceLoc="/etc/systemd/system/pyload.service"
|
toolServiceLoc="/etc/systemd/system/pyload.service"
|
||||||
toolService="\
|
toolService="[Unit]
|
||||||
[Unit]
|
|
||||||
Description=Python Downloader
|
Description=Python Downloader
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=pyload
|
User=pyload
|
||||||
ExecStart=/usr/bin/python /opt/pyload/pyLoadCore.py
|
ExecStart=/usr/bin/python \${PYL_INSTALL_DIR}/pyLoadCore.py
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target"
|
WantedBy=multi-user.target"
|
||||||
|
|
||||||
|
step_7_info() { echo "Add ufw rules"; }
|
||||||
|
step_7_alias() { ALIAS="ufw"; }
|
||||||
|
step_7() {
|
||||||
|
echoseq " [I] Port 9666 needs to be forwarded to the target machine with ssh"
|
||||||
|
echoseq " 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_info() { echo "Upgrade to latest version of branch $toolBranch"; }
|
||||||
step_10_alias() { ALIAS="upgrade"; }
|
step_10_alias() { ALIAS="upgrade"; }
|
||||||
step_10() {
|
step_10() {
|
||||||
exe service $toolName stop
|
exe service $toolName stop
|
||||||
exe cd $toolLoc
|
exe cd "$PYL_INSTALL_DIR"
|
||||||
exe git pull
|
exe git pull
|
||||||
echo " [I] Service is not started automatically"
|
echo " [I] Service is not started automatically"
|
||||||
echo " Do so manually with: service $toolName start"
|
echo " Do so manually with: service $toolName start"
|
||||||
}
|
}
|
||||||
|
|
||||||
VERSION_SEQREV=10
|
VERSION_SEQREV=12
|
||||||
. /usr/local/bin/sequencer.sh
|
. /usr/local/bin/sequencer.sh
|
||||||
|
Reference in New Issue
Block a user