### Configure GPTWOL Deployment Source: https://context7.com/misterbabou/gptwol/llms.txt Configuration examples for Docker and Nginx, including enabling Layer 2 WOL and setting up reverse proxy subpaths. ```yaml services: gptwol: environment: - ENABLE_L2_WOL_PACKET=true - L2_INTERFACE=eth0 ``` ```yaml services: gptwol: environment: - SCRIPT_NAME=/gptwol ``` ```nginx location /gptwol { proxy_pass http://localhost:5000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } ``` -------------------------------- ### Migrate Computers.txt Location (Shell) Source: https://github.com/misterbabou/gptwol/blob/main/docs/migration.md This script automates the migration of the computers.txt file to the new /app/db path. It stops the Docker containers, creates the new directory, copies the old file if it exists, updates the docker-compose.yml file to reflect the new path, and then restarts the containers. Ensure you are in the root path of your docker-compose.yml. ```shell docker compose down || sudo docker compose down mkdir -p appdata/db || sudo mkdir -p appdata/db 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|' docker-compose.yml) docker compose up -d || sudo docker compose up -d ``` -------------------------------- ### Add Computer API Source: https://context7.com/misterbabou/gptwol/llms.txt Register a new computer in the GPTWOL system. You can specify the computer's name, MAC address, IP address, and the method for checking its status. ```APIDOC ## POST /add_computer ### Description Adds a new computer to the GPTWOL system. This endpoint allows you to register devices with their network details and preferred status check method. ### Method POST ### Endpoint /add_computer ### Parameters #### Request Body - **name** (string) - Required - The name of the computer. - **mac_address** (string) - Required - The MAC address of the computer (e.g., AA:BB:CC:DD:EE:FF). - **ip_address** (string) - Required - The IP address of the computer. - **test_type** (string) - Required - The method for checking the computer's status. Can be 'icmp', 'arp', or a TCP port number (e.g., '22', '3389'). ### Request Example ```bash # Add computer with ICMP check curl -X POST http://localhost:5000/add_computer \ -d "name=Gaming-PC" \ -d "mac_address=AA:BB:CC:DD:EE:FF" \ -d "ip_address=192.168.1.100" \ -d "test_type=icmp" # Add computer with TCP port check curl -X POST http://localhost:5000/add_computer \ -d "name=Web-Server" \ -d "mac_address=11:22:33:44:55:66" \ -d "ip_address=192.168.1.50" \ -d "test_type=22" # Add computer with ARP check curl -X POST http://localhost:5000/add_computer \ -d "name=NAS-Storage" \ -d "mac_address=77:88:99:AA:BB:CC" \ -d "ip_address=192.168.1.200" \ -d "test_type=arp" ``` ### Response #### Success Response (200) - Typically returns a success message or redirects to the dashboard. ``` -------------------------------- ### Configure Authentication Source: https://context7.com/misterbabou/gptwol/llms.txt Sets up security for the web interface using either local credentials or OIDC/SSO integration. ```yaml # Local authentication services: gptwol: environment: - ENABLE_LOGIN=true - USERNAME=admin - PASSWORD=securepassword123 # OIDC authentication services: gptwol: environment: - OIDC_ENABLED=true - OIDC_ISSUER=https://auth.example.com - OIDC_CLIENT_ID=gptwol-client - OIDC_CLIENT_SECRET=your-client-secret - OIDC_REDIRECT_URI=https://gptwol.example.com ``` -------------------------------- ### Manage Computers via API Source: https://context7.com/misterbabou/gptwol/llms.txt Provides endpoints to add, edit, delete, and check the status of computers on the network. ```bash curl -X POST http://localhost:5000/add_computer -d "name=Gaming-PC" -d "mac_address=AA:BB:CC:DD:EE:FF" -d "ip_address=192.168.1.100" -d "test_type=icmp" curl -X POST http://localhost:5000/edit_computer -d "name=Gaming-PC-Updated" -d "mac_address=AA:BB:CC:DD:EE:FF" -d "ip_address=192.168.1.101" -d "test_type=3389" curl -X POST http://localhost:5000/delete_computer -d "mac_address=AA:BB:CC:DD:EE:FF" ``` -------------------------------- ### Initialize and Show Bootstrap Modal Source: https://github.com/misterbabou/gptwol/blob/main/app/templates/generate_modal.html This snippet demonstrates how to initialize a Bootstrap modal instance and display it when the page loads. It relies on the Bootstrap JavaScript library and a modal element with the ID 'messageModal'. ```javascript var myModal = new bootstrap.Modal(document.getElementById('messageModal')); myModal.show(); ``` -------------------------------- ### GPTWOL Environment Variables Reference Source: https://context7.com/misterbabou/gptwol/llms.txt A comprehensive list of environment variables used to configure core settings, authentication, UI features, and network timeouts. ```bash PORT=5000 IP=0.0.0.0 TZ=Europe/Paris LOG_LEVEL=INFO ENABLE_LOGIN=false USERNAME=admin PASSWORD=admin OIDC_ENABLED=false ENABLE_ADD_DEL=true ENABLE_REFRESH=true REFRESH_INTERVAL=30 PING_TIMEOUT=300 ARP_TIMEOUT=300 TCP_TIMEOUT=1 ENABLE_L2_WOL_PACKET=false L2_INTERFACE=eth0 ``` -------------------------------- ### Deploy GPTWOL with Docker Compose Source: https://context7.com/misterbabou/gptwol/llms.txt Configures and runs the GPTWOL container using host networking, which is required for broadcasting magic packets. Includes volume mounts for persistent database and cron job storage. ```yaml 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 - ENABLE_ADD_DEL=true - ENABLE_REFRESH=true - REFRESH_INTERVAL=30 - PING_TIMEOUT=300 - ARP_TIMEOUT=300 - TCP_TIMEOUT=1 volumes: - ./appdata/db:/app/db - ./appdata/cron:/etc/cron.d ``` ```bash docker compose up -d docker logs -f gptwol docker compose down ``` -------------------------------- ### POST /add_wol_cron Source: https://context7.com/misterbabou/gptwol/llms.txt Schedules a Wake-On-LAN packet to be sent at a specific time using cron syntax. ```APIDOC ## POST /add_wol_cron ### Description Schedules a Wake-On-LAN packet to be sent to a target device based on a cron schedule. ### Method POST ### Endpoint /add_wol_cron ### Parameters #### Request Body - **mac_address** (string) - Required - The MAC address of the target machine. - **cron_request** (string) - Required - The cron expression for the schedule. ### Request Example { "mac_address": "AA:BB:CC:DD:EE:FF", "cron_request": "0 8 * * 1-5" } ### Response #### Success Response (200) - **message** (string) - Confirmation of the scheduled task. ``` -------------------------------- ### Jinja2 Templating for GPTWOL Web Interface Source: https://github.com/misterbabou/gptwol/blob/main/app/templates/wol_form.html This Jinja2 template dynamically generates the GPTWOL web interface. It includes logic for displaying computer information, status indicators, scheduling options, and handling user authentication. It also incorporates conditional rendering based on environment variables. ```jinja2 {% if os.environ.get('ENABLE_ADD_DEL') != 'false' -%}* [Add](#) {% endif -%}* [About](#) {% if os.environ.get('ENABLE_LOGIN') == 'true' or os.environ.get('OIDC_ENABLED') == 'true' -%}* [Logout]({{ url_for('logout') }}) {% endif -%}* * [Sort by Name](#) * [Sort by IP](#) * [Sort by MAC](#) {% with messages = get_flashed_messages(with_categories=true) %} {% for category, message in messages %} **{{ category|capitalize }}** {{ message }} {% endfor %} {% endwith %} {% for computer in computers %} {{ computer.name }} IP : {{ computer.ip_address }} MAC : {{ computer.mac_address }} {% if computer.test_type in ['icmp', 'arp'] -%} Check : {{ computer.test_type | upper }} {% else -%} Check : TCP {{ computer.test_type }} {% endif -%} {% if computer.cron_wol_schedule is defined -%} {{ computer.cron_wol_schedule }} {% endif -%} {% if computer.cron_sol_schedule is defined -%} {{ computer.cron_sol_schedule }} {% endif -%} {% if os.environ.get('ENABLE_ADD_DEL') != 'false' -%} {% endif -%} {% endfor %} {% if os.environ.get('ENABLE_ADD_DEL') != 'false' -%} ##### Add Computer Name: MAC address: IP address: Status Check: Scan Network Cancel Add ##### Edit Computer Name: MAC address: IP address: Status Check: Cancel Save ##### Schedule Wake or Sleep Close ##### Confirm Deletion Are you sure you want to delete the ? Cancel Delete ##### Select a Device Scanning in progress... Validate {% endif -%} ##### About [GPTWOL](https://github.com/Misterbabou/gptwol) **Version:** 7.1.4 **License:** MIT Close {% if os.environ.get('ENABLE_ADD_DEL') != 'false' -%} {% endif -%} ``` -------------------------------- ### Configure Sleep-On-LAN Client Source: https://context7.com/misterbabou/gptwol/llms.txt Client-side configuration files for Sleep-On-LAN. Defines listeners and shutdown commands specific to Linux and Windows environments. ```json // Linux (Debian-based) - /etc/sleep-on-lan/sol.json { "Listeners": ["UDP:9"], "LogLevel": "INFO", "Commands": [{"Operation": "shutdown", "Command": "poweroff", "Default": true}] } ``` ```json // Windows - sol.json { "Listeners": ["UDP:9"], "LogLevel": "INFO", "Commands": [{"Operation": "shutdown", "Command": "shutdown /s /t 0 /f", "Default": true}] } ``` -------------------------------- ### POST /add_sol_cron Source: https://context7.com/misterbabou/gptwol/llms.txt Schedules a Sleep-On-LAN (shutdown) packet to be sent at a specific time using cron syntax. ```APIDOC ## POST /add_sol_cron ### Description Schedules a Sleep-On-LAN packet to shut down a target device based on a cron schedule. ### Method POST ### Endpoint /add_sol_cron ### Parameters #### Request Body - **mac_address** (string) - Required - The MAC address of the target machine. - **cron_request** (string) - Required - The cron expression for the schedule. ### Request Example { "mac_address": "AA:BB:CC:DD:EE:FF", "cron_request": "0 18 * * 1-5" } ### Response #### Success Response (200) - **message** (string) - Confirmation of the scheduled task. ``` -------------------------------- ### Edit Computer API Source: https://context7.com/misterbabou/gptwol/llms.txt Update the configuration of an existing computer in the GPTWOL system. The computer is identified by its MAC address. ```APIDOC ## POST /edit_computer ### Description Updates the details of an existing computer in the GPTWOL system. The MAC address is used to identify the computer to be modified. ### Method POST ### Endpoint /edit_computer ### Parameters #### Request Body - **name** (string) - Optional - The new name for the computer. - **mac_address** (string) - Required - The MAC address of the computer to edit. - **ip_address** (string) - Optional - The new IP address of the computer. - **test_type** (string) - Optional - The new method for checking the computer's status. ### Request Example ```bash # Edit computer details curl -X POST http://localhost:5000/edit_computer \ -d "name=Gaming-PC-Updated" \ -d "mac_address=AA:BB:CC:DD:EE:FF" \ -d "ip_address=192.168.1.101" \ -d "test_type=3389" ``` ### Response #### Success Response (200) - Typically returns a success message or redirects to the dashboard. ``` -------------------------------- ### Main Dashboard Source: https://context7.com/misterbabou/gptwol/llms.txt Access the main dashboard which displays all registered computers and their status. This endpoint redirects to the login page if authentication is enabled. ```APIDOC ## GET / ### Description Retrieves the main dashboard of the GPTWOL application, listing all registered computers and their current status. If authentication is enabled, users will be prompted to log in. ### Method GET ### Endpoint / ### Parameters None ### Request Example ```bash curl -X GET http://localhost:5000/ ``` ### Response #### Success Response (200) - HTML page content displaying computer list, status indicators, and control buttons. ``` -------------------------------- ### Send Wake/Sleep Packet API Source: https://context7.com/misterbabou/gptwol/llms.txt Send a Wake-On-LAN (WOL) or Sleep-On-LAN (SOL) magic packet to a computer. The action taken depends on the computer's current status. ```APIDOC ## POST /wol_or_sol_send ### Description Sends a magic packet to the specified computer. If the computer is detected as asleep, a Wake-On-LAN packet is sent. If it's awake, a Sleep-On-LAN packet is sent. ### Method POST ### Endpoint /wol_or_sol_send ### Parameters #### Request Body - **mac_address** (string) - Required - The MAC address of the target computer. ### Request Example ```bash # Send WOL/SOL packet curl -X POST http://localhost:5000/wol_or_sol_send \ -d "mac_address=AA:BB:CC:DD:EE:FF" ``` ### Response #### Success Response (200) - Confirmation message indicating the packet was sent. ``` -------------------------------- ### Trigger Wake/Sleep Actions Source: https://context7.com/misterbabou/gptwol/llms.txt Sends a magic packet to a device. The system automatically determines whether to send a Wake-On-LAN or Sleep-On-LAN packet based on the device's current status. ```bash curl -X POST http://localhost:5000/wol_or_sol_send -d "mac_address=AA:BB:CC:DD:EE:FF" ``` -------------------------------- ### Delete Computer API Source: https://context7.com/misterbabou/gptwol/llms.txt Remove a computer from the GPTWOL system. This action also removes any associated cron schedules for the computer. ```APIDOC ## POST /delete_computer ### Description Removes a computer from the GPTWOL system. All associated data, including cron schedules, will also be deleted. ### Method POST ### Endpoint /delete_computer ### Parameters #### Request Body - **mac_address** (string) - Required - The MAC address of the computer to delete. ### Request Example ```bash # Delete a computer by MAC address curl -X POST http://localhost:5000/delete_computer \ -d "mac_address=AA:BB:CC:DD:EE:FF" ``` ### Response #### Success Response (200) - Typically returns a success message or redirects to the dashboard. ``` -------------------------------- ### Handle Modal Close Button Click Source: https://github.com/misterbabou/gptwol/blob/main/app/templates/generate_modal.html This code sets up an event listener for the 'click' event on a close button with the ID 'closeModalButton'. When clicked, it navigates the user back to the previous page using `window.history.back()`. ```javascript document.getElementById('closeModalButton').addEventListener('click', function() { window.history.back(); }); ``` -------------------------------- ### Check Device Status Source: https://context7.com/misterbabou/gptwol/llms.txt Queries the current power state of a device using various protocols like ICMP, ARP, or TCP port checks. ```bash curl -X GET "http://localhost:5000/check_status?ip_address=192.168.1.100&test_type=icmp" curl -X GET "http://localhost:5000/check_status?ip_address=192.168.1.100&test_type=arp" curl -X GET "http://localhost:5000/check_status?ip_address=192.168.1.100&test_type=22" ``` -------------------------------- ### JavaScript for Real-time Status Updates Source: https://github.com/misterbabou/gptwol/blob/main/app/templates/wol_form.html This JavaScript code periodically updates the status indicators for computers on the network. It retrieves URLs for various actions and uses `setInterval` to call an `updateStatus` function for each computer. The update interval can be configured via environment variables. ```javascript const arp_scan_url = "{{ url_for('arp_scan') }}"; const check_status_url = "{{ url_for('check_status') }}"; const add_wol_cron_url = "{{ url_for('add_wol_cron') }}" const add_sol_cron_url = "{{ url_for('add_sol_cron') }}" const delete_wol_cron_url = "{{ url_for('delete_wol_cron') }}" const delete_sol_cron_url = "{{ url_for('delete_sol_cron') }}" {% if os.environ.get('ENABLE_REFRESH') != 'false' -%} setInterval(() => { // Update the status of all computers for (let element of document.getElementsByClassName('status-indicator')) { const ip_address = element.getAttribute('data-ip-address'); const test_type = element.getAttribute('data-test-type'); // Find the corresponding button element const buttonElement = element.closest('.card').querySelector('.status-power'); updateStatus(ip_address, test_type, element, buttonElement); } {% if os.environ.get('REFRESH_INTERVAL') -%} }, {{ os.environ.get('REFRESH_INTERVAL') | int * 1000 }}); {% else -%} }, 30000); {% endif -%} {% endif -%} ``` -------------------------------- ### Manage Sleep-On-LAN Cron Schedules via Web API Source: https://context7.com/misterbabou/gptwol/llms.txt Use these curl commands to schedule automated shutdown tasks for target computers. The API requires a MAC address and a valid cron string. ```bash curl -X POST http://localhost:5000/add_sol_cron -d "mac_address=AA:BB:CC:DD:EE:FF" -d "cron_request=0 18 * * 1-5" curl -X POST http://localhost:5000/add_sol_cron -d "mac_address=AA:BB:CC:DD:EE:FF" -d "cron_request=0 23 * * *" curl -X POST http://localhost:5000/delete_sol_cron -d "mac_address=AA:BB:CC:DD:EE:FF" ``` -------------------------------- ### Manage Wake-On-LAN Cron Schedules via Web API Source: https://context7.com/misterbabou/gptwol/llms.txt Use these curl commands to add or delete Wake-On-LAN tasks. The API accepts a MAC address and a standard cron expression to define the execution schedule. ```bash curl -X POST http://localhost:5000/add_wol_cron -d "mac_address=AA:BB:CC:DD:EE:FF" -d "cron_request=0 8 * * 1-5" curl -X POST http://localhost:5000/add_wol_cron -d "mac_address=AA:BB:CC:DD:EE:FF" -d "cron_request=30 7 * * *" curl -X POST http://localhost:5000/delete_wol_cron -d "mac_address=AA:BB:CC:DD:EE:FF" ``` -------------------------------- ### POST /delete_wol_cron Source: https://context7.com/misterbabou/gptwol/llms.txt Removes a previously scheduled Wake-On-LAN task for a specific device. ```APIDOC ## POST /delete_wol_cron ### Description Deletes an existing Wake-On-LAN cron schedule for the specified MAC address. ### Method POST ### Endpoint /delete_wol_cron ### Parameters #### Request Body - **mac_address** (string) - Required - The MAC address of the target machine. ### Request Example { "mac_address": "AA:BB:CC:DD:EE:FF" } ### Response #### Success Response (200) - **message** (string) - Confirmation of the deletion. ``` -------------------------------- ### Check Computer Status API Source: https://context7.com/misterbabou/gptwol/llms.txt Query the current status of a computer using various methods like ICMP ping, ARP, or TCP port checks. ```APIDOC ## GET /check_status ### Description Checks the current status of a specified computer using the configured test type (ICMP, ARP, or TCP port). ### Method GET ### Endpoint /check_status ### Parameters #### Query Parameters - **ip_address** (string) - Required - The IP address of the computer to check. - **test_type** (string) - Required - The method to use for checking status. Options: 'icmp', 'arp', or a TCP port number (e.g., '22'). ### Request Example ```bash # Check status via ICMP ping curl -X GET "http://localhost:5000/check_status?ip_address=192.168.1.100&test_type=icmp" # Check status via ARP curl -X GET "http://localhost:5000/check_status?ip_address=192.168.1.100&test_type=arp" # Check status via TCP port (e.g., SSH on port 22) curl -X GET "http://localhost:5000/check_status?ip_address=192.168.1.100&test_type=22" ``` ### Response #### Success Response (200) - **status** (string) - Returns either "awake" or "asleep". ``` -------------------------------- ### ARP Network Scan API Source: https://context7.com/misterbabou/gptwol/llms.txt Scan the local network using ARP to discover devices that are not yet registered within GPTWOL. ```APIDOC ## GET /arp_scan ### Description Initiates an ARP scan of the local network to discover active devices. This is useful for finding devices that may not be registered in the GPTWOL system. ### Method GET ### Endpoint /arp_scan ### Parameters None ### Request Example ```bash # Scan network for new devices curl -X GET http://localhost:5000/arp_scan ``` ### Response #### Success Response (200) - **discovered_devices** (array) - A JSON array containing details of discovered devices, typically including IP address and MAC address. ``` -------------------------------- ### POST /delete_sol_cron Source: https://context7.com/misterbabou/gptwol/llms.txt Removes a previously scheduled Sleep-On-LAN task for a specific device. ```APIDOC ## POST /delete_sol_cron ### Description Deletes an existing Sleep-On-LAN cron schedule for the specified MAC address. ### Method POST ### Endpoint /delete_sol_cron ### Parameters #### Request Body - **mac_address** (string) - Required - The MAC address of the target machine. ### Request Example { "mac_address": "AA:BB:CC:DD:EE:FF" } ### Response #### Success Response (200) - **message** (string) - Confirmation of the deletion. ``` -------------------------------- ### Handle Modal Dismissal Events Source: https://github.com/misterbabou/gptwol/blob/main/app/templates/generate_modal.html This snippet attaches an event listener to the 'hidden.bs.modal' event for the modal element with the ID 'messageModal'. This event fires after the modal has been hidden, and the code redirects the user back to the previous page. ```javascript document.getElementById('messageModal').addEventListener('hidden.bs.modal', function () { window.history.back(); }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.