#!/usr/bin/env bash
# x11vnc を環境変数に応じた引数で起動する
set -euo pipefail

COMMON_ARGS=(-display :99 -forever -shared -rfbport 5900 -quiet)

if [ -n "${SCRAPER_VNC_PASSWORD:-}" ] && [ -f /etc/x11vnc.pass ]; then
    exec /usr/bin/x11vnc "${COMMON_ARGS[@]}" -rfbauth /etc/x11vnc.pass
else
    exec /usr/bin/x11vnc "${COMMON_ARGS[@]}" -nopw
fi
