| | import os |
| | import subprocess |
| | import time |
| | import signal |
| | import sys |
| |
|
| | def run_command(command, background=True): |
| | print(f"Starting: {command}") |
| | if background: |
| | return subprocess.Popen(command, shell=True) |
| | else: |
| | return subprocess.run(command, shell=True) |
| |
|
| | def main(): |
| | |
| | |
| | resolution = os.environ.get('RESOLUTION', '1280x720') |
| | xvfb_cmd = f"Xvfb :0 -screen 0 {resolution}x24" |
| | xvfb_process = run_command(xvfb_cmd) |
| | |
| | |
| | time.sleep(2) |
| |
|
| | |
| | |
| | run_command("fluxbox") |
| |
|
| | |
| | |
| | run_command("x11vnc -display :0 -forever -shared -rfbport 5900 -nopw") |
| |
|
| | |
| | |
| | |
| | novnc_cmd = "websockify --web /usr/share/novnc 7860 localhost:5900" |
| | run_command(novnc_cmd) |
| |
|
| | |
| | |
| | |
| | |
| | print("Starting Brave Browser...") |
| | brave_cmd = ( |
| | "brave-browser " |
| | "--no-sandbox " |
| | "--disable-dev-shm-usage " |
| | "--kiosk " |
| | "--start-maximized " |
| | "--user-data-dir=/home/user/brave-data " |
| | "https://www.google.com" |
| | ) |
| | |
| | |
| | |
| | brave_process = subprocess.Popen(brave_cmd, shell=True) |
| |
|
| | try: |
| | |
| | while True: |
| | time.sleep(1) |
| | if brave_process.poll() is not None: |
| | print("Brave exited. Restarting...") |
| | brave_process = subprocess.Popen(brave_cmd, shell=True) |
| | except KeyboardInterrupt: |
| | print("Stopping services...") |
| | xvfb_process.terminate() |
| | brave_process.terminate() |
| | sys.exit(0) |
| |
|
| | if __name__ == "__main__": |
| | main() |