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

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