Skip to content

Instantly share code, notes, and snippets.

@akoskovacs
Created September 16, 2020 18:54
Show Gist options
  • Save akoskovacs/93715fd7044387d4eb8dcdb77b96dbfb to your computer and use it in GitHub Desktop.
Save akoskovacs/93715fd7044387d4eb8dcdb77b96dbfb to your computer and use it in GitHub Desktop.
Server start/stop/ssh script
#!/bin/bash
# Copy this script to your /usr/local/bin/ /usr/bin, or put its path into PATH
# Customize these:
SERVER_MAC="44:8a:xx:xx:xx:xx"
CLIENT_IFACE="wlp2s0"
SSH_PARAM="user@address"
# ----
myhelp() {
echo " start - Start the server"
echo " stop - Stop the server"
echo " ssh - Connect to the server via SSH"
echo " -h, --help - This help"
}
case "$1" in
start) echo "Starting server..."
sudo etherwake -i $CLIENT_IFACE $SERVER_MAC
;;
stop) echo "Stopping server..."
ssh -t $SSH_PARAM "sudo shutdown now"
;;
ssh) echo "Connecting to server..."
ssh -X $SSH_PARAM
;;
--help|-h) myhelp
;;
*) myhelp
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment