mirror of
https://github.com/community-scripts/ProxmoxVED.git
synced 2026-02-26 02:55:54 +00:00
Init app install + json + default ct update
This commit is contained in:
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"
|
||||
Reference in New Issue
Block a user