From f5affeda71e106951526bd8dddfca2e32770d947 Mon Sep 17 00:00:00 2001 From: Vincent <114195376+HydroshieldMKII@users.noreply.github.com> Date: Mon, 22 Sep 2025 15:46:17 -0400 Subject: [PATCH] Init app install + json + default ct update --- ct/guardian.sh | 77 ++++++++++++++++++++++ frontend/public/json/guardian.json | 33 ++++++++++ install/guardian-install.sh | 101 +++++++++++++++++++++++++++++ 3 files changed, 211 insertions(+) create mode 100644 ct/guardian.sh create mode 100644 frontend/public/json/guardian.json create mode 100644 install/guardian-install.sh diff --git a/ct/guardian.sh b/ct/guardian.sh new file mode 100644 index 00000000..42aaa0bc --- /dev/null +++ b/ct/guardian.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: HydroshieldMKII +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/HydroshieldMKII/Guardian + +APP="Guardian" +var_tags="${var_tags:-media;monitoring}" +var_cpu="${var_cpu:-2}" +var_ram="${var_ram:-2048}" +var_disk="${var_disk:-4}" +var_os="${var_os:-debian}" +var_version="${var_version:-12}" +var_unprivileged="${var_unprivileged:-1}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + # Check if installation is present | -f for file, -d for folder + if [[ ! -d "/opt/${APP}" ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + # Crawling the new version and checking whether an update is required + RELEASE=$(curl -fsSL [RELEASE_URL] | [PARSE_RELEASE_COMMAND]) + if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + # Stopping Services + msg_info "Stopping $APP" + systemctl stop [SERVICE_NAME] + msg_ok "Stopped $APP" + + # Creating Backup + msg_info "Creating Backup" + tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" [IMPORTANT_PATHS] + msg_ok "Backup Created" + + # Execute Update + msg_info "Updating $APP to v${RELEASE}" + [UPDATE_COMMANDS] + msg_ok "Updated $APP to v${RELEASE}" + + # Starting Services + msg_info "Starting $APP" + systemctl start [SERVICE_NAME] + msg_ok "Started $APP" + + # Cleaning up + msg_info "Cleaning Up" + rm -rf [TEMP_FILES] + 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}" + fi + exit +} + +start +build_container +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}" diff --git a/frontend/public/json/guardian.json b/frontend/public/json/guardian.json new file mode 100644 index 00000000..4bc9f6dc --- /dev/null +++ b/frontend/public/json/guardian.json @@ -0,0 +1,33 @@ +{ + "name": "Guardian", + "slug": "guardian", + "categories": [13], + "date_created": "2025-09-22", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 3000, + "documentation": null, + "config_path": "", + "website": "https://github.com/HydroshieldMKII/Guardian", + "logo": null, + "description": "A tool to manage devices access to your Plex server with a nice Dashboard ", + "install_methods": [ + { + "type": "default", + "script": "ct/guardian.sh", + "resources": { + "cpu": 4, + "ram": 2048, + "hdd": 6, + "os": "Debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [] +} diff --git a/install/guardian-install.sh b/install/guardian-install.sh new file mode 100644 index 00000000..77d73eed --- /dev/null +++ b/install/guardian-install.sh @@ -0,0 +1,101 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: HydroshieldMKII +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/HydroshieldMKII/Guardian + +# Import Functions und Setup +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +# Installing Dependencies +msg_info "Installing Dependencies" +$STD apt-get install -y \ + git \ + nodejs \ + npm \ + sqlite +msg_ok "Installed Dependencies" + +# Setup App +msg_info "Setup ${APPLICATION}" +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}" + +# ===== Build Backend ===== +msg_info "Building backend" +cd /opt/${APPLICATION}/backend +npm ci +npm run build +msg_ok "Built backend" + +# ===== Build Frontend ===== +msg_info "Building frontend" +cd /opt/${APPLICATION}/frontend +npm ci +npm run build +msg_ok "Built frontend" + +# ===== Backend Service ===== +msg_info "Creating Backend Service" +cat </etc/systemd/system/guardian-backend.service +[Unit] +Description=Guardian Backend +After=network.target + +[Service] +WorkingDirectory=/opt/Guardian/backend +Environment=NODE_ENV=development +ExecStart=/usr/bin/node dist/main.js +Restart=always +RestartSec=3 + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now guardian-backend +msg_ok "Created Backend Service" + +# ===== Frontend Service ===== +msg_info "Creating Frontend Service" +cat </etc/systemd/system/guardian-frontend.service +[Unit] +Description=Guardian Frontend +After=guardian-backend.service network.target +Wants=guardian-backend.service + +[Service] +WorkingDirectory=/opt/Guardian/frontend +Environment=NODE_ENV=development +ExecStart=/usr/bin/npm run start +Restart=always +RestartSec=3 + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now guardian-frontend +msg_ok "Created Frontend Service" + +motd_ssh +customize + +# Cleanup +msg_info "Cleaning up" +rm -f "${RELEASE}".zip +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned"