Skip to content

adityasanehi/wol-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Wake on LAN Server for Raspberry P

A lightweight Wake on LAN server that can be installed on Raspberry Pi or other lightweight Linux devices.

Features

  • Simple REST API for sending Wake on LAN packets
  • JWT authentication for security
  • Small memory footprint
  • Systemd service for automatic startup
  • CORS configuration for connecting from web applications

Requirements

  • for Raspberry Pi Zero 2W/3/4/5 or other lightweight Linux devices
  • Node.js 12.x or higher
  • Internet connection for installation
  • The server must be on the same network as the devices you want to wake

Installation

  1. Download the latest release and extract it
  2. Run the installer script:
chmod +x install.sh
./install.sh
  1. Edit the configuration file:
sudo nano /opt/wol-server/.env
  1. Set your JWT_SECRET and ALLOWED_ORIGINS in the .env file

Manual Installation

If you prefer to install manually:

  1. Install Node.js if not already installed
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs
  1. Create a directory for the server
sudo mkdir -p /opt/wol-server
  1. Copy files and install dependencies
sudo cp wol-server.js package.json .env.example /opt/wol-server/
sudo mv /opt/wol-server/.env.example /opt/wol-server/.env
cd /opt/wol-server
npm install --production
  1. Create and enable systemd service
sudo nano /etc/systemd/system/wol-server.service
# Copy the service configuration from install.sh
sudo systemctl daemon-reload
sudo systemctl enable wol-server
sudo systemctl start wol-server

API Endpoints

Check Status

GET /api/status

Returns the server status and version.

Wake Device

POST /api/wake
Headers:
  Authorization: Bearer [JWT_TOKEN]
Body:
  {
    "macAddress": "00:11:22:33:44:55",
    "broadcastAddress": "255.255.255.255", (optional)
    "port": 9 (optional)
  }

Integrating with the Main App

To use this WOL server with the main Wake on LAN web app:

  1. In the main app, add your WOL server URL to the device settings
  2. Generate a JWT token with your secret or use the same JWT_SECRET as your main app
  3. Configure ALLOWED_ORIGINS to allow requests from your main app domain

Troubleshooting

  • Check if the service is running:
sudo systemctl status wol-server
  • View logs:
sudo journalctl -u wol-server -f
  • Test API directly:
curl -X GET http://localhost:8080/api/status

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published