2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-09-01 14:55:27 +00:00

sensors-detect: Fix systemd paths

This commit is contained in:
Jean Delvare
2015-07-06 11:51:24 +00:00
parent 75dbc240d9
commit b26a85f06c
2 changed files with 35 additions and 21 deletions

View File

@@ -1,6 +1,9 @@
lm-sensors CHANGES file lm-sensors CHANGES file
----------------------- -----------------------
SVN HEAD
sensors-detect: Fix systemd paths
3.4.0 (2015-06-25) 3.4.0 (2015-06-25)
documentation: Update the note about libsensors license documentation: Update the note about libsensors license
sensors.conf.5: Enhance the hysteresis documentation sensors.conf.5: Enhance the hysteresis documentation

View File

@@ -2728,7 +2728,7 @@ sub isa_read_i5d6
# AUTODETECTION # # AUTODETECTION #
################# #################
use vars qw($dev_i2c $sysfs_root); use vars qw($dev_i2c $sysfs_root $systemd_systemctl $systemd_system_dir);
sub initialize_conf sub initialize_conf
{ {
@@ -2789,6 +2789,19 @@ sub initialize_conf
exit -1; exit -1;
} }
} }
# Detect systemd presence and paths
if (-x "/usr/bin/systemctl") {
$systemd_systemctl = "/usr/bin/systemctl";
} elsif (-x "/bin/systemctl") {
$systemd_systemctl = "/bin/systemctl";
}
if (-d "/usr/lib/systemd/system") {
$systemd_system_dir = "/usr/lib/systemd/system";
} elsif (-d "/lib/systemd/system") {
$systemd_system_dir = "/lib/systemd/system";
}
} }
# [0] -> VERSION # [0] -> VERSION
@@ -7090,19 +7103,16 @@ EOT
print SYSCONFIG "HWMON_MODULES=\"", join(" ", @{$hwmon_modules}), "\"\n"; print SYSCONFIG "HWMON_MODULES=\"", join(" ", @{$hwmon_modules}), "\"\n";
close(SYSCONFIG); close(SYSCONFIG);
if (-x "/bin/systemctl" && -d "/lib/systemd/system" && if ($systemd_systemctl && $systemd_system_dir) {
! -f "/lib/systemd/system/lm_sensors.service") { if (-f "$systemd_system_dir/lm_sensors.service") {
print "Copy prog/init/lm_sensors.service to /lib/systemd/system\n". system($systemd_systemctl, "enable", "lm_sensors.service");
"and run 'systemctl enable lm_sensors.service'\n". system($systemd_systemctl, "start", "lm_sensors.service");
"for initialization at boot time.\n"; # All done, don't check for /etc/init.d/lm_sensors
return; } else {
} print "Copy prog/init/lm_sensors.service to $systemd_system_dir\n".
"and run 'systemctl enable lm_sensors.service'\n".
if (-x "/bin/systemctl" && "for initialization at boot time.\n";
-f "/lib/systemd/system/lm_sensors.service") { }
system("/bin/systemctl", "enable", "lm_sensors.service");
system("/bin/systemctl", "start", "lm_sensors.service");
# All done, don't check for /etc/init.d/lm_sensors
return; return;
} }
@@ -7170,13 +7180,6 @@ sub main
exit -1; exit -1;
} }
if (-x "/bin/systemctl" && -f "/lib/systemd/system/lm_sensors.service") {
system("/bin/systemctl", "stop", "lm_sensors.service");
} elsif (-x "/sbin/service" && -f "/etc/init.d/lm_sensors" &&
-f "/var/lock/subsys/lm_sensors") {
system("/sbin/service", "lm_sensors", "stop");
}
initialize_kernel_version(); initialize_kernel_version();
initialize_conf(); initialize_conf();
initialize_pci(); initialize_pci();
@@ -7187,6 +7190,14 @@ sub main
initialize_modules_supported(); initialize_modules_supported();
initialize_cpu_list(); initialize_cpu_list();
if ($systemd_systemctl && $systemd_system_dir &&
-f "$systemd_system_dir/lm_sensors.service") {
system("$systemd_systemctl", "stop", "lm_sensors.service");
} elsif (-x "/sbin/service" && -f "/etc/init.d/lm_sensors" &&
-f "/var/lock/subsys/lm_sensors") {
system("/sbin/service", "lm_sensors", "stop");
}
print "# sensors-detect revision $revision\n"; print "# sensors-detect revision $revision\n";
initialize_dmi_data(); initialize_dmi_data();
print_dmi_summary(); print_dmi_summary();