shell-things/etc/systemd/system/geoclue.service.d/gpsd-socket.conf

22 lines
914 B
Plaintext
Raw Normal View History

# 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