Last active
February 21, 2026 01:19
-
-
Save Geofferey/e9486d9a110bead19923f12e6b0291ec to your computer and use it in GitHub Desktop.
A Pineapple Pager payload for connecting to a remote gpsd server
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/bash | |
| # Title: GPSd Remote | |
| # Author: Geofferey | |
| # Description: Connects pager to a remote gpsd server | |
| # Version: 1.0 | |
| ## Simply connects the pager to a remote GPSd server capable of providing coordinates | |
| DEF_PORT=29470 | |
| DEF_HOST=192.168.128.254 | |
| LOG "" | |
| LOG green "Connecting to remote GPSd server..." | |
| LOG "" | |
| # Prompt user for host IP address or name | |
| host=$(TEXT_PICKER "Enter gpsd host" $DEF_HOST) | |
| case $? in | |
| $DUCKYSCRIPT_CANCELLED) | |
| LOG "User cancelled" | |
| exit 1 | |
| ;; | |
| $DUCKYSCRIPT_REJECTED) | |
| LOG "Dialog rejected" | |
| exit 1 | |
| ;; | |
| $DUCKYSCRIPT_ERROR) | |
| LOG "An error occurred" | |
| exit 1 | |
| ;; | |
| esac | |
| # Prompt user for number of pings (optional) | |
| port=$(NUMBER_PICKER "Input port" $DEF_PORT) | |
| case $? in | |
| $DUCKYSCRIPT_CANCELLED) | |
| LOG "User cancelled" | |
| exit 1 | |
| ;; | |
| $DUCKYSCRIPT_REJECTED) | |
| LOG "Using default port: $DEF_PORT" | |
| port=$DEF_PORT | |
| ;; | |
| $DUCKYSCRIPT_ERROR) | |
| LOG "An error occurred, using default port: $DEF_PORT" | |
| port=$DEF_PORT | |
| ;; | |
| esac | |
| killall gpsd | |
| gpsd gpsd://$host:$port | |
| sleep 5 | |
| id=$(START_SPINNER "Checking...") # Only one word, because of bug in 1.0.4 | |
| if timeout 3 gpspipe -r | grep -v '"class":'; then | |
| STOP_SPINNER ${id} | |
| LOG green "GPS data is flowing" | |
| else | |
| STOP_SPINNER ${id} | |
| LOG yellow "No GPS data | |
| restarting gpsd | |
| & checking again" | |
| sleep 1 | |
| id=$(START_SPINNER "Checking...") # Only one word, because of bug in 1.0.4 | |
| killall gpsd | |
| #service gpsd restart | |
| gpsd gpsd://$host:$port | |
| if timeout 3 gpspipe -r | grep -v '"class":'; then | |
| STOP_SPINNER ${id} | |
| LOG green "GPS data is flowing" | |
| else | |
| STOP_SPINNER ${id} | |
| LOG red "Could not get GPS working, please check config or hardware." | |
| exit 1 | |
| fi | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment