From 8c30c1d1c3a0844bd94fc008326fa401879dabf6 Mon Sep 17 00:00:00 2001 From: Nikola Pajkovsky Date: Mon, 13 Feb 2012 14:25:43 +0100 Subject: [PATCH] 789761 - Provide native systemd service Signed-off-by: Nikola Pajkovsky --- lm_sensors.spec | 35 ++++++++++++++++------- sensord.init | 76 ------------------------------------------------- sensord.systemd | 11 +++++++ 3 files changed, 36 insertions(+), 86 deletions(-) delete mode 100644 sensord.init create mode 100644 sensord.systemd diff --git a/lm_sensors.spec b/lm_sensors.spec index de339b2..d9ac70a 100644 --- a/lm_sensors.spec +++ b/lm_sensors.spec @@ -1,12 +1,12 @@ Name: lm_sensors Version: 3.3.1 -Release: 2%{?dist} +Release: 3%{?dist} URL: http://www.lm-sensors.org/ Source: http://dl.lm-sensors.org/lm-sensors/releases/%{name}-%{version}.tar.bz2 Source1: lm_sensors.sysconfig # these 2 were taken from PLD-linux, Thanks! Source2: sensord.sysconfig -Source3: sensord.init +Source3: sensord.systemd Summary: Hardware monitoring tools Group: Applications/System License: LGPLv2+ @@ -76,7 +76,9 @@ mkdir -p $RPM_BUILD_ROOT%{_initrddir} mkdir -p $RPM_BUILD_ROOT/lib/systemd/system install -p -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/lm_sensors install -p -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/sensord -install -p -m 755 %{SOURCE3} $RPM_BUILD_ROOT%{_initrddir}/sensord + +# remove it after upstream includes sensord.service in repo +install -p -m 755 %{SOURCE3} $RPM_BUILD_ROOT/lib/systemd/system/sensord.service install -p -m 644 prog/init/lm_sensors.service \ $RPM_BUILD_ROOT/lib/systemd/system @@ -99,13 +101,24 @@ fi %postun libs -p /sbin/ldconfig %post sensord -/sbin/chkconfig --add sensord - -%preun sensord -if [ $1 = 0 ]; then - /sbin/chkconfig --del sensord +if [ $1 -eq 1 ] ; then + # Initial installation + /bin/systemctl daemon-reload >/dev/null 2>&1 || : fi +%preun sensord +if [ $1 -eq 0 ] ; then + # Package removal, not upgrade + /bin/systemctl --no-reload disable sensord.service > /dev/null 2>&1 || : + /bin/systemctl stop sensord.service > /dev/null 2>&1 || : +fi + +%postun +/bin/systemctl daemon-reload >/dev/null 2>&1 || : +if [ $1 -ge 1 ] ; then + # Package upgrade, not uninstall + /bin/systemctl try-restart sensord.service >/dev/null 2>&1 || : +fi %files %defattr(-,root,root,-) @@ -121,7 +134,6 @@ fi %config(noreplace) %{_sysconfdir}/sysconfig/lm_sensors %exclude %{_sbindir}/sensord %exclude %{_mandir}/man8/sensord.8.gz -%dir %{_sysconfdir}/sensors.d %files libs %defattr(-,root,root,-) @@ -138,11 +150,14 @@ fi %doc prog/sensord/README %{_sbindir}/sensord %{_mandir}/man8/sensord.8.gz -%{_initrddir}/sensord %config(noreplace) %{_sysconfdir}/sysconfig/sensord +/lib/systemd/system/sensord.service %changelog +* Mon Feb 13 2012 Nikola Pajkovsky - 3.3.1-3 +- 789761 - Provide native systemd service + * Fri Jan 13 2012 Fedora Release Engineering - 3.3.1-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild diff --git a/sensord.init b/sensord.init deleted file mode 100644 index c3ba38a..0000000 --- a/sensord.init +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/sh -# -# sensord: Hardware sensors monitoring daemon -# -# chkconfig: - 27 73 -# description: Starts and stops hardware sensors monitoring daemon. -# config: /etc/sysconfig/sensord -# author: Filip Kalinski -# adapted for fedora by Hans de Goede - -# Source function library. -. /etc/rc.d/init.d/functions - -# Get service config -if [ -f /etc/sysconfig/sensord ]; then - . /etc/sysconfig/sensord -fi - -prog="sensord" - -start() { - echo -n $"Starting $prog: " - - if [ ! -f /var/lock/subsys/lm_sensors ]; then - echo -n "error lm_sensors service not started" - echo_failure - echo - exit 6 - fi - - daemon sensord \ - ${INTERVAL:+-i $INTERVAL} \ - ${LOG_INTERVAL:+-l $LOG_INTERVAL} \ - ${RRD_LOGFILE:+-r $RRD_LOGFILE} \ - ${RRD_INTERVAL:+-t $RRD_INTERVAL} \ - -f daemon - - RETVAL=$? - echo - [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sensord -} - -stop() { - echo -n $"Stopping $prog: " - - killproc sensord - - RETVAL=$? - echo - [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sensord -} - -RETVAL=0 -# See how we were called. -case "$1" in - start) - start - ;; - stop) - stop - ;; - status) - status sensord - RETVAL=$? - sensors - ;; - restart|force-reload) - stop - start - ;; - *) - msg_usage "$0 {start|stop|restart|force-reload|status}" - exit 3 -esac - -exit $RETVAL diff --git a/sensord.systemd b/sensord.systemd new file mode 100644 index 0000000..4df7ad4 --- /dev/null +++ b/sensord.systemd @@ -0,0 +1,11 @@ +[Unit] +Description=Sensor Information Logging + +[Service] +Type=forking +EnvironmentFile=-/etc/sysconfig/sensord +PIDFile=/run/sensord.pid +ExecStart=/usr/sbin/sensord -i $INTERVAL -l $LOG_INTERVAL -f daemon + +[Install] +WantedBy=multi-user.target