Created
July 11, 2025 23:58
-
-
Save clunkclunk/661ff15d5767ccb796d71971cfe73ffd to your computer and use it in GitHub Desktop.
Bash script to connect tailscale, send a WoL packet to gaming PC, then start a stream
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # get tailscale status | |
| status_json=$(tailscale status --json) | |
| # extract BackendState and Tailnet Name | |
| backend_state=$(echo "$status_json" | jq -r '.BackendState') | |
| tailnet_name=$(echo "$status_json" | jq -r '.CurrentTailnet.Name') | |
| # If backend is stopped but on the correct tailnet, bring it up | |
| if [ "$tailnet_name" = "myemail@mydomain.com" ] && [ "$backend_state" = "Stopped" ]; then | |
| echo "Bringing up tailscale." | |
| tailscale up | |
| sleep 2 | |
| fi | |
| # If not in the correct tailnet, switch and bring up | |
| if [ "$tailnet_name" != "myemail@mydomain.com" ]; then | |
| echo "Switching tailscale accounts." | |
| tailscale switch myemail@mydomain.com | |
| tailscale up | |
| sleep 2 | |
| fi | |
| # send wake command to PC via raspberry pi | |
| echo "Waking up Gaming PC" | |
| ssh raspberrypi.lan '/usr/bin/wakeonlan A8:A1:59:16:63:00' | |
| # start stream | |
| echo "Starting Moonlight -> Steam Big Picture" | |
| /Applications/Moonlight.app/Contents/MacOS/Moonlight stream Gaming-PC "Steam Big Picture" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment