Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 592916
Collapse All | Expand All

(-)prog/detect/sensors-detect (-46 / +31 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
#
26
# Gentoo specific modifications updated by Chad Joan on 2016-09-07
27
# <chadjoan@gmail.com>
28
23
require 5.004;
29
require 5.004;
24
30
25
use strict;
31
use strict;
Lines 7074-7099 sub write_config Link Here
7074
			print MODPROBE_D $configfile;
7080
			print MODPROBE_D $configfile;
7075
			close(MODPROBE_D);
7081
			close(MODPROBE_D);
7076
		} else {
7082
		} else {
7083
			print "\nIf you want to load the modules at startup, generate a confing file\n".
7084
			      "below and make sure lm_sensors gets started at boot time; e.g\n".
7085
			      "\$ rc-update add lm_sensors default\n";
7077
			print "To make the sensors modules behave correctly, add these lines to\n".
7086
			print "To make the sensors modules behave correctly, add these lines to\n".
7078
			      "/etc/modprobe.conf:\n\n";
7087
			      "/etc/modules.d/lm_sensors and run modules-update:\n\n";
7079
			print "#----cut here----\n".
7088
			print "#----cut here----\n".
7080
			      $configfile.
7089
			      $configfile.
7081
			      "#----cut here----\n\n";
7090
			      "#----cut here----\n\n";
7082
		}
7091
		}
7083
	}
7092
	}
7084
7093
7085
	my $have_sysconfig = -d '/etc/sysconfig';
7094
	my $have_sysconfig = -f '/etc/conf.d/lm_sensors';
7086
	printf "Do you want to \%s /etc/sysconfig/lm_sensors? (\%s): ",
7095
	printf "Do you want to ".($have_sysconfig?"overwrite":"generate").
7087
	       (-e '/etc/sysconfig/lm_sensors' ? 'overwrite' : 'generate'),
7096
	       " /etc/conf.d/lm_sensors? Enter s to specify other file name?\n",
7088
	       ($have_sysconfig ? 'YES/no' : 'yes/NO');
7097
	       "  (".($have_sysconfig?"yes/NO":"YES/no")."/s): ";
7089
	$_ = read_answer();
7098
	my $reply = read_answer();
7090
	if (($have_sysconfig and not m/^\s*n/i) or m/^\s*y/i) {
7099
7091
		unless ($have_sysconfig) {
7100
	if (($have_sysconfig and $reply =~ /^\s*[Yy]/) or
7092
			mkdir('/etc/sysconfig', 0777)
7101
		(not $have_sysconfig and not $reply =~ /^\s*[Nn]/) or
7093
				or die "Sorry, can't create /etc/sysconfig ($!)";
7102
		$reply =~ /^\s*[Ss]/) {
7103
		my $filename = "/etc/conf.d/lm_sensors";
7104
		if ($reply =~ /^\s*[Ss]/) {
7105
			print "Specify the file to store the configuration to: ";
7106
			$filename = read_answer();
7094
		}
7107
		}
7095
		open(local *SYSCONFIG, ">/etc/sysconfig/lm_sensors")
7108
		open(local *SYSCONFIG, ">".$filename)
7096
			or die "Sorry, can't create /etc/sysconfig/lm_sensors ($!)";
7109
			or die "Sorry, can't create $filename ($!).";
7097
		print SYSCONFIG "# Generated by sensors-detect on " . scalar localtime() . "\n";
7110
		print SYSCONFIG "# Generated by sensors-detect on " . scalar localtime() . "\n";
7098
		print SYSCONFIG <<'EOT';
7111
		print SYSCONFIG <<'EOT';
7099
# This file is sourced by /etc/init.d/lm_sensors and defines the modules to
7112
# This file is sourced by /etc/init.d/lm_sensors and defines the modules to
Lines 7104-7130 sub write_config Link Here
7104
# BUS_MODULES for any required bus driver module (for example for I2C or SPI).
7117
# BUS_MODULES for any required bus driver module (for example for I2C or SPI).
7105
7118
7106
EOT
7119
EOT
7120
		print SYSCONFIG
7121
			"# Load modules at startup\n".
7122
			"LOADMODULES=yes\n\n".
7123
			"# Initialize sensors at startup\n".
7124
			"INITSENSORS=yes\n\n";
7107
		print SYSCONFIG "BUS_MODULES=\"", join(" ", @{$bus_modules}), "\"\n"
7125
		print SYSCONFIG "BUS_MODULES=\"", join(" ", @{$bus_modules}), "\"\n"
7108
			if @{$bus_modules};
7126
			if @{$bus_modules};
7109
		print SYSCONFIG "HWMON_MODULES=\"", join(" ", @{$hwmon_modules}), "\"\n";
7127
		print SYSCONFIG "HWMON_MODULES=\"", join(" ", @{$hwmon_modules}), "\"\n";
7110
		close(SYSCONFIG);
7128
		close(SYSCONFIG);
7111
7129
7112
		if ($systemd_systemctl && $systemd_system_dir) {
7130
		print "Done.\n";
7113
			if (-f "$systemd_system_dir/lm_sensors.service") {
7114
				system($systemd_systemctl, "enable", "lm_sensors.service");
7115
				system($systemd_systemctl, "start", "lm_sensors.service");
7116
				# All done, don't check for /etc/init.d/lm_sensors
7117
			} else {
7118
				print "Copy prog/init/lm_sensors.service to $systemd_system_dir\n".
7119
				      "and run 'systemctl enable lm_sensors.service'\n".
7120
				      "for initialization at boot time.\n";
7121
			}
7122
			return;
7123
		}
7124
7125
		print "Copy prog/init/lm_sensors.init to /etc/init.d/lm_sensors\n".
7126
		      "for initialization at boot time.\n"
7127
			unless -f "/etc/init.d/lm_sensors";
7128
7131
7129
		if (-x "/sbin/insserv" && -f "/etc/init.d/lm_sensors") {
7132
		if (-x "/sbin/insserv" && -f "/etc/init.d/lm_sensors") {
7130
			system("/sbin/insserv", "/etc/init.d/lm_sensors");
7133
			system("/sbin/insserv", "/etc/init.d/lm_sensors");
Lines 7137-7160 EOT Link Here
7137
			print "You should now start the lm_sensors service to load the required\n".
7140
			print "You should now start the lm_sensors service to load the required\n".
7138
			      "kernel modules.\n\n";
7141
			      "kernel modules.\n\n";
7139
		}
7142
		}
7140
	} else {
7141
		print "To load everything that is needed, add this to one of the system\n".
7142
		      "initialization scripts (e.g. /etc/rc.d/rc.local):\n\n";
7143
		print "#----cut here----\n";
7144
		if (@{$bus_modules}) {
7145
			print "# Adapter drivers\n";
7146
			print "modprobe $_\n" foreach (@{$bus_modules});
7147
		}
7148
		print "# Chip drivers\n";
7149
		print "modprobe $_\n" foreach (@{$hwmon_modules});
7150
		print((-e '/usr/bin/sensors' ?
7151
		       "/usr/bin/sensors -s\n" :
7152
		       "/usr/local/bin/sensors -s\n").
7153
		      "#----cut here----\n\n");
7154
7155
		print "You really should try these commands right now to make sure everything\n".
7156
		      "is working properly. Monitoring programs won't work until the needed\n".
7157
		      "modules are loaded.\n\n";
7158
	}
7143
	}
7159
}
7144
}
7160
7145

Return to bug 592916