No description
devices | ||
routes | ||
sessions | ||
.gitignore | ||
env.go | ||
go.mod | ||
index.tmpl | ||
LICENSE.md | ||
main.go | ||
README.md |
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 tomem
.mem
: Sessions are stored in RAM.
WOLBODGE_DEVICE_TYPE
: Device type to pick, defaults totest
.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