From 8e88146e75fa56a46116c04a2cf058a84d7bac35 Mon Sep 17 00:00:00 2001 From: bakerboy448 <55419169+bakerboy448@users.noreply.github.com> Date: Tue, 15 Mar 2022 08:33:39 -0500 Subject: [PATCH] add update script to nix docs --- Nix-Installation.md | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/Nix-Installation.md b/Nix-Installation.md index 2367e68..b0cbeac 100644 --- a/Nix-Installation.md +++ b/Nix-Installation.md @@ -25,11 +25,45 @@ cp config.yml.sample config.yml nano -e config.yml ``` -* Updating +* Create the update script ```bash -wget -O - https://github.com/StuffAnThings/qbit_manage/archive/master.tar.gz | tar xz --strip=1 "qbit_manage-master" -chmod +x qbit_manage.py -pip install -r requirements.txt -diff -ui config/config.yml config/config.yml.sample +nano qbm-update.sh +``` + +* Paste the below into the update script and update the Paths and Service Name (if using systemd) + +```bash +#!/bin/bash + +qbmPath="/home/bakerboy448/QbitManage" +qbmVenvPath="$qbmPath"/"qbit-venv/" +qbmServiceName="qbm" +cd "$qbmPath" || exit +currentVersion=$(cat VERSION) +branch=$(git rev-parse --abbrev-ref HEAD) +git fetch +if [ "$(git rev-parse HEAD)" = "$(git rev-parse @'{u}')" ]; then + echo "=== Already up to date $currentVersion on $branch ===" + exit 0 +fi +git pull +newVersion=$(cat VERSION) +"$qbmVenvPath"/bin/python -m pip install -r requirements.txt +echo "=== Updated from $currentVersion to $newVersion on $branch ===" +echo "=== Restarting qbm Service ===" +sudo systemctl restart "$qbmServiceName" +exit 0 +``` + +* Make the update script executable + +```bash +chmod +x qbm-update.sh +``` + +* Run the update script + +```bash +./qbm-update.sh ```