Skip to content

Commit

Permalink
Script for triggering wakeonlan
Browse files Browse the repository at this point in the history
  • Loading branch information
TheKnarf committed Jul 10, 2024
1 parent 1baff30 commit cde226b
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions bin/wol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# Check that homebrew is installed
command -v brew >/dev/null 2>&1 || { \
echo >&2 "Homebrew not install"; \
exit 1; \
}

# Use homebrew to check that wakeonlan is installed
if brew ls --versions wakeonlan > /dev/null; then
echo "wakeonlan allready installed"
else
echo "wakeonlan not installed, run `brew install wakeonlan`"
exit 1
fi

# List of servers to use wakeonlan with
# The list should be pairwise a name and the MAC address of the network card (seperated by tab)
SERVERS=(
"nixos 10:7c:61:41:14:be"
)

# Use fzf to pick a server from the list
MACADDRESS=$(printf '%s\n' "${SERVERS[@]}"|fzf --with-nth 1 --delimiter="\t"|awk '{print $2}')

# Run wakeonlan with the selected mac address for the server
wakeonlan $MACADDRESS

0 comments on commit cde226b

Please sign in to comment.