--- prog/detect/sensors-detect.orig 2015-08-21 15:22:28.961204079 +0200 +++ prog/detect/sensors-detect 2015-08-21 15:55:32.340333015 +0200 @@ -20,6 +20,9 @@ # MA 02110-1301 USA. # +# Gentoo specific modifications based on a patch from Rudo Thomas +# + require 5.004; use strict; @@ -7055,61 +7058,49 @@ print MODPROBE_D $configfile; close(MODPROBE_D); } else { + print "\nIf you want to load the modules at startup, let this script\n". + "append to your modules config file below.\n"; print "To make the sensors modules behave correctly, add these lines to\n". - "/etc/modprobe.conf:\n\n"; + "/etc/modules.d/lm_sensors and run modules-update:\n\n"; print "#----cut here----\n". $configfile. "#----cut here----\n\n"; } } - my $have_sysconfig = -d '/etc/sysconfig'; - printf "Do you want to \%s /etc/sysconfig/lm_sensors? (\%s): ", - (-e '/etc/sysconfig/lm_sensors' ? 'overwrite' : 'generate'), - ($have_sysconfig ? 'YES/no' : 'yes/NO'); - $_ = read_answer(); - if (($have_sysconfig and not m/^\s*n/i) or m/^\s*y/i) { - unless ($have_sysconfig) { - mkdir('/etc/sysconfig', 0777) - or die "Sorry, can't create /etc/sysconfig ($!)"; - } - open(local *SYSCONFIG, ">/etc/sysconfig/lm_sensors") - or die "Sorry, can't create /etc/sysconfig/lm_sensors ($!)"; - print SYSCONFIG "# Generated by sensors-detect on " . scalar localtime() . "\n"; - print SYSCONFIG <<'EOT'; -# This file is sourced by /etc/init.d/lm_sensors and defines the modules to -# be loaded/unloaded. -# -# The format of this file is a shell script that simply defines variables: -# HWMON_MODULES for hardware monitoring driver modules, and optionally -# BUS_MODULES for any required bus driver module (for example for I2C or SPI). - -EOT - print SYSCONFIG "BUS_MODULES=\"", join(" ", @{$bus_modules}), "\"\n" - if @{$bus_modules}; - print SYSCONFIG "HWMON_MODULES=\"", join(" ", @{$hwmon_modules}), "\"\n"; + my $string = "lm_sensors_detect_modules=\"". + join(" ", (@{$bus_modules}, @{$hwmon_modules})). "\"\n"; + $string .= "# Please add the modules defined in \"lm_sensors_detect_modules\" to the\n". + "# modules list for your kernel.\n". + "# In the most general case the following line will work\n". + "modules=\"\$modules \$lm_sensors_detect_modules\""; + print "This is what should be appended to /etc/conf.d/modules :\n\n". $string . "\n\n"; + + my $have_sysconfig = -f '/etc/conf.d/modules'; + printf "Do you want to ".($have_sysconfig?"append to":"generate"). + " /etc/conf.d/modules? Enter s to specify other file name?\n". + " (".($have_sysconfig?"yes/NO":"YES/no")."/s): "; + my $reply = read_answer(); + + if (($have_sysconfig and $reply =~ /^\s*[Yy]/) or + (not $have_sysconfig and not $reply =~ /^\s*[Nn]/) or + $reply =~ /^\s*[Ss]/) { + my $filename = "/etc/conf.d/modules"; + if ($reply =~ /^\s*[Ss]/) { + print "Specify the file to store the configuration to: "; + $filename = read_answer(); + } + open(local *SYSCONFIG, ">>".$filename) + or die "Sorry, can't create $filename ($!)."; + print SYSCONFIG "\n#\n# Added by sensors-detect on " . scalar localtime() . "\n#\n"; + print SYSCONFIG $string; + print SYSCONFIG "\n#\n# End of sensors-detect section\n#\n"; close(SYSCONFIG); - if (-x "/bin/systemctl" && -d "/lib/systemd/system" && - ! -f "/lib/systemd/system/lm_sensors.service") { - print "Copy prog/init/lm_sensors.service to /lib/systemd/system\n". - "and run 'systemctl enable lm_sensors.service'\n". - "for initialization at boot time.\n"; - return; - } - - if (-x "/bin/systemctl" && - -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; - } - - print "Copy prog/init/lm_sensors.init to /etc/init.d/lm_sensors\n". - "for initialization at boot time.\n" - unless -f "/etc/init.d/lm_sensors"; - + print "Done.\n\n"; + print "Now please review the changes made to /etc/conf.d/modules and make sure\n". + "the modules in \"lm_sensors_detect_modules\" will get loaded. Also check\n". + "that you have only one generated section in your /etc/conf.d/modules!\n\n"; if (-x "/sbin/insserv" && -f "/etc/init.d/lm_sensors") { system("/sbin/insserv", "/etc/init.d/lm_sensors"); } elsif (-x "/sbin/chkconfig" && -f "/etc/init.d/lm_sensors") { @@ -7118,27 +7109,9 @@ system("/sbin/service", "lm_sensors", "start"); } } else { - print "You should now start the lm_sensors service to load the required\n". - "kernel modules.\n\n"; + print "You should now restart the modules service to load the required\n". + "kernel modules.\nRun \'/etc/init.d/modules restart\'\n"; } - } else { - print "To load everything that is needed, add this to one of the system\n". - "initialization scripts (e.g. /etc/rc.d/rc.local):\n\n"; - print "#----cut here----\n"; - if (@{$bus_modules}) { - print "# Adapter drivers\n"; - print "modprobe $_\n" foreach (@{$bus_modules}); - } - print "# Chip drivers\n"; - print "modprobe $_\n" foreach (@{$hwmon_modules}); - print((-e '/usr/bin/sensors' ? - "/usr/bin/sensors -s\n" : - "/usr/local/bin/sensors -s\n"). - "#----cut here----\n\n"); - - print "You really should try these commands right now to make sure everything\n". - "is working properly. Monitoring programs won't work until the needed\n". - "modules are loaded.\n\n"; } }