From 552959a39bdc793b30a14746809f40f6f2f1164e Mon Sep 17 00:00:00 2001 From: Vincent <114195376+HydroshieldMKII@users.noreply.github.com> Date: Tue, 30 Sep 2025 14:36:17 -0400 Subject: [PATCH] Update Guardian installation and update scripts to use new repository paths and improve dependency management --- ct/guardian.sh | 34 ++++++++++++++++++++++++---------- install/guardian-install.sh | 19 +++++++++---------- misc/build.func | 2 +- misc/install.func | 10 +++++----- 4 files changed, 39 insertions(+), 26 deletions(-) diff --git a/ct/guardian.sh b/ct/guardian.sh index 42aaa0bc..09c774cc 100644 --- a/ct/guardian.sh +++ b/ct/guardian.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +source <(curl -fsSL https://raw.githubusercontent.com/HydroshieldMKII/ProxmoxVED/refs/heads/add-guardian-app/misc/build.func) # Copyright (c) 2021-2025 community-scripts ORG # Author: HydroshieldMKII # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE @@ -31,35 +31,49 @@ function update_script() { fi # Crawling the new version and checking whether an update is required - RELEASE=$(curl -fsSL [RELEASE_URL] | [PARSE_RELEASE_COMMAND]) + RELEASE=$(curl -fsSL https://api.github.com/repos/HydroshieldMKII/Guardian/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then # Stopping Services msg_info "Stopping $APP" - systemctl stop [SERVICE_NAME] + systemctl stop guardian-backend guardian-frontend msg_ok "Stopped $APP" # Creating Backup msg_info "Creating Backup" - tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" [IMPORTANT_PATHS] + tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" /opt/Guardian msg_ok "Backup Created" # Execute Update msg_info "Updating $APP to v${RELEASE}" - [UPDATE_COMMANDS] + cd /tmp + curl -fsSL -o "${RELEASE}.zip" "https://github.com/HydroshieldMKII/Guardian/archive/refs/tags/${RELEASE}.zip" + unzip -q "${RELEASE}.zip" + rm -rf /opt/Guardian + mv "Guardian-${RELEASE}/" "/opt/Guardian" + + # Build Backend + cd /opt/Guardian/backend + npm ci + npm run build + + # Build Frontend + cd /opt/Guardian/frontend + npm ci + npm run build + + echo "${RELEASE}" >/opt/${APP}_version.txt msg_ok "Updated $APP to v${RELEASE}" # Starting Services msg_info "Starting $APP" - systemctl start [SERVICE_NAME] + systemctl start guardian-backend guardian-frontend msg_ok "Started $APP" # Cleaning up msg_info "Cleaning Up" - rm -rf [TEMP_FILES] + rm -rf /tmp/"${RELEASE}.zip" /tmp/"Guardian-${RELEASE}" msg_ok "Cleanup Completed" - # Last Action - echo "${RELEASE}" >/opt/${APP}_version.txt msg_ok "Update Successful" else msg_ok "No update required. ${APP} is already at v${RELEASE}" @@ -74,4 +88,4 @@ description msg_ok "Completed Successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}" -echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:[PORT]${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}" diff --git a/install/guardian-install.sh b/install/guardian-install.sh index 77d73eed..69eeecf3 100644 --- a/install/guardian-install.sh +++ b/install/guardian-install.sh @@ -20,31 +20,30 @@ $STD apt-get install -y \ git \ nodejs \ npm \ - sqlite + sqlite3 \ + unzip \ + curl msg_ok "Installed Dependencies" # Setup App -msg_info "Setup ${APPLICATION}" +msg_info "Setup Guardian" RELEASE=$(curl -fsSL https://api.github.com/repos/HydroshieldMKII/Guardian/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') curl -fsSL -o "${RELEASE}.zip" "https://github.com/HydroshieldMKII/Guardian/archive/refs/tags/${RELEASE}.zip" unzip -q "${RELEASE}.zip" -mv "${APPLICATION}-${RELEASE}/" "/opt/${APPLICATION}" -# -# -# -echo "${RELEASE}" >/opt/"${APPLICATION}"_version.txt -msg_ok "Setup ${APPLICATION}" +mv "Guardian-${RELEASE}/" "/opt/Guardian" +echo "${RELEASE}" >/opt/Guardian_version.txt +msg_ok "Setup Guardian" # ===== Build Backend ===== msg_info "Building backend" -cd /opt/${APPLICATION}/backend +cd /opt/Guardian/backend npm ci npm run build msg_ok "Built backend" # ===== Build Frontend ===== msg_info "Building frontend" -cd /opt/${APPLICATION}/frontend +cd /opt/Guardian/frontend npm ci npm run build msg_ok "Built frontend" diff --git a/misc/build.func b/misc/build.func index d6b0af72..92e9c719 100644 --- a/misc/build.func +++ b/misc/build.func @@ -79,7 +79,7 @@ variables() { # [Dd]*) # for file in core.func error_handler.func tools.func; do # local_path="$FUNC_DIR/$file" -# url="https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/$file" +# url="https://raw.githubusercontent.com/HydroshieldMKII/ProxmoxVED/refs/heads/add-guardian-app/misc/$file" # remote_tmp="$(mktemp)" # curl -fsSL "$url" -o "$remote_tmp" || continue diff --git a/misc/install.func b/misc/install.func index f741b921..2ebc8e2e 100644 --- a/misc/install.func +++ b/misc/install.func @@ -9,8 +9,8 @@ if ! command -v curl >/dev/null 2>&1; then apt-get update >/dev/null 2>&1 apt-get install -y curl >/dev/null 2>&1 fi -source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/core.func) -source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/error_handler.func) +source <(curl -fsSL https://raw.githubusercontent.com/HydroshieldMKII/ProxmoxVED/refs/heads/add-guardian-app/misc/core.func) +source <(curl -fsSL https://raw.githubusercontent.com/HydroshieldMKII/ProxmoxVED/refs/heads/add-guardian-app/misc/error_handler.func) load_functions catch_errors @@ -32,7 +32,7 @@ verb_ip6() { # # This function handles errors # error_handler() { -# source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/api.func) +# source <(curl -fsSL https://raw.githubusercontent.com/HydroshieldMKII/ProxmoxVED/refs/heads/add-guardian-app/misc/api.func) # local exit_code="$1" # local line_number="$2" # local command="${3:-}" @@ -147,7 +147,7 @@ EOF $STD apt-get -o Dpkg::Options::="--force-confold" -y dist-upgrade rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED msg_ok "Updated Container OS" - source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/tools.func) + source <(curl -fsSL https://raw.githubusercontent.com/HydroshieldMKII/ProxmoxVED/refs/heads/add-guardian-app/misc/tools.func) } # This function modifies the message of the day (motd) and SSH settings @@ -195,7 +195,7 @@ EOF systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') msg_ok "Customized Container" fi - echo "bash -c \"\$(curl -fsSL https://github.com/community-scripts/ProxmoxVED/raw/main/ct/${app}.sh)\"" >/usr/bin/update + echo "bash -c \"\$(curl -fsSL https://github.com/HydroshieldMKII/ProxmoxVED/raw/add-guardian-app/ct/${app}.sh)\"" >/usr/bin/update chmod +x /usr/bin/update if [[ -n "${SSH_AUTHORIZED_KEY}" ]]; then mkdir -p /root/.ssh