No description
Find a file
2025-03-23 13:38:39 +01:00
devices improve logging 2025-03-22 15:42:01 +01:00
routes improve logging 2025-03-22 15:42:01 +01:00
sessions improve logging 2025-03-22 15:42:01 +01:00
.gitignore libgpiod support and better docs 2025-03-22 14:09:00 +01:00
env.go improve logging 2025-03-22 15:42:01 +01:00
go.mod first commit 2025-03-22 13:19:55 +01:00
index.tmpl fix column sizing 2025-03-22 14:20:02 +01:00
LICENSE.md first commit 2025-03-22 13:19:55 +01:00
main.go improve logging 2025-03-22 15:42:01 +01:00
README.md fix readme mistake 2025-03-23 13:38:39 +01:00

WoLBodge

Configuration

Configuration is done using environment variables.

  • WOLBODGE_ADDRESS: The address that WoLBodge should listen on, defaults to :3000.
  • WOLBODGE_STORAGE_TYPE: Storage type to pick, defaults to mem.
    • mem: Sessions are stored in RAM.
  • WOLBODGE_DEVICE_TYPE: Device type to pick, defaults to test.
    • test: A dummy device, used for testing.
    • command: Runs a subprocess to aquire the info. See the example below for more info.

Example: Raspberry pi using the command device

  • WOLBODGE_DEVICE_TYPE=command
  • WOLBODGE_DEVICE_SHELL=bash -c $COMMAND: Configure which shell we should use.
  • WOLBODGE_DEVICE_STATUS_COMMAND=gpioget --bias pull-down gpiochip0 17 > $WOLBODGE_STATUS_FILE: Which command should be used to aquire the device's status. It should echo out a "0" for off and a "1" for on into the file created at "$WOLBODGE_STATUS_FILE".
  • WOLBODGE_DEVICE_TOGGLE_STATUS_COMMAND=gpioset gpiochip0 27=1 && sleep 2 && gpioset gpiochip0 27=0: Which command should be used to toggle the device's status. This usually involves pressing the power button virtually.

Usage example

Usage example for a backup script that backs up to a NAS that isn't online 24/7.

#!/usr/bin/env sh

# Start a new session
session_id=$(curl -s -X POST -F "description=Daily backup" http://localhost:3000/api/session)
exit_code=$?
if [ $exit_code != 0 ]; then
    echo "Failed to create session"
    exit 1
fi

echo "Aquired session with id $session_id"

# 1. Wait for the PC to come online (using a ping-loop for example)
# 2. Do your backup here
sleep 5

# End the session after we are done using it
curl -s -X DELETE http://localhost:3000/api/session/$session_id
exit_code=$?
if [ $exit_code != 0 ]; then
    echo "Failed to delete session"
    exit 1
fi

TODOs

  • Alerts when a session has existed for a long time