mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-04-05 18:13:50 +00:00
termix: migrate to .env
This commit is contained in:
41
ct/termix.sh
41
ct/termix.sh
@@ -108,6 +108,47 @@ EOF
|
|||||||
systemctl stop termix
|
systemctl stop termix
|
||||||
msg_ok "Stopped Termix"
|
msg_ok "Stopped Termix"
|
||||||
|
|
||||||
|
msg_info "Migrating Configuration"
|
||||||
|
if [[ ! -f /opt/termix/.env ]]; then
|
||||||
|
cat <<EOF >/opt/termix/.env
|
||||||
|
NODE_ENV=production
|
||||||
|
DATA_DIR=/opt/termix/data
|
||||||
|
GUACD_HOST=127.0.0.1
|
||||||
|
GUACD_PORT=4822
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
if ! grep -q "EnvironmentFile" /etc/systemd/system/termix.service 2>/dev/null; then
|
||||||
|
cat <<EOF >/etc/systemd/system/termix.service
|
||||||
|
[Unit]
|
||||||
|
Description=Termix Backend
|
||||||
|
After=network.target guacd.service
|
||||||
|
Wants=guacd.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=root
|
||||||
|
WorkingDirectory=/opt/termix
|
||||||
|
EnvironmentFile=/opt/termix/.env
|
||||||
|
ExecStart=/usr/bin/node /opt/termix/dist/backend/backend/starter.js
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=5
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
systemctl daemon-reload
|
||||||
|
fi
|
||||||
|
cd /opt/termix
|
||||||
|
$STD node -e "
|
||||||
|
const Database = require('better-sqlite3');
|
||||||
|
try {
|
||||||
|
const db = new Database('data/db.sqlite');
|
||||||
|
db.prepare(\"UPDATE settings SET value = '127.0.0.1:4822' WHERE key = 'guac_url' AND value LIKE '%guacd%'\").run();
|
||||||
|
db.close();
|
||||||
|
} catch(e) {}
|
||||||
|
"
|
||||||
|
msg_ok "Migrated Configuration"
|
||||||
|
|
||||||
msg_info "Backing up Data"
|
msg_info "Backing up Data"
|
||||||
cp -r /opt/termix/data /opt/termix_data_backup
|
cp -r /opt/termix/data /opt/termix_data_backup
|
||||||
cp -r /opt/termix/uploads /opt/termix_uploads_backup
|
cp -r /opt/termix/uploads /opt/termix_uploads_backup
|
||||||
|
|||||||
@@ -113,6 +113,13 @@ bind_host = 127.0.0.1
|
|||||||
bind_port = 4822
|
bind_port = 4822
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
cat <<EOF >/opt/termix/.env
|
||||||
|
NODE_ENV=production
|
||||||
|
DATA_DIR=/opt/termix/data
|
||||||
|
GUACD_HOST=127.0.0.1
|
||||||
|
GUACD_PORT=4822
|
||||||
|
EOF
|
||||||
|
|
||||||
cat <<EOF >/etc/systemd/system/guacd.service
|
cat <<EOF >/etc/systemd/system/guacd.service
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Guacamole Proxy Daemon (guacd)
|
Description=Guacamole Proxy Daemon (guacd)
|
||||||
@@ -138,8 +145,7 @@ Wants=guacd.service
|
|||||||
Type=simple
|
Type=simple
|
||||||
User=root
|
User=root
|
||||||
WorkingDirectory=/opt/termix
|
WorkingDirectory=/opt/termix
|
||||||
Environment=NODE_ENV=production
|
EnvironmentFile=/opt/termix/.env
|
||||||
Environment=DATA_DIR=/opt/termix/data
|
|
||||||
ExecStart=/usr/bin/node /opt/termix/dist/backend/backend/starter.js
|
ExecStart=/usr/bin/node /opt/termix/dist/backend/backend/starter.js
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
RestartSec=5
|
RestartSec=5
|
||||||
|
|||||||
Reference in New Issue
Block a user