Lines 176-216shell
176 have python3 || run apt-get install -y python3 python3-venv
177 run python3 -m venv "$VENV"
178 run "$VENV/bin/pip" install --quiet --upgrade pip aiohttp
181if [ -f "$CDIR/console.crt" ] && [ -f "$CDIR/console.key" ]; then
182 log "TLS cert present"
184 log "Generating self-signed TLS cert for $CONSOLE_DOMAIN"
185 run openssl req -x509 -newkey rsa:2048 -nodes -days 3650 \
186 -keyout "$CDIR/console.key" -out "$CDIR/console.crt" -subj "/CN=$CONSOLE_DOMAIN"
189if [ -f "$CDIR/.auth" ]; then
190 log "Admin password already set (.auth present)"
191elif [ "$DRY" = 1 ]; then
192 echo " [dry-run] would set admin password"
194 PW="${ADMIN_PASSWORD:-}"
195 if [ -z "$PW" ]; then
196 read -r -s -p "Console admin password: " PW; echo
197 [ -n "$PW" ] || die "empty password"
199 log "Writing admin password hash"
200 CONSOLE_PW="$PW" "$VPY" - "$CDIR/server.py" "$CDIR/.auth" <<'PY'
201import importlib.util, os, sys
202src, out = sys.argv[1], sys.argv[2]
203spec = importlib.util.spec_from_file_location("console_server", src)
204m = importlib.util.module_from_spec(spec); spec.loader.exec_module(m)
205open(out, "w").write(m.hash_password(os.environ["CONSOLE_PW"]))
207 chmod 600 "$CDIR/.auth"; chown "$CONSOLE_USER" "$CDIR/.auth"
210log "Writing systemd unit station-console.service"
211UNIT=/etc/systemd/system/station-console.service
212if [ "$DRY" = 1 ]; then
213 echo " [dry-run] would write $UNIT (User=$CONSOLE_USER ExecStart=$VPY $CDIR/server.py)"
215 cat > "$UNIT" <<UNITEOF