systemd: move gpsd nmea socket from gpsd to geoclue

This commit is contained in:
Aminda Suomalainen 2024-07-19 10:13:55 +03:00
parent bcdd54426c
commit a8530221aa
Signed by: Mikaela
SSH Key Fingerprint: SHA256:CXLULpqNBdUKB6E6fLA1b/4SzG0HvKD19PbIePU175Q
3 changed files with 23 additions and 9 deletions

View File

@ -1,4 +1,4 @@
[network-nmea]
enable=true
# Refer to ../../systemd/system/gpsd.service.d/aminda-additions.conf
nmea-socket=/var/run/gps-share.sock
# Refer to ../../systemd/system/geoclue.service.d/gpsd-socket.conf
nmea-socket=/tmp/gps-share.sock

View File

@ -0,0 +1,21 @@
# systemd drop-in for ensuring geoclue has a socket to get GPS location from
# Weak dependency of geoclue pulling gpsd on so gpspipe might work?
[Unit]
Wants=gpsd.service gpsd.socket
# NOTE: /tmp is not /tmp, because the unit has systemd PrivateTmp. And
# SELINUX dislikes this, so
# ausearch -c 'geoclue' --raw | audit2allow -M my-geoclue
# semodule -X 300 -i my-geoclue.pp
[Service]
# Handle failure situation of the socket not going away (ExecStartPost=)
ExecStartPre=-/tmp/gps-share.sock
# Creating a socket for geoclue to connect to
# Credit: @schnell at https://gitlab.freedesktop.org/geoclue/geoclue/-/issues/145#note_1772702
ExecStartPost=/bin/sh -c "(gpspipe --nmea | ( read; read; read; cat ) | ncat --verbose --keep-open --listen --unixsock /tmp/gps-share.sock&)"
# In case of clean shutdown, remove the socket for restart
ExecStopPost=-/usr/bin/rm -vf /tmp/gps-share.sock
# vim: filetype=systemd

View File

@ -6,17 +6,10 @@ Type=exec
EnvironmentFile=-/etc/gpsd.aminda.conf
# Kernel module possibly required for USB GPS devices especially with Chrony?
ExecStartPre=-/usr/sbin/modprobe pps_ldisc
# Handle failure situation of the socket not going away (ExecStartPost=)
ExecStartPre=-/usr/bin/rm -vf /var/run/gps-share.sock
# Empty ExecStart= before the actual ExecStart= removes the original
# ExecStart= line
ExecStart=
ExecStart=/usr/sbin/gpsd /dev/gps0 --nowait --foreground $AMINDAGPSD
# Creating a socket for geoclue to connect to
# Credit: @schnell at https://gitlab.freedesktop.org/geoclue/geoclue/-/issues/145#note_1772702
ExecStartPost=/bin/sh -c "(sleep 5 && gpspipe --nmea | ( read; read; read; cat ) | ncat --verbose --keep-open --listen --unixsock /var/run/gps-share.sock&)"
# In case of clean shutdown, remove the socket for restart
ExecStopPost=-/usr/bin/rm -vf /var/run/gps-share.sock
# Missing from the original unit, will reconnect all GPS says man gpsd
ExecReload=/usr/bin/killall -HUP gpsd
# Avoiding systemd considering the unit as failed.