Merge pull request #965 from HydroshieldMKII/add-guardian-app
Add guardian app
This commit is contained in:
commit
f9281d3b3a
79
ct/guardian.sh
Executable file
79
ct/guardian.sh
Executable file
@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env bash
|
||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/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:-6}"
|
||||
var_os="${var_os:-debian}"
|
||||
var_version="${var_version:-13}"
|
||||
var_unprivileged="${var_unprivileged:-1}"
|
||||
|
||||
header_info "$APP"
|
||||
variables
|
||||
color
|
||||
catch_errors
|
||||
|
||||
function update_script() {
|
||||
header_info
|
||||
check_container_storage
|
||||
check_container_resources
|
||||
|
||||
if [[ ! -d "/opt/guardian" ]] ; then
|
||||
msg_error "No ${APP} Installation Found!"
|
||||
exit
|
||||
fi
|
||||
|
||||
if check_for_gh_release "guardian" "HydroshieldMKII/Guardian" ; then
|
||||
msg_info "Stopping Services"
|
||||
systemctl stop guardian-backend guardian-frontend
|
||||
msg_ok "Stopped Services"
|
||||
|
||||
if [[ -f "/opt/guardian/backend/plex-guard.db" ]] ; then
|
||||
msg_info "Saving Database"
|
||||
cp "/opt/guardian/backend/plex-guard.db" "/tmp/plex-guard.db.backup"
|
||||
msg_ok "Database backed up"
|
||||
fi
|
||||
|
||||
cp /opt/guardian/.env /opt
|
||||
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "guardian" "HydroshieldMKII/Guardian" "tarball" "latest" "/opt/guardian"
|
||||
mv /opt/.env /opt/guardian
|
||||
|
||||
if [[ -f "/tmp/plex-guard.db.backup" ]] ; then
|
||||
msg_info "Restoring Database"
|
||||
cp "/tmp/plex-guard.db.backup" "/opt/guardian/backend/plex-guard.db"
|
||||
rm "/tmp/plex-guard.db.backup"
|
||||
msg_ok "Database restored"
|
||||
fi
|
||||
|
||||
msg_info "Updating Guardian"
|
||||
cd /opt/guardian/backend
|
||||
$STD npm ci
|
||||
$STD npm run build
|
||||
|
||||
cd /opt/guardian/frontend
|
||||
$STD npm ci
|
||||
$STD DEPLOYMENT_MODE=standalone npm run build
|
||||
msg_ok "Updated Guardian"
|
||||
|
||||
msg_info "Starting Services"
|
||||
systemctl start guardian-backend guardian-frontend
|
||||
msg_ok "Started Services"
|
||||
msg_ok "Updated Successfully"
|
||||
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}:3000${CL}"
|
35
frontend/public/json/guardian.json
Normal file
35
frontend/public/json/guardian.json
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "Guardian",
|
||||
"slug": "guardian",
|
||||
"categories": [
|
||||
13
|
||||
],
|
||||
"date_created": "2025-09-22",
|
||||
"type": "ct",
|
||||
"updateable": true,
|
||||
"privileged": false,
|
||||
"interface_port": 3000,
|
||||
"documentation": "https://github.com/HydroshieldMKII/Guardian/blob/main/README.md",
|
||||
"config_path": "/opt/guardian/.env",
|
||||
"website": "https://github.com/HydroshieldMKII/Guardian",
|
||||
"logo": null,
|
||||
"description": "Guardian is a lightweight companion app for Plex that lets you monitor, approve or block devices in real time. It helps you enforce per-user or global policies, stop unwanted sessions automatically and grant temporary access - all through a simple web interface.",
|
||||
"install_methods": [
|
||||
{
|
||||
"type": "default",
|
||||
"script": "ct/guardian.sh",
|
||||
"resources": {
|
||||
"cpu": 2,
|
||||
"ram": 2048,
|
||||
"hdd": 6,
|
||||
"os": "Debian",
|
||||
"version": "13"
|
||||
}
|
||||
}
|
||||
],
|
||||
"default_credentials": {
|
||||
"username": null,
|
||||
"password": null
|
||||
},
|
||||
"notes": []
|
||||
}
|
74
install/guardian-install.sh
Normal file
74
install/guardian-install.sh
Normal file
@ -0,0 +1,74 @@
|
||||
#!/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
|
||||
|
||||
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
|
||||
color
|
||||
verb_ip6
|
||||
catch_errors
|
||||
setting_up_container
|
||||
network_check
|
||||
update_os
|
||||
|
||||
msg_info "Installing Dependencies"
|
||||
$STD apt install -y sqlite3
|
||||
msg_ok "Installed Dependencies"
|
||||
|
||||
NODE_VERSION="24" setup_nodejs
|
||||
fetch_and_deploy_gh_release "guardian" "HydroshieldMKII/Guardian" "tarball" "latest" "/opt/guardian"
|
||||
|
||||
msg_info "Configuring ${APPLICATION}"
|
||||
cd /opt/guardian/backend
|
||||
$STD npm ci
|
||||
$STD npm run build
|
||||
cd /opt/guardian/frontend
|
||||
$STD npm ci
|
||||
export DEPLOYMENT_MODE=standalone
|
||||
$STD npm run build
|
||||
msg_ok "Configured {APPLICATION}"
|
||||
|
||||
msg_info "Creating Service"
|
||||
cat <<EOF >/etc/systemd/system/guardian-backend.service
|
||||
[Unit]
|
||||
Description=Guardian Backend
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
WorkingDirectory=/opt/guardian/backend
|
||||
ExecStart=/usr/bin/node dist/main.js
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
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=DEPLOYMENT_MODE=standalone
|
||||
ExecStart=/usr/bin/npm run start
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
systemctl enable -q --now guardian-backend
|
||||
systemctl enable -q --now guardian-frontend
|
||||
msg_ok "Created Service"
|
||||
|
||||
motd_ssh
|
||||
customize
|
||||
|
||||
apt -y autoremove
|
||||
apt -y autoclean
|
||||
apt -y clean
|
||||
msg_ok "Cleaned"
|
Loading…
x
Reference in New Issue
Block a user