Blame SOURCES/lm_sensors-3.4.0-fix-systemd-paths.patch

a0074b
From b26a85f06c231e488f99e698861932077aab7be5 Mon Sep 17 00:00:00 2001
a0074b
From: Jean Delvare <khali@linux-fr.org>
a0074b
Date: Mon, 6 Jul 2015 11:51:24 +0000
a0074b
Subject: [PATCH 1/6] sensors-detect: Fix systemd paths
a0074b
a0074b
---
a0074b
 CHANGES                    |  3 +++
a0074b
 prog/detect/sensors-detect | 53 ++++++++++++++++++++++++++++------------------
a0074b
 2 files changed, 35 insertions(+), 21 deletions(-)
a0074b
a0074b
diff --git a/CHANGES b/CHANGES
a0074b
index a33bc42..9a761f5 100644
a0074b
--- a/CHANGES
a0074b
+++ b/CHANGES
a0074b
@@ -1,6 +1,9 @@
a0074b
 lm-sensors CHANGES file
a0074b
 -----------------------
a0074b
 
a0074b
+SVN HEAD
a0074b
+  sensors-detect: Fix systemd paths
a0074b
+
a0074b
 3.4.0 (2015-06-25)
a0074b
   documentation: Update the note about libsensors license
a0074b
   sensors.conf.5: Enhance the hysteresis documentation
a0074b
diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect
a0074b
index fb6658c..6c0c566 100755
a0074b
--- a/prog/detect/sensors-detect
a0074b
+++ b/prog/detect/sensors-detect
a0074b
@@ -2728,7 +2728,7 @@ sub isa_read_i5d6
a0074b
 # AUTODETECTION #
a0074b
 #################
a0074b
 
a0074b
-use vars qw($dev_i2c $sysfs_root);
a0074b
+use vars qw($dev_i2c $sysfs_root $systemd_systemctl $systemd_system_dir);
a0074b
 
a0074b
 sub initialize_conf
a0074b
 {
a0074b
@@ -2789,6 +2789,19 @@ sub initialize_conf
a0074b
 			exit -1;
a0074b
 		}
a0074b
 	}
a0074b
+
a0074b
+	# Detect systemd presence and paths
a0074b
+	if (-x "/usr/bin/systemctl") {
a0074b
+		$systemd_systemctl = "/usr/bin/systemctl";
a0074b
+	} elsif (-x "/bin/systemctl") {
a0074b
+		$systemd_systemctl = "/bin/systemctl";
a0074b
+	}
a0074b
+
a0074b
+	if (-d "/usr/lib/systemd/system") {
a0074b
+		$systemd_system_dir = "/usr/lib/systemd/system";
a0074b
+	} elsif (-d "/lib/systemd/system") {
a0074b
+		$systemd_system_dir = "/lib/systemd/system";
a0074b
+	}
a0074b
 }
a0074b
 
a0074b
 # [0] -> VERSION
a0074b
@@ -7090,19 +7103,16 @@ EOT
a0074b
 		print SYSCONFIG "HWMON_MODULES=\"", join(" ", @{$hwmon_modules}), "\"\n";
a0074b
 		close(SYSCONFIG);
a0074b
 
a0074b
-		if (-x "/bin/systemctl" && -d "/lib/systemd/system" &&
a0074b
-		    ! -f "/lib/systemd/system/lm_sensors.service") {
a0074b
-			print "Copy prog/init/lm_sensors.service to /lib/systemd/system\n".
a0074b
-			      "and run 'systemctl enable lm_sensors.service'\n".
a0074b
-			      "for initialization at boot time.\n";
a0074b
-			return;
a0074b
-		}
a0074b
-
a0074b
-		if (-x "/bin/systemctl" &&
a0074b
-		    -f "/lib/systemd/system/lm_sensors.service") {
a0074b
-			system("/bin/systemctl", "enable", "lm_sensors.service");
a0074b
-			system("/bin/systemctl", "start", "lm_sensors.service");
a0074b
-			# All done, don't check for /etc/init.d/lm_sensors
a0074b
+		if ($systemd_systemctl && $systemd_system_dir) {
a0074b
+			if (-f "$systemd_system_dir/lm_sensors.service") {
a0074b
+				system($systemd_systemctl, "enable", "lm_sensors.service");
a0074b
+				system($systemd_systemctl, "start", "lm_sensors.service");
a0074b
+				# All done, don't check for /etc/init.d/lm_sensors
a0074b
+			} else {
a0074b
+				print "Copy prog/init/lm_sensors.service to $systemd_system_dir\n".
a0074b
+				      "and run 'systemctl enable lm_sensors.service'\n".
a0074b
+				      "for initialization at boot time.\n";
a0074b
+			}
a0074b
 			return;
a0074b
 		}
a0074b
 
a0074b
@@ -7170,13 +7180,6 @@ sub main
a0074b
 		exit -1;
a0074b
 	}
a0074b
 
a0074b
-	if (-x "/bin/systemctl" && -f "/lib/systemd/system/lm_sensors.service") {
a0074b
-		system("/bin/systemctl", "stop", "lm_sensors.service");
a0074b
-	} elsif (-x "/sbin/service" && -f "/etc/init.d/lm_sensors" &&
a0074b
-		 -f "/var/lock/subsys/lm_sensors") {
a0074b
-		system("/sbin/service", "lm_sensors", "stop");
a0074b
-	}
a0074b
-
a0074b
 	initialize_kernel_version();
a0074b
 	initialize_conf();
a0074b
 	initialize_pci();
a0074b
@@ -7187,6 +7190,14 @@ sub main
a0074b
 	initialize_modules_supported();
a0074b
 	initialize_cpu_list();
a0074b
 
a0074b
+	if ($systemd_systemctl && $systemd_system_dir &&
a0074b
+	    -f "$systemd_system_dir/lm_sensors.service") {
a0074b
+		system("$systemd_systemctl", "stop", "lm_sensors.service");
a0074b
+	} elsif (-x "/sbin/service" && -f "/etc/init.d/lm_sensors" &&
a0074b
+		 -f "/var/lock/subsys/lm_sensors") {
a0074b
+		system("/sbin/service", "lm_sensors", "stop");
a0074b
+	}
a0074b
+
a0074b
 	print "# sensors-detect revision $revision\n";
a0074b
 	initialize_dmi_data();
a0074b
 	print_dmi_summary();
a0074b
-- 
a0074b
2.7.4
a0074b