Scanning USB bus.
No start IP, skipping SNMP
Scanning XML/HTTP bus.
No start IP, skipping NUT bus (old connect method)
Scanning IPMI bus.
[nutdev1]
driver = "blazer_usb"
port = "auto"
vendorid = "0665"
productid = "5161"
product = "USB to Serial"
vendor = "INNO TECH"
bus = "003"
Configure Wake-on-LAN (WOL)
This configuration is applied to any device that needs to be remotely powered on automatically after recovering from a power failure. i.e., the Wake-on-LAN clients
You will need to use a Raspberry Pi or a similar low-powered device without a standby power mode for this setup. i.e., no on/off button, turns on once connected to a power source.
This device will serve as the Wake-on-LAN server that sends "power on" signals to all your other devices in the same network after recovering from a power failure.
Create a wake-on-LAN script on your Raspberry Pi that covers all your other devices.
sudo nano /usr/local/bin/wake_devices
Paste the following content:
#!/bin/bash# Wake all devices by sending magic packets using wakeonlan# Logs are saved to a designated folder, including device names# Define the folder to store logsLOG_FOLDER="$HOME/wol_logs"LOG_FILE="$LOG_FOLDER/wol_$(date '+%Y-%m-%d_%H-%M-%S').log"# Create the log folder if it doesn't existmkdir-p"$LOG_FOLDER"# Define a list of devices with their names and MAC addressesdeclare-A devices=( ["testnode"]="aa:bb:cc:dd:ee:ff"# replace with your actual device name and MAC address # Add more devices as needed in the format ["Name"]="MAC")# Start loggingecho"WOL Script started at $(date)">"$LOG_FILE"echo"Log file: $LOG_FILE">>"$LOG_FILE"# Send a WOL packet to each devicefor name in"${!devices[@]}"; do mac="${devices[$name]}"echo"Sending WOL packet to $name ($mac)..."|tee-a"$LOG_FILE"wakeonlan"$mac">>"$LOG_FILE"2>&1if [ $? -eq0 ]; thenecho"Successfully sent WOL packet to $name ($mac)"|tee-a"$LOG_FILE"elseecho"Failed to send WOL packet to $name ($mac)"|tee-a"$LOG_FILE"fidone# End loggingecho"WOL Script finished at $(date)">>"$LOG_FILE"echo"Logs saved to $LOG_FILE"
CTRL+O, ENTER, CTRL+X to save and exit.
Make this script executable.
sudochmod+x/usr/local/bin/wake_devices
We want this script to run automatically whenever our WOL server restarts after a power failure. Create a new systemd service file to run the script at startup.
sudonano/etc/systemd/system/wake_devices.service
Add the following content:
[Unit]Description=Wake-on-LANscripttowakealldevicesAfter=network.target[Service]ExecStartPre=/bin/sleep300ExecStart=/usr/local/bin/wake_devicesRestart=on-failureUser=raspberrypi#use your actual system user here[Install]WantedBy=multi-user.target
We want the WOL script to run only after all your other devices have completely turned off in the event of a instant recovery following a power failure, which will cause this script to fail its purpose. Hence the deliberate 300 second delay imposed in this service file via /bin/sleep 300
This is useful as a backup to the automated WOL setup above in case you need to manually "wake up" your devices remote after recovery from a power failure.
Key Features:
Does not require opening ports to each of your devices
Conveniently "wakes up" all your devices via Telegram. i.e., without needing to download new apps
Run on your Wake-on-LAN server. e.g., Raspberry Pi that runs 24/7
Requires the "Setup an automated Wake-on-LAN server" sub-section above to be completed
Create a new Telegram bot by following the steps below.
Open Telegram and Message the BotFather:
Search for "BotFather" in Telegram and start a conversation.
Create a New Bot:
Send /newbot to the BotFather.
Follow the instructions in the BotFather chat to name your bot and get its API token.
Save the API Token:
Example token: 123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZ.
Add the Bot to Your Private Group:
Invite the bot to your Telegram group.
Get Your Chat ID:
Use the bot to retrieve the chat ID:
Send a message in your group.
Navigate to https://api.telegram.org/bot<YourBOTToken>/getUpdates on your browser while replaceing <YourBOTToken> with your actual Telegram bot API token
[Unit]Description=TelegramBotforWake-on-LANAfter=network.target[Service]ExecStart=/usr/bin/python3/usr/local/bin/TG_WOL_BOT/WOL_bot.pyRestart=alwaysUser=raspberrypi#use your actual system user here[Install]WantedBy=multi-user.target