Init app install + json + default ct update
This commit is contained in:
parent
a431ee99e8
commit
f5affeda71
77
ct/guardian.sh
Normal file
77
ct/guardian.sh
Normal file
@ -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}"
|
33
frontend/public/json/guardian.json
Normal file
33
frontend/public/json/guardian.json
Normal file
@ -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": []
|
||||
}
|
101
install/guardian-install.sh
Normal file
101
install/guardian-install.sh
Normal file
@ -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 <<EOF >/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 <<EOF >/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"
|
Loading…
x
Reference in New Issue
Block a user