[PATCH] systemd units rework

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello guys.

The attached patch fixes several things our users complained about.

The patch introduces 3 wrappers for the service files and example
/etc/sysconfig/* configuration files

The lm_sensors-modprobe*wrapper scriptlets change the way how
the modprobe failures look like as the users had no idea that
the failures are caused by missing configuration and that
led to frequent bug reports. The wrapper checks whether the
modprobe is called with any arguments and leaves a hint
message when no modules are passed to the modprobe.

Te sensord-service-wrapper enhances the sensord service so that
it supports all relevant switches needed by the users which
were previously omitted and thus unsupported.

The service files now contain a placeholder for the target
wrapper directory and distribution build scripts can do
the substitution easily with two sed calls ...

Example for RPM based distributions:
sed -i "s|\@WRAPPER_DIR\@|%{_libexecdir}/%{name}|" sensord.service
sed -i "s|\@WRAPPER_DIR\@|%{_libexecdir}/%{name}|" lm_sensors.service

The patch is applicable on the latest trunk.
Please, check it and apply if you find it worthy.

Thank you.

Regards,
Jaromir.

--
Jaromir Capik
Red Hat Czech, s.r.o.
Software Engineer / Secondary Arch

Email: jcapik@xxxxxxxxxx
Web: www.cz.redhat.com
Red Hat Czech s.r.o., Purkynova 99/71, 612 45, Brno, Czech Republic
IC: 27690016 
Index: prog/init/lm_sensors-modprobe-r-wrapper
===================================================================
--- prog/init/lm_sensors-modprobe-r-wrapper	(revision 0)
+++ prog/init/lm_sensors-modprobe-r-wrapper	(working copy)
@@ -0,0 +1,8 @@
+#!/bin/sh
+if [ $# -ne 0 ]; then
+  /usr/sbin/modprobe -abr $@
+else
+  echo "No sensors with loadable kernel modules configured."
+  echo "Please, run 'sensors-detect' as root in order to search for available sensors."
+  exit 1
+fi
Index: prog/init/lm_sensors-modprobe-wrapper
===================================================================
--- prog/init/lm_sensors-modprobe-wrapper	(revision 0)
+++ prog/init/lm_sensors-modprobe-wrapper	(working copy)
@@ -0,0 +1,8 @@
+#!/bin/sh
+if [ $# -ne 0 ]; then
+  /usr/sbin/modprobe -ab $@
+else
+  echo "No sensors with loadable kernel modules configured."
+  echo "Please, run 'sensors-detect' as root in order to search for available sensors."
+  exit 1
+fi
Index: prog/init/lm_sensors.service
===================================================================
--- prog/init/lm_sensors.service	(revision 6214)
+++ prog/init/lm_sensors.service	(working copy)
@@ -1,13 +1,13 @@
 [Unit]
-Description=Initialize hardware monitoring sensors
+Description=Hardware Monitoring Sensors
 
 [Service]
 EnvironmentFile=/etc/sysconfig/lm_sensors
 Type=oneshot
 RemainAfterExit=yes
-ExecStart=-/sbin/modprobe -qab $BUS_MODULES $HWMON_MODULES
+ExecStart=-@WRAPPER_DIR@/lm_sensors-modprobe-wrapper $BUS_MODULES $HWMON_MODULES
 ExecStart=/usr/bin/sensors -s
-ExecStop=-/sbin/modprobe -qabr $BUS_MODULES $HWMON_MODULES
+ExecStop=-@WRAPPER_DIR@/lm_sensors-modprobe-r-wrapper $BUS_MODULES $HWMON_MODULES
 
 [Install]
 WantedBy=multi-user.target
Index: prog/init/lm_sensors.sysconfig
===================================================================
--- prog/init/lm_sensors.sysconfig	(revision 0)
+++ prog/init/lm_sensors.sysconfig	(working copy)
@@ -0,0 +1,2 @@
+# /etc/sysconfig/lm_sensors - Defines modules loaded by the lm_sensors service
+# Run 'sensors-detect' to generate this config file
Index: prog/init/sensord-service-wrapper
===================================================================
--- prog/init/sensord-service-wrapper	(revision 0)
+++ prog/init/sensord-service-wrapper	(working copy)
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+. /etc/sysconfig/sensord
+
+ARGS=""
+[ "$INTERVAL" = "" ] || ARGS=`echo "$ARGS -i $INTERVAL"`
+[ "$LOG_INTERVAL" = "" ] || ARGS=`echo "$ARGS -l $LOG_INTERVAL"`
+[ "$RRD_INTERVAL" = "" ] || ARGS=`echo "$ARGS -t $RRD_INTERVAL"`
+[ "$RRD_LOGFILE" = "" ] || ARGS=`echo "$ARGS -r $RRD_LOGFILE"`
+[ "$RRD_NO_AVG" = "1" ] && ARGS=`echo "$ARGS -T"`
+[ "$LOAD_AVG" = "1" ] && ARGS=`echo "$ARGS -a"`
+
+/usr/sbin/sensord -f daemon $ARGS
Index: prog/init/sensord.service
===================================================================
--- prog/init/sensord.service	(revision 6214)
+++ prog/init/sensord.service	(working copy)
@@ -1,12 +1,12 @@
 [Unit]
-Description=Log hardware monitoring data
+Description=Hardware Monitoring Data Logger
 After=lm_sensors.service
 
 [Service]
-EnvironmentFile=/etc/sysconfig/sensord
+EnvironmentFile=-/etc/sysconfig/sensord
 Type=forking
 PIDFile=/var/run/sensord.pid
-ExecStart=/usr/sbin/sensord -i $INTERVAL -l $LOG_INTERVAL -f daemon
+ExecStart=@WRAPPER_DIR@/sensord-service-wrapper
 
 [Install]
 WantedBy=multi-user.target
Index: prog/init/sensord.sysconfig
===================================================================
--- prog/init/sensord.sysconfig	(revision 0)
+++ prog/init/sensord.sysconfig	(working copy)
@@ -0,0 +1,21 @@
+# configuration for harware sensors monitoring daemon
+# use suffix "m" for minutes, "s" for seconds, "h" for hours
+# 0 turns the facility off
+
+# interval between scanning alarms
+INTERVAL=1m
+
+# interval between logging
+LOG_INTERVAL=20m
+
+# interval between RRD logging
+# RRD_INTERVAL=1m
+
+# RRD db location
+# RRD_LOGFILE=/var/log/sensors.rrd
+
+# Switch RRD in non-average mode ... 1 - enabled, 0 - disabled (default)
+# RRD_NO_AVG=1
+
+# Include load average in RRD ... 1 - enabled, 0 - disabled (default)
+# LOAD_AVG=1
_______________________________________________
lm-sensors mailing list
lm-sensors@xxxxxxxxxxxxxx
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux