# wol-vbox-helper

Wake-on-LAN listener that starts configured VirtualBox VMs when a matching magic packet is received.

## Project structure

- `source/`: all files required to build the application
  - `main.go`
  - `go.mod`
  - `go.sum`
  - `config.yaml`
- `dist/`: build output
  - `virtualbox-vm-wol.exe`
  - `config.yaml`

## Requirements

- Windows
- Go `1.25.6` (for reproducible builds, use exactly this version)
- Oracle VirtualBox with `VBoxManage.exe`

## Build

Run from the project root:

```powershell
.\source\build.ps1
```

This generates `dist\virtualbox-vm-wol.exe` and ensures `dist\config.yaml` is present.

The script uses reproducible build settings:

- `CGO_ENABLED=0`
- `-trimpath`
- `-buildvcs=false`
- `-ldflags "-buildid="`

To get byte-identical outputs, use the same Go toolchain version and target platform (`GOOS`/`GOARCH`).

## Configuration

Edit `source/config.yaml` (or `dist/config.yaml` after building):

- `listen.address`: UDP bind address (for example `0.0.0.0`)
- `listen.port`: UDP port for Wake-on-LAN packets (commonly `9`)
- `virtualbox.vboxmanage`: full path to `VBoxManage.exe`
- `vms`: list of VMs with `name` and `mac`

## Run

Run from `dist/` so the executable can load `config.yaml` from the current directory:

```powershell
Set-Location .\dist
.\virtualbox-vm-wol.exe
```

## Run As Windows Service (Servy)

You can use `Servy` to run `virtualbox-vm-wol.exe` as a Windows service.

Recommended service settings in Servy:

- Service executable: `D:\Codex\VirtualBox-VM-Wol\dist\virtualbox-vm-wol.exe`
- Working directory: `D:\Codex\VirtualBox-VM-Wol\dist`
- Startup type: `Automatic`
- Service account: an account that can access `VBoxManage.exe` and control your VirtualBox VMs

After creating the service in Servy, start it from Servy or Windows Services (`services.msc`).
