This repository contains a Bash script to send a Wake-on-LAN (WOL) signal to a device on your network. The script reads configuration settings from a .env
file, which contains the target device's IP address and MAC address.
-
A Linux environment with Bash support.
-
etherwake
installed for sending WOL packets. You can install it using:sudo apt-get install etherwake
-
Ensure your device supports Wake-on-LAN and is properly configured to accept WOL packets.
-
Clone the repository:
git clone https://github.com/yourusername/wake-on-lan.git cd wake-on-lan
-
Create a
.env
file in the root of the repository with the following format:TARGET_IP=<your_device_ip> TARGET_MAC=<your_device_mac>
Replace
<your_device_ip>
and<your_device_mac>
with the actual IP address and MAC address of the target device.
The provided script performs the following actions:
- Checks for the
.env
file and exports the variables defined within it. - Sends a WOL signal to the specified device using its MAC address.
- Waits for the device to come online by pinging its IP address for up to 120 seconds.
- Outputs the status of the operation, confirming whether the device is online or if a physical check is needed.
-
Make the script executable:
chmod +x wake_on_lan.sh
-
Run the script:
./wake_on_lan.sh
This project is licensed under the GNU General Public License - see the LICENSE file for details.
- This script utilizes
etherwake
for sending Wake-on-LAN packets. - Inspired by various online resources and community contributions to network automation.