Skip to content

Commit eb2c3b7

Browse files
push-app-to-main[bot]MickLeskCrazyWolf13
authored
Guardian (#8365)
* 'Add new script' * Add messages to cleanup commands in guardian-install.sh * refactor --------- Co-authored-by: push-app-to-main[bot] <203845782+push-app-to-main[bot]@users.noreply.github.com> Co-authored-by: CanbiZ <[email protected]> Co-authored-by: Tobias <[email protected]>
1 parent 2d807ee commit eb2c3b7

File tree

4 files changed

+195
-0
lines changed

4 files changed

+195
-0
lines changed

ct/guardian.sh

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/usr/bin/env bash
2+
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: HydroshieldMKII
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://github.com/HydroshieldMKII/Guardian
7+
8+
APP="Guardian"
9+
var_tags="${var_tags:-media;monitoring}"
10+
var_cpu="${var_cpu:-2}"
11+
var_ram="${var_ram:-2048}"
12+
var_disk="${var_disk:-6}"
13+
var_os="${var_os:-debian}"
14+
var_version="${var_version:-13}"
15+
var_unprivileged="${var_unprivileged:-1}"
16+
17+
header_info "$APP"
18+
variables
19+
color
20+
catch_errors
21+
22+
function update_script() {
23+
header_info
24+
check_container_storage
25+
check_container_resources
26+
27+
if [[ ! -d "/opt/guardian" ]] ; then
28+
msg_error "No ${APP} Installation Found!"
29+
exit
30+
fi
31+
32+
if check_for_gh_release "guardian" "HydroshieldMKII/Guardian" ; then
33+
msg_info "Stopping Services"
34+
systemctl stop guardian-backend guardian-frontend
35+
msg_ok "Stopped Services"
36+
37+
if [[ -f "/opt/guardian/backend/plex-guard.db" ]] ; then
38+
msg_info "Backing up Database"
39+
cp "/opt/guardian/backend/plex-guard.db" "/tmp/plex-guard.db.backup"
40+
msg_ok "Backed up Database"
41+
fi
42+
43+
cp /opt/guardian/.env /opt
44+
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "guardian" "HydroshieldMKII/Guardian" "tarball" "latest" "/opt/guardian"
45+
mv /opt/.env /opt/guardian
46+
47+
if [[ -f "/tmp/plex-guard.db.backup" ]] ; then
48+
msg_info "Restoring Database"
49+
cp "/tmp/plex-guard.db.backup" "/opt/guardian/backend/plex-guard.db"
50+
rm "/tmp/plex-guard.db.backup"
51+
msg_ok "Restored Database"
52+
fi
53+
54+
msg_info "Updating Guardian"
55+
cd /opt/guardian/backend
56+
$STD npm ci
57+
$STD npm run build
58+
59+
cd /opt/guardian/frontend
60+
$STD npm ci
61+
$STD DEPLOYMENT_MODE=standalone npm run build
62+
msg_ok "Updated Guardian"
63+
64+
msg_info "Starting Services"
65+
systemctl start guardian-backend guardian-frontend
66+
msg_ok "Started Services"
67+
msg_ok "Updated Successfully"
68+
fi
69+
exit
70+
}
71+
72+
start
73+
build_container
74+
description
75+
76+
msg_ok "Completed Successfully!\n"
77+
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
78+
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
79+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}"

ct/headers/guardian

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
______ ___
2+
/ ____/_ ______ __________/ (_)___ _____
3+
/ / __/ / / / __ `/ ___/ __ / / __ `/ __ \
4+
/ /_/ / /_/ / /_/ / / / /_/ / / /_/ / / / /
5+
\____/\__,_/\__,_/_/ \__,_/_/\__,_/_/ /_/
6+

frontend/public/json/guardian.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "Guardian",
3+
"slug": "guardian",
4+
"categories": [
5+
13
6+
],
7+
"date_created": "2025-09-22",
8+
"type": "ct",
9+
"updateable": true,
10+
"privileged": false,
11+
"interface_port": 3000,
12+
"documentation": "https://github.com/HydroshieldMKII/Guardian/blob/main/README.md",
13+
"config_path": "/opt/guardian/.env",
14+
"website": "https://github.com/HydroshieldMKII/Guardian",
15+
"logo": null,
16+
"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.",
17+
"install_methods": [
18+
{
19+
"type": "default",
20+
"script": "ct/guardian.sh",
21+
"resources": {
22+
"cpu": 2,
23+
"ram": 2048,
24+
"hdd": 6,
25+
"os": "Debian",
26+
"version": "13"
27+
}
28+
}
29+
],
30+
"default_credentials": {
31+
"username": null,
32+
"password": null
33+
},
34+
"notes": []
35+
}

install/guardian-install.sh

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: HydroshieldMKII
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://github.com/HydroshieldMKII/Guardian
7+
8+
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
9+
color
10+
verb_ip6
11+
catch_errors
12+
setting_up_container
13+
network_check
14+
update_os
15+
16+
msg_info "Installing Dependencies"
17+
$STD apt install -y sqlite3
18+
msg_ok "Installed Dependencies"
19+
20+
NODE_VERSION="24" setup_nodejs
21+
fetch_and_deploy_gh_release "guardian" "HydroshieldMKII/Guardian" "tarball" "latest" "/opt/guardian"
22+
23+
msg_info "Configuring ${APPLICATION}"
24+
cd /opt/guardian/backend
25+
$STD npm ci
26+
$STD npm run build
27+
cd /opt/guardian/frontend
28+
$STD npm ci
29+
export DEPLOYMENT_MODE=standalone
30+
$STD npm run build
31+
msg_ok "Configured ${APPLICATION}"
32+
33+
msg_info "Creating Service"
34+
cat <<EOF >/etc/systemd/system/guardian-backend.service
35+
[Unit]
36+
Description=Guardian Backend
37+
After=network.target
38+
39+
[Service]
40+
WorkingDirectory=/opt/guardian/backend
41+
ExecStart=/usr/bin/node dist/main.js
42+
Restart=always
43+
RestartSec=3
44+
[Install]
45+
WantedBy=multi-user.target
46+
EOF
47+
48+
cat <<EOF >/etc/systemd/system/guardian-frontend.service
49+
[Unit]
50+
Description=Guardian Frontend
51+
After=guardian-backend.service network.target
52+
Wants=guardian-backend.service
53+
54+
[Service]
55+
WorkingDirectory=/opt/guardian/frontend
56+
Environment=DEPLOYMENT_MODE=standalone
57+
ExecStart=/usr/bin/npm run start
58+
Restart=always
59+
RestartSec=3
60+
[Install]
61+
WantedBy=multi-user.target
62+
EOF
63+
64+
systemctl enable -q --now guardian-backend
65+
systemctl enable -q --now guardian-frontend
66+
msg_ok "Created Service"
67+
68+
motd_ssh
69+
customize
70+
71+
msg_info "Cleaning up"
72+
$STD apt -y autoremove
73+
$STD apt -y autoclean
74+
$STD apt -y clean
75+
msg_ok "Cleaned"

0 commit comments

Comments
 (0)