Skip to content

Commit dff876f

Browse files
committed
termix: migrate to .env
1 parent 02e7e5a commit dff876f

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

ct/termix.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,47 @@ EOF
108108
systemctl stop termix
109109
msg_ok "Stopped Termix"
110110

111+
msg_info "Migrating Configuration"
112+
if [[ ! -f /opt/termix/.env ]]; then
113+
cat <<EOF >/opt/termix/.env
114+
NODE_ENV=production
115+
DATA_DIR=/opt/termix/data
116+
GUACD_HOST=127.0.0.1
117+
GUACD_PORT=4822
118+
EOF
119+
fi
120+
if ! grep -q "EnvironmentFile" /etc/systemd/system/termix.service 2>/dev/null; then
121+
cat <<EOF >/etc/systemd/system/termix.service
122+
[Unit]
123+
Description=Termix Backend
124+
After=network.target guacd.service
125+
Wants=guacd.service
126+
127+
[Service]
128+
Type=simple
129+
User=root
130+
WorkingDirectory=/opt/termix
131+
EnvironmentFile=/opt/termix/.env
132+
ExecStart=/usr/bin/node /opt/termix/dist/backend/backend/starter.js
133+
Restart=on-failure
134+
RestartSec=5
135+
136+
[Install]
137+
WantedBy=multi-user.target
138+
EOF
139+
systemctl daemon-reload
140+
fi
141+
cd /opt/termix
142+
$STD node -e "
143+
const Database = require('better-sqlite3');
144+
try {
145+
const db = new Database('data/db.sqlite');
146+
db.prepare(\"UPDATE settings SET value = '127.0.0.1:4822' WHERE key = 'guac_url' AND value LIKE '%guacd%'\").run();
147+
db.close();
148+
} catch(e) {}
149+
"
150+
msg_ok "Migrated Configuration"
151+
111152
msg_info "Backing up Data"
112153
cp -r /opt/termix/data /opt/termix_data_backup
113154
cp -r /opt/termix/uploads /opt/termix_uploads_backup

install/termix-install.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ bind_host = 127.0.0.1
113113
bind_port = 4822
114114
EOF
115115

116+
cat <<EOF >/opt/termix/.env
117+
NODE_ENV=production
118+
DATA_DIR=/opt/termix/data
119+
GUACD_HOST=127.0.0.1
120+
GUACD_PORT=4822
121+
EOF
122+
116123
cat <<EOF >/etc/systemd/system/guacd.service
117124
[Unit]
118125
Description=Guacamole Proxy Daemon (guacd)
@@ -138,8 +145,7 @@ Wants=guacd.service
138145
Type=simple
139146
User=root
140147
WorkingDirectory=/opt/termix
141-
Environment=NODE_ENV=production
142-
Environment=DATA_DIR=/opt/termix/data
148+
EnvironmentFile=/opt/termix/.env
143149
ExecStart=/usr/bin/node /opt/termix/dist/backend/backend/starter.js
144150
Restart=on-failure
145151
RestartSec=5

0 commit comments

Comments
 (0)