Update Guardian installation and update scripts to use new repository paths and improve dependency management
This commit is contained in:
parent
f5affeda71
commit
552959a39b
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/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
|
# Copyright (c) 2021-2025 community-scripts ORG
|
||||||
# Author: HydroshieldMKII
|
# Author: HydroshieldMKII
|
||||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||||
@ -31,35 +31,49 @@ function update_script() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Crawling the new version and checking whether an update is required
|
# 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
|
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
|
||||||
# Stopping Services
|
# Stopping Services
|
||||||
msg_info "Stopping $APP"
|
msg_info "Stopping $APP"
|
||||||
systemctl stop [SERVICE_NAME]
|
systemctl stop guardian-backend guardian-frontend
|
||||||
msg_ok "Stopped $APP"
|
msg_ok "Stopped $APP"
|
||||||
|
|
||||||
# Creating Backup
|
# Creating Backup
|
||||||
msg_info "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"
|
msg_ok "Backup Created"
|
||||||
|
|
||||||
# Execute Update
|
# Execute Update
|
||||||
msg_info "Updating $APP to v${RELEASE}"
|
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}"
|
msg_ok "Updated $APP to v${RELEASE}"
|
||||||
|
|
||||||
# Starting Services
|
# Starting Services
|
||||||
msg_info "Starting $APP"
|
msg_info "Starting $APP"
|
||||||
systemctl start [SERVICE_NAME]
|
systemctl start guardian-backend guardian-frontend
|
||||||
msg_ok "Started $APP"
|
msg_ok "Started $APP"
|
||||||
|
|
||||||
# Cleaning up
|
# Cleaning up
|
||||||
msg_info "Cleaning Up"
|
msg_info "Cleaning Up"
|
||||||
rm -rf [TEMP_FILES]
|
rm -rf /tmp/"${RELEASE}.zip" /tmp/"Guardian-${RELEASE}"
|
||||||
msg_ok "Cleanup Completed"
|
msg_ok "Cleanup Completed"
|
||||||
|
|
||||||
# Last Action
|
|
||||||
echo "${RELEASE}" >/opt/${APP}_version.txt
|
|
||||||
msg_ok "Update Successful"
|
msg_ok "Update Successful"
|
||||||
else
|
else
|
||||||
msg_ok "No update required. ${APP} is already at v${RELEASE}"
|
msg_ok "No update required. ${APP} is already at v${RELEASE}"
|
||||||
@ -74,4 +88,4 @@ description
|
|||||||
msg_ok "Completed Successfully!\n"
|
msg_ok "Completed Successfully!\n"
|
||||||
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
||||||
echo -e "${INFO}${YW} Access it using the following URL:${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}"
|
||||||
|
@ -20,31 +20,30 @@ $STD apt-get install -y \
|
|||||||
git \
|
git \
|
||||||
nodejs \
|
nodejs \
|
||||||
npm \
|
npm \
|
||||||
sqlite
|
sqlite3 \
|
||||||
|
unzip \
|
||||||
|
curl
|
||||||
msg_ok "Installed Dependencies"
|
msg_ok "Installed Dependencies"
|
||||||
|
|
||||||
# Setup App
|
# 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) }')
|
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"
|
curl -fsSL -o "${RELEASE}.zip" "https://github.com/HydroshieldMKII/Guardian/archive/refs/tags/${RELEASE}.zip"
|
||||||
unzip -q "${RELEASE}.zip"
|
unzip -q "${RELEASE}.zip"
|
||||||
mv "${APPLICATION}-${RELEASE}/" "/opt/${APPLICATION}"
|
mv "Guardian-${RELEASE}/" "/opt/Guardian"
|
||||||
#
|
echo "${RELEASE}" >/opt/Guardian_version.txt
|
||||||
#
|
msg_ok "Setup Guardian"
|
||||||
#
|
|
||||||
echo "${RELEASE}" >/opt/"${APPLICATION}"_version.txt
|
|
||||||
msg_ok "Setup ${APPLICATION}"
|
|
||||||
|
|
||||||
# ===== Build Backend =====
|
# ===== Build Backend =====
|
||||||
msg_info "Building backend"
|
msg_info "Building backend"
|
||||||
cd /opt/${APPLICATION}/backend
|
cd /opt/Guardian/backend
|
||||||
npm ci
|
npm ci
|
||||||
npm run build
|
npm run build
|
||||||
msg_ok "Built backend"
|
msg_ok "Built backend"
|
||||||
|
|
||||||
# ===== Build Frontend =====
|
# ===== Build Frontend =====
|
||||||
msg_info "Building frontend"
|
msg_info "Building frontend"
|
||||||
cd /opt/${APPLICATION}/frontend
|
cd /opt/Guardian/frontend
|
||||||
npm ci
|
npm ci
|
||||||
npm run build
|
npm run build
|
||||||
msg_ok "Built frontend"
|
msg_ok "Built frontend"
|
||||||
|
@ -79,7 +79,7 @@ variables() {
|
|||||||
# [Dd]*)
|
# [Dd]*)
|
||||||
# for file in core.func error_handler.func tools.func; do
|
# for file in core.func error_handler.func tools.func; do
|
||||||
# local_path="$FUNC_DIR/$file"
|
# 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)"
|
# remote_tmp="$(mktemp)"
|
||||||
|
|
||||||
# curl -fsSL "$url" -o "$remote_tmp" || continue
|
# curl -fsSL "$url" -o "$remote_tmp" || continue
|
||||||
|
@ -9,8 +9,8 @@ if ! command -v curl >/dev/null 2>&1; then
|
|||||||
apt-get update >/dev/null 2>&1
|
apt-get update >/dev/null 2>&1
|
||||||
apt-get install -y curl >/dev/null 2>&1
|
apt-get install -y curl >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/core.func)
|
source <(curl -fsSL https://raw.githubusercontent.com/HydroshieldMKII/ProxmoxVED/refs/heads/add-guardian-app/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/error_handler.func)
|
||||||
load_functions
|
load_functions
|
||||||
catch_errors
|
catch_errors
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ verb_ip6() {
|
|||||||
|
|
||||||
# # This function handles errors
|
# # This function handles errors
|
||||||
# error_handler() {
|
# 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 exit_code="$1"
|
||||||
# local line_number="$2"
|
# local line_number="$2"
|
||||||
# local command="${3:-}"
|
# local command="${3:-}"
|
||||||
@ -147,7 +147,7 @@ EOF
|
|||||||
$STD apt-get -o Dpkg::Options::="--force-confold" -y dist-upgrade
|
$STD apt-get -o Dpkg::Options::="--force-confold" -y dist-upgrade
|
||||||
rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED
|
rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED
|
||||||
msg_ok "Updated Container OS"
|
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
|
# 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//')
|
systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//')
|
||||||
msg_ok "Customized Container"
|
msg_ok "Customized Container"
|
||||||
fi
|
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
|
chmod +x /usr/bin/update
|
||||||
if [[ -n "${SSH_AUTHORIZED_KEY}" ]]; then
|
if [[ -n "${SSH_AUTHORIZED_KEY}" ]]; then
|
||||||
mkdir -p /root/.ssh
|
mkdir -p /root/.ssh
|
||||||
|
Loading…
x
Reference in New Issue
Block a user