From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from eddie.linux-mips.org ([148.251.95.138] helo=cvs.linux-mips.org) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1ivO9R-0006rj-0g for ptxdist@pengutronix.de; Sat, 25 Jan 2020 17:19:13 +0100 Received: (from localhost user: 'ladis' uid#1021 fake: STDIN (ladis@eddie.linux-mips.org)) by eddie.linux-mips.org id S23990394AbgAYQTJQQhb7 (ORCPT ); Sat, 25 Jan 2020 17:19:09 +0100 Date: Sat, 25 Jan 2020 17:19:08 +0100 From: Ladislav Michl Message-ID: <20200125161908.GA3281@lenoch> MIME-Version: 1.0 Content-Disposition: inline Subject: [ptxdist] [PATCH v2] gpsd: Optionally install systemd unit files List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ptxdist@pengutronix.de Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ptxdist-bounces@pengutronix.de Sender: "ptxdist" To: ptxdist@pengutronix.de Signed-off-by: Ladislav Michl --- Changes: -v2: provide default service files in projectroot Note, udev rules and sysv init script are left as an excercise for respective users (I do not have hardware to test with) :) Also eventual chrony dependency is ommited. projectroot/usr/lib/systemd/system/gpsd.service | 11 +++++++++++ projectroot/usr/lib/systemd/system/gpsd.socket | 15 +++++++++++++++ .../usr/lib/systemd/system/gpsdctl@.service | 12 ++++++++++++ rules/gpsd.in | 11 +++++++++++ rules/gpsd.make | 15 +++++++++++++++ 5 files changed, 64 insertions(+) create mode 100644 projectroot/usr/lib/systemd/system/gpsd.service create mode 100644 projectroot/usr/lib/systemd/system/gpsd.socket create mode 100644 projectroot/usr/lib/systemd/system/gpsdctl@.service diff --git a/projectroot/usr/lib/systemd/system/gpsd.service b/projectroot/usr/lib/systemd/system/gpsd.service new file mode 100644 index 000000000..53c0b96bb --- /dev/null +++ b/projectroot/usr/lib/systemd/system/gpsd.service @@ -0,0 +1,11 @@ +[Unit] +Description=GPS (Global Positioning System) Daemon +Requires=gpsd.socket + +[Service] +Type=forking +ExecStart=/usr/sbin/gpsd @ARGS@ + +[Install] +WantedBy=multi-user.target +Also=gpsd.socket diff --git a/projectroot/usr/lib/systemd/system/gpsd.socket b/projectroot/usr/lib/systemd/system/gpsd.socket new file mode 100644 index 000000000..bc7682116 --- /dev/null +++ b/projectroot/usr/lib/systemd/system/gpsd.socket @@ -0,0 +1,15 @@ +[Unit] +Description=GPS (Global Positioning System) Daemon Sockets + +[Socket] +ListenStream=/var/run/gpsd.sock +ListenStream=[::1]:2947 +ListenStream=127.0.0.1:2947 +# To allow gpsd remote access, start gpsd with the -G option and +# uncomment the next two lines: +# ListenStream=[::1]:2947 +# ListenStream=0.0.0.0:2947 +SocketMode=0600 + +[Install] +WantedBy=sockets.target diff --git a/projectroot/usr/lib/systemd/system/gpsdctl@.service b/projectroot/usr/lib/systemd/system/gpsdctl@.service new file mode 100644 index 000000000..24d291408 --- /dev/null +++ b/projectroot/usr/lib/systemd/system/gpsdctl@.service @@ -0,0 +1,12 @@ +[Unit] +Description=Manage %I for GPS daemon +Requires=gpsd.socket +BindsTo=dev-%i.device +After=dev-%i.device + +[Service] +Type=oneshot +Environment="GPSD_SOCKET=/var/run/gpsd.sock" +RemainAfterExit=yes +ExecStart=/usr/bin/gpsdctl add /dev/%I +ExecStop=/usr/bin/gpsdctl remove /dev/%I diff --git a/rules/gpsd.in b/rules/gpsd.in index ba0edb7bc..e1c4442d6 100644 --- a/rules/gpsd.in +++ b/rules/gpsd.in @@ -256,6 +256,17 @@ menu "install options" queries with a format that is substantially easier to parse than the NMEA 0183 emitted by most GPS receivers. + config GPSD_SYSTEMD_UNIT + bool + default y + depends on INITMETHOD_SYSTEMD && GPSD_GPSD + prompt "systemd unit files for gpsd" + + config GPSD_GPSD_ARGS + string + depends on GPSD_SYSTEMD_UNIT + prompt "gpsd arguments" + config GPSD_GPS2UDP bool prompt "gps2udp" diff --git a/rules/gpsd.make b/rules/gpsd.make index ac95b0af6..e1242eeb7 100644 --- a/rules/gpsd.make +++ b/rules/gpsd.make @@ -162,6 +162,21 @@ $(STATEDIR)/gpsd.targetinstall: ifdef PTXCONF_GPSD_GPSD @$(call install_copy, gpsd, 0, 0, 0755, -, /usr/sbin/gpsd) endif +ifdef PTXCONF_GPSD_SYSTEMD_UNIT + @$(call install_alternative, gpsd, 0, 0, 644, \ + /usr/lib/systemd/system/gpsd.service) + @$(call install_replace, gpsd, \ + /usr/lib/systemd/system/gpsd.service, \ + @ARGS@, $(PTXCONF_GPSD_GPSD_ARGS)) + @$(call install_link, gpsd, ../gpsd.service, \ + /usr/lib/systemd/system/multi-user.target.wants/gpsd.service) + @$(call install_alternative, gpsd, 0, 0, 644, \ + /usr/lib/systemd/system/gpsd.socket) +ifdef PTXCONF_GPSD_GPSCTL + @$(call install_alternative, gpsd, 0, 0, 644, \ + /usr/lib/systemd/system/gpsdctl@.service) +endif +endif ifdef PTXCONF_GPSD_PYTHON @$(call install_glob, gpsd, 0, 0, -, \ /usr/lib/python$(PYTHON3_MAJORMINOR), *.so *.py) -- 2.25.0 _______________________________________________ ptxdist mailing list ptxdist@pengutronix.de