Update paperless-ngx.sh

Clean old code.
pull/2929/head
tteckster 7 months ago committed by GitHub
parent cfc6ca13ef
commit b950a06b5f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -59,7 +59,6 @@ function update_script() {
exit exit
fi fi
RELEASE=$(curl -s https://api.github.com/repos/paperless-ngx/paperless-ngx/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') RELEASE=$(curl -s https://api.github.com/repos/paperless-ngx/paperless-ngx/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
SER=/etc/systemd/system/paperless-task-queue.service
UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 2 \ UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 2 \
"1" "Update Paperless-ngx to $RELEASE" ON \ "1" "Update Paperless-ngx to $RELEASE" ON \
@ -67,64 +66,32 @@ function update_script() {
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
header_info header_info
if [ "$UPD" == "1" ]; then if [ "$UPD" == "1" ]; then
msg_info "Stopping Paperless-ngx" echo -e "Stopping all Paperless-ngx Services"
systemctl stop paperless-consumer paperless-webserver paperless-scheduler systemctl stop paperless-consumer paperless-webserver paperless-scheduler paperless-task-queue.service
if [ -f "$SER" ]; then msg_ok "Stopped all Paperless-ngx Services"
systemctl stop paperless-task-queue.service
fi
sleep 1
msg_ok "Stopped Paperless-ngx"
msg_info "Updating to ${RELEASE}" echo -e "Updating to ${RELEASE}"
cd ~ cd ~
if [ "$(dpkg -l | awk '/libmariadb-dev-compat/ {print }' | wc -l)" != 1 ]; then apt-get install -y libmariadb-dev-compat; fi &>/dev/null wget https://github.com/paperless-ngx/paperless-ngx/releases/download/$RELEASE/paperless-ngx-$RELEASE.tar.xz
wget https://github.com/paperless-ngx/paperless-ngx/releases/download/$RELEASE/paperless-ngx-$RELEASE.tar.xz &>/dev/null tar -xf paperless-ngx-$RELEASE.tar.xz
tar -xf paperless-ngx-$RELEASE.tar.xz &>/dev/null
cp -r /opt/paperless/paperless.conf paperless-ngx/ cp -r /opt/paperless/paperless.conf paperless-ngx/
cp -r paperless-ngx/* /opt/paperless/ cp -r paperless-ngx/* /opt/paperless/
cd /opt/paperless cd /opt/paperless
pip install -r requirements.txt &>/dev/null pip install -r requirements.txt
cd /opt/paperless/src cd /opt/paperless/src
/usr/bin/python3 manage.py migrate &>/dev/null /usr/bin/python3 manage.py migrate
if [ -f "$SER" ]; then
msg_ok "paperless-task-queue.service Exists."
else
cat <<EOF >/etc/systemd/system/paperless-task-queue.service
[Unit]
Description=Paperless Celery Workers
Requires=redis.service
[Service]
WorkingDirectory=/opt/paperless/src
ExecStart=celery --app paperless worker --loglevel INFO
[Install]
WantedBy=multi-user.target
EOF
systemctl enable paperless-task-queue &>/dev/null
msg_ok "paperless-task-queue.service Created."
fi
cat <<EOF >/etc/systemd/system/paperless-scheduler.service
[Unit]
Description=Paperless Celery beat
Requires=redis.service
[Service]
WorkingDirectory=/opt/paperless/src
ExecStart=celery --app paperless beat --loglevel INFO
[Install]
WantedBy=multi-user.target
EOF
msg_ok "Updated to ${RELEASE}" msg_ok "Updated to ${RELEASE}"
msg_info "Cleaning up" echo -e "Cleaning up"
cd ~ cd ~
rm paperless-ngx-$RELEASE.tar.xz rm paperless-ngx-$RELEASE.tar.xz
rm -rf paperless-ngx rm -rf paperless-ngx
msg_ok "Cleaned" msg_ok "Cleaned"
msg_info "Starting Paperless-ngx" echo -e "Starting all Paperless-ngx Services"
systemctl daemon-reload
systemctl start paperless-consumer paperless-webserver paperless-scheduler paperless-task-queue.service systemctl start paperless-consumer paperless-webserver paperless-scheduler paperless-task-queue.service
sleep 1 sleep 1
msg_ok "Started Paperless-ngx" msg_ok "Started all Paperless-ngx Services"
msg_ok "Updated Successfully!\n" msg_ok "Updated Successfully!\n"
exit exit
fi fi

Loading…
Cancel
Save

Powered by BW's shoe-string budget.