Skip to content

Commit

Permalink
improve gps autodetect
Browse files Browse the repository at this point in the history
  • Loading branch information
kx1t committed Nov 19, 2023
1 parent f3ebda8 commit b4e344d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions rootfs/etc/s6-overlay/scripts/10-container-init
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source /scripts/common
s6wrap --quiet --timestamps --prepend="$(basename "$0")" --args echo "Starting DireWolf version $(cat /.CONTAINER_VERSION)"
s6wrap --quiet --timestamps --prepend="$(basename "$0")" --args cat << EOM

docker-aprs-tracker - APRS tracker for vehicles using Direwolf, GPSD, and Chrony
docker-aprs-tracker - APRS tracker for vehicles using Direwolf, gpsd, and chrony
---------------------------------------------------------------------------------------------
Copyright (C) 2023, Ramon F. Kolb (kx1t)

Expand All @@ -21,11 +21,11 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more

You should have received a copy of the GNU General Public License along with this program.
If not, see <https://www.gnu.org/licenses/>.
#---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
Among other pieces of software, this container contains:
- Direwolf, Copyright: 2013-2023,John Langner, WB2OSZ; license: GPL-2
- Direwolf, Copyright: 2013-2023, John Langner, WB2OSZ; license: GPL-2
- gpsd, Copyright: 1997-2002, Remco Treffkorn; 2005, Eric S. Raymond; 1997-2018, GPSD project; license: BSD-3-clause
- chrony, Copyright: 2009-2021, Miroslav Lichvar; 1997-2007, Richard P. Curnow; license: GPL-2
#---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
EOM

3 changes: 2 additions & 1 deletion rootfs/etc/s6-overlay/scripts/gpsd
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ if [[ -n "$GPSD_SOCKET" ]]; then GPSD_ARGS+=(--sockfile "$GPSD_SOCKET"); fi
if [[ -n "$GPSD_OPTIONS" ]]; then GPSD_ARGS+=("$GPSD_OPTIONS"); fi
if chk_enabled "$GPSD_USBAUTO"; then
# if the product name of the serial port device has gps or GPS in it, we can figure out the /dev device link for it:
gps_dev="$(find /dev/serial/by-id/ -iname "*gps*" -printf '%l\n' 2>/dev/null | awk -F/ '{print "/dev/" $NF}')"
gps_dev="$(find /dev -iname "gps*" -print | head -1)"
gps_dev="${gps_dev:-$(find /dev/serial/by-id/ -iname "*gps*" -printf '%l\n' 2>/dev/null | awk -F/ '{print "/dev/" $NF}')}"
if [[ -n "$gps_dev" ]]; then
"${s6wrap[@]}" echo "[INFO] GPSD_USBAUTO enabled: GPS device auto-detected on $gps_dev"
else
Expand Down
3 changes: 2 additions & 1 deletion rootfs/etc/s6-overlay/scripts/gpsd-watchdog
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ done
# sometimes it takes a few secs for the new device to become listed
sleep 5

gps_dev_new="$(find /dev/serial/by-id/ -iname "*gps*" -printf '%l\n' 2>/dev/null | awk -F/ '{print "/dev/" $NF}')"
gps_dev_new="$(find /dev -iname "gps*" -print | head -1)"
gps_dev_new="${gps_dev_new:-$(find /dev/serial/by-id/ -iname "*gps*" -printf '%l\n' 2>/dev/null | awk -F/ '{print "/dev/" $NF}')}"

"${s6wrap[@]}" echo "[WARNING] GPS device has changed ports! Old port: ${GPSD_DEVICES} New port: ${gps_dev_new:-unknown}"
"${s6wrap[@]}" echo "[WARNING] Restarting GPSD!"
Expand Down

0 comments on commit b4e344d

Please sign in to comment.