mirror of
https://github.com/etiennecollin/unifi-voucher-manager.git
synced 2025-10-23 08:12:15 +00:00
- Also reverted change in run_wrapper.sh where backend variables where overwritten. This is simply not an issue as variables are baked-in at build time.
26 lines
666 B
Bash
26 lines
666 B
Bash
#!/usr/bin/env sh
|
|
|
|
set -e
|
|
|
|
# Set variables accessible by the frontend
|
|
mkdir -p /app/frontend/public
|
|
|
|
# Build runtime-config.js containing only env vars that are defined and non-empty.
|
|
node - <<'NODE'
|
|
const fs = require('fs');
|
|
const outPath = '/app/frontend/public/runtime-config.js';
|
|
const keys = ['WIFI_SSID','WIFI_PASSWORD','WIFI_TYPE','WIFI_HIDDEN'];
|
|
const cfg = {};
|
|
for (const k of keys) {
|
|
const v = process.env[k];
|
|
if (v !== undefined) {
|
|
cfg[k] = v;
|
|
}
|
|
}
|
|
fs.writeFileSync(outPath, 'window.__RUNTIME_CONFIG__ = ' + JSON.stringify(cfg) + ';', 'utf8');
|
|
console.log('WROTE', outPath, 'keys=', Object.keys(cfg));
|
|
NODE
|
|
|
|
# exec the original command
|
|
exec "$@"
|