Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 480018 | Differences between
and this patch

Collapse All | Expand All

(-)prog/detect/sensors-detect.orig (-66 / +39 lines)
Lines 20-25 Link Here
20
#    MA 02110-1301 USA.
20
#    MA 02110-1301 USA.
21
#
21
#
22
22
23
# Gentoo specific modifications based on a patch from Rudo Thomas
24
# <thomr9am@ss1000.ms.mff.cuni.cz>
25
23
require 5.004;
26
require 5.004;
24
27
25
use strict;
28
use strict;
Lines 7055-7115 Link Here
7055
			print MODPROBE_D $configfile;
7058
			print MODPROBE_D $configfile;
7056
			close(MODPROBE_D);
7059
			close(MODPROBE_D);
7057
		} else {
7060
		} else {
7061
			print "\nIf you want to load the modules at startup, let this script\n".
7062
			      "append to your modules config file below.\n";
7058
			print "To make the sensors modules behave correctly, add these lines to\n".
7063
			print "To make the sensors modules behave correctly, add these lines to\n".
7059
			      "/etc/modprobe.conf:\n\n";
7064
			      "/etc/modules.d/lm_sensors and run modules-update:\n\n";
7060
			print "#----cut here----\n".
7065
			print "#----cut here----\n".
7061
			      $configfile.
7066
			      $configfile.
7062
			      "#----cut here----\n\n";
7067
			      "#----cut here----\n\n";
7063
		}
7068
		}
7064
	}
7069
	}
7065
7070
7066
	my $have_sysconfig = -d '/etc/sysconfig';
7071
	my $string = "lm_sensors_detect_modules=\"".
7067
	printf "Do you want to \%s /etc/sysconfig/lm_sensors? (\%s): ",
7072
			join(" ", (@{$bus_modules}, @{$hwmon_modules})). "\"\n";
7068
	       (-e '/etc/sysconfig/lm_sensors' ? 'overwrite' : 'generate'),
7073
	$string .= "# Please add the modules defined in \"lm_sensors_detect_modules\" to the\n".
7069
	       ($have_sysconfig ? 'YES/no' : 'yes/NO');
7074
			   "# modules list for your kernel.\n".
7070
	$_ = read_answer();
7075
			   "# In the most general case the following line will work\n".
7071
	if (($have_sysconfig and not m/^\s*n/i) or m/^\s*y/i) {
7076
			   "modules=\"\$modules \$lm_sensors_detect_modules\"";
7072
		unless ($have_sysconfig) {
7077
	print "This is what should be appended to /etc/conf.d/modules :\n\n". $string . "\n\n";
7073
			mkdir('/etc/sysconfig', 0777)
7078
	
7074
				or die "Sorry, can't create /etc/sysconfig ($!)";
7079
	my $have_sysconfig = -f '/etc/conf.d/modules';
7075
		}
7080
	printf "Do you want to ".($have_sysconfig?"append to":"generate").
7076
		open(local *SYSCONFIG, ">/etc/sysconfig/lm_sensors")
7081
	       " /etc/conf.d/modules? Enter s to specify other file name?\n".
7077
			or die "Sorry, can't create /etc/sysconfig/lm_sensors ($!)";
7082
	       "  (".($have_sysconfig?"yes/NO":"YES/no")."/s): ";
7078
		print SYSCONFIG "# Generated by sensors-detect on " . scalar localtime() . "\n";
7083
	my $reply = read_answer();
7079
		print SYSCONFIG <<'EOT';
7084
7080
# This file is sourced by /etc/init.d/lm_sensors and defines the modules to
7085
	if (($have_sysconfig and $reply =~ /^\s*[Yy]/) or
7081
# be loaded/unloaded.
7086
		(not $have_sysconfig and not $reply =~ /^\s*[Nn]/) or
7082
#
7087
		$reply =~ /^\s*[Ss]/) {
7083
# The format of this file is a shell script that simply defines variables:
7088
		my $filename = "/etc/conf.d/modules";
7084
# HWMON_MODULES for hardware monitoring driver modules, and optionally
7089
		if ($reply =~ /^\s*[Ss]/) {
7085
# BUS_MODULES for any required bus driver module (for example for I2C or SPI).
7090
			print "Specify the file to store the configuration to: ";
7086
7091
			$filename = read_answer();
7087
EOT
7092
		}
7088
		print SYSCONFIG "BUS_MODULES=\"", join(" ", @{$bus_modules}), "\"\n"
7093
		open(local *SYSCONFIG, ">>".$filename)
7089
			if @{$bus_modules};
7094
			or die "Sorry, can't create $filename ($!).";
7090
		print SYSCONFIG "HWMON_MODULES=\"", join(" ", @{$hwmon_modules}), "\"\n";
7095
		print SYSCONFIG "\n#\n# Added by sensors-detect on " . scalar localtime() . "\n#\n";
7096
		print SYSCONFIG $string;
7097
		print SYSCONFIG "\n#\n# End of sensors-detect section\n#\n";
7091
		close(SYSCONFIG);
7098
		close(SYSCONFIG);
7092
7099
7093
		if (-x "/bin/systemctl" && -d "/lib/systemd/system" &&
7100
		print "Done.\n\n";
7094
		    ! -f "/lib/systemd/system/lm_sensors.service") {
7101
		print "Now please review the changes made to /etc/conf.d/modules and make sure\n".
7095
			print "Copy prog/init/lm_sensors.service to /lib/systemd/system\n".
7102
			  "the modules in \"lm_sensors_detect_modules\" will get loaded. Also check\n".
7096
			      "and run 'systemctl enable lm_sensors.service'\n".
7103
			  "that you have only one generated section in your /etc/conf.d/modules!\n\n";
7097
			      "for initialization at boot time.\n";
7098
			return;
7099
		}
7100
7101
		if (-x "/bin/systemctl" &&
7102
		    -f "/lib/systemd/system/lm_sensors.service") {
7103
			system("/bin/systemctl", "enable", "lm_sensors.service");
7104
			system("/bin/systemctl", "start", "lm_sensors.service");
7105
			# All done, don't check for /etc/init.d/lm_sensors
7106
			return;
7107
		}
7108
7109
		print "Copy prog/init/lm_sensors.init to /etc/init.d/lm_sensors\n".
7110
		      "for initialization at boot time.\n"
7111
			unless -f "/etc/init.d/lm_sensors";
7112
7113
		if (-x "/sbin/insserv" && -f "/etc/init.d/lm_sensors") {
7104
		if (-x "/sbin/insserv" && -f "/etc/init.d/lm_sensors") {
7114
			system("/sbin/insserv", "/etc/init.d/lm_sensors");
7105
			system("/sbin/insserv", "/etc/init.d/lm_sensors");
7115
		} elsif (-x "/sbin/chkconfig" && -f "/etc/init.d/lm_sensors") {
7106
		} elsif (-x "/sbin/chkconfig" && -f "/etc/init.d/lm_sensors") {
Lines 7118-7144 Link Here
7118
				system("/sbin/service", "lm_sensors", "start");
7109
				system("/sbin/service", "lm_sensors", "start");
7119
			}
7110
			}
7120
		} else {
7111
		} else {
7121
			print "You should now start the lm_sensors service to load the required\n".
7112
			print "You should now restart the modules service to load the required\n".
7122
			      "kernel modules.\n\n";
7113
			      "kernel modules.\nRun \'/etc/init.d/modules restart\'\n";
7123
		}
7114
		}
7124
	} else {
7125
		print "To load everything that is needed, add this to one of the system\n".
7126
		      "initialization scripts (e.g. /etc/rc.d/rc.local):\n\n";
7127
		print "#----cut here----\n";
7128
		if (@{$bus_modules}) {
7129
			print "# Adapter drivers\n";
7130
			print "modprobe $_\n" foreach (@{$bus_modules});
7131
		}
7132
		print "# Chip drivers\n";
7133
		print "modprobe $_\n" foreach (@{$hwmon_modules});
7134
		print((-e '/usr/bin/sensors' ?
7135
		       "/usr/bin/sensors -s\n" :
7136
		       "/usr/local/bin/sensors -s\n").
7137
		      "#----cut here----\n\n");
7138
7139
		print "You really should try these commands right now to make sure everything\n".
7140
		      "is working properly. Monitoring programs won't work until the needed\n".
7141
		      "modules are loaded.\n\n";
7142
	}
7115
	}
7143
}
7116
}
7144
7117

Return to bug 480018