GPTWOL Documentation

repository·main·Indexed 18 days ago

https://github.com/misterbabou/gptwol

A lightweight Docker-based GUI for managing Wake-on-LAN (WOL) and Sleep-on-LAN (SOL) operations on a local network. It enables users to wake up, shut down, and monitor the status of computers via a web interface. Features include OIDC authentication, local login, and support for Debian-based and Windows computers via the sleep-on-lan utility.

Tokens
2.1K
Snippets
4
Records
6
Agent score
13%

What's inside GPTWOL

  1. Configure Sleep on Lan (Shutdown)

    main

    GPTWOL sends a reverse MAC Wake-on-LAN packet on port 9 to trigger a shutdown. To enable this, you must install and configure the sleep-on-lan utility on the target computer.

    Debian-based computers

    Create a sol.json file with the following content:

    {
        "Listeners": [
            "UDP:9"
        ],
        "LogLevel": "INFO",
        "Commands": [
            {
                "Operation": "shutdown",
                "Command": "poweroff",
                "Default": true
            }
        ]
    }

    Windows computers

    Create a sol.json file with the following content:

    {
        "Listeners": [
            "UDP:9"
        ],
        "LogLevel": "INFO",
        "Commands": [
            {
                "Operation": "shutdown",
                "Command": "shutdown /s /t 0 /f",
                "Default": true
            }
        ]
    }

    Note for Windows: You must configure the Windows Defender Firewall to allow an Inbound Rule for UDP port 9.

  2. Migrate from GPTWOL 3.0.1 to 4.0.0 or above

    main

    In versions 4.0.0 and above, the computers.txt file is no longer mounted as a standalone file. Instead, it is stored within the /app/db directory inside the container.

    If you see the warning message Computers migration needed, you must move your existing computers.txt file to the new database directory and update your docker-compose.yml configuration. Follow these steps in your docker-compose.yml root path:

    # 1. Stop the current containers
    docker compose down || sudo docker compose down
    
    # 2. Create the new database directory
    mkdir -p appdata/db || sudo mkdir -p appdata/db
    
    # 3. Locate the old computers.txt path from docker-compose.yml, copy it to the new location, and update the compose file
    old_computer_location=$(grep "/app/computers.txt" docker-compose.yml | awk '{print $NF}' | awk -F':' '{print $1}')
    [ -f "$old_computer_location" ] && (cp "$old_computer_location" appdata/db/computers.txt || sudo cp "$old_computer_location" appdata/db/computers.txt) && (sed -i 's|-.*:/app/computers.txt|- ./appdata/db:/app/db|' docker-compose.yml || sudo sed -i 's|-.*:/app/computers.txt|- ./appdata/db:/app/db|')
    
    # 4. Restart the containers
    docker compose up -d || sudo docker compose up -d
  3. Install GPTWOL via Docker CLI

    main

    You can run GPTWOL using a single docker run command. Ensure you use --network="host" so the application can communicate with devices on your LAN.

    docker run -d \
      --name=gptwol \
      --network="host" \
      --restart unless-stopped \
      -e PORT=5000 \
      -e TZ=Europe/Paris \
      -v ./appdata/db:/app/db \
      -v ./appdata/cron:/etc/cron.d \
      misterbabou/gptwol:latest
  4. Install GPTWOL via Docker Compose

    main

    The recommended way to deploy GPTWOL is using Docker Compose.

    Important Requirements:

    • The container must run in host network mode to send Wake-on-LAN packets to your local network.
    • Ensure the PORT you select is free on your host machine.
    • Ensure BIOS settings and the remote OS are configured to allow Wake-on-LAN.
    • Do not expose GPTWOL directly to the internet without enabling authentication.

    Create a docker-compose.yml file with the following configuration:

    services:
      gptwol:
        container_name: gptwol
        image: misterbabou/gptwol:latest
        network_mode: host
        restart: unless-stopped
        environment:
          - TZ=Europe/Paris
          # - PORT=5000
          # - IP=0.0.0.0
          # - LOG_LEVEL=INFO
          # - ENABLE_LOGIN=false
          # - USERNAME=admin
          # - PASSWORD=admin
          # - OIDC_ENABLED=false
          # - OIDC_ISSUER=https://auth.exemple.com
          # - OIDC_CLIENT_ID=oidcclientid
          # - OIDC_CLIENT_SECRET=oidcclientsecret
          # - OIDC_REDIRECT_URI=http(s)://urlofyourgptwol(:port)
          # - SCRIPT_NAME=/my-app
          # - ENABLE_ADD_DEL=true
          # - ENABLE_REFRESH=true
          # - REFRESH_INTERVAL=30
          # - PING_TIMEOUT=300
          # - ARP_INTERFACE=eth0
          # - ARP_TIMEOUT=300
          # - TCP_TIMEOUT=1
          # - ENABLE_L2_WOL_PACKET=false
          # - L2_INTERFACE=eth0
        volumes:
          - ./appdata/db:/app/db
          - ./appdata/cron:/etc/cron.d

    Then run the application with:

    docker compose up -d
  5. Configure OIDC Authentication

    main

    To use OIDC for login, you must configure your OIDC provider with the following Redirect URI: http(s)://yourgptwolurl(:port)/auth/oidc/callback

    Then, set the following environment variables in your Docker configuration:

    • OIDC_ENABLED
    • OIDC_ISSUER (Base URL of the OIDC server, excluding /.well-known/openid-configuration and without a trailing /)
    • OIDC_CLIENT_ID
    • OIDC_CLIENT_SECRET
    • OIDC_REDIRECT_URI (The base URL of your GPTWOL instance)
  6. Reference: GPTWOL Environment Variables

    main

    The following environment variables can be used to configure the GPTWOL Docker container:

    VariableDescription
    TZSet your timezone for Cron (e.g., Europe/Paris). Default is UTC.
    PORTThe port the Web UI listens on. Default is 5000.
    IPApp listening IPv4 or IPv6 address. Default is 0.0.0.0.
    LOG_LEVELLogging level: DEBUG, INFO, WARN, or ERROR.
    ENABLE_LOGINEnable or disable local login (username/password). Default is false.
    USERNAMELocal login username. Default is admin.
    PASSWORDLocal login password. Default is admin.
    OIDC_ENABLEDEnable OIDC login. Default is false.
    OIDC_ISSUERBase URL of the OIDC server.
    OIDC_CLIENT_IDYour OIDC client ID.
    OIDC_CLIENT_SECRETYour OIDC client secret.
    OIDC_REDIRECT_URIBase URL of your GPTWOL instance.
    SCRIPT_NAMEPrefix to run the app under.
    ENABLE_ADD_DELEnable/disable ADD and Delete computer buttons. Default is true.
    ENABLE_REFRESHEnable/disable automatic status refresh. Default is true.
    REFRESH_INTERVALTime between status checks (in seconds). Default is 30.
    PING_TIMEOUTTime to wait for a ping answer (in ms). Default is 300.
    ARP_INTERFACEManual ARP interface for scan and test.
    ARP_TIMEOUTTime to wait for an ARP answer (in ms). Default is 300.
    TCP_TIMEOUTTime to wait for a TCP check (in seconds). Default is 1.
    ENABLE_L2_WOL_PACKETEnable L2 WOL packet instead of L4. Default is false.
    L2_INTERFACEInterface for L2 WOL (required if ENABLE_L2_WOL_PACKET is true). Default is eth0.