--- prog/detect/sensors-detect | 101 +++++++++++++-------------------------------- 1 file changed, 30 insertions(+), 71 deletions(-) --- a/prog/detect/sensors-detect +++ b/prog/detect/sensors-detect @@ -1,4 +1,4 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl # # sensors-detect - Detect hardware monitoring chips # Copyright (C) 1998 - 2002 Frodo Looijaard @@ -7344,80 +7344,39 @@ } } - 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"; - close(SYSCONFIG); - - if ($systemd_systemctl && $systemd_system_dir) { - if (-f "$systemd_system_dir/lm_sensors.service") { - system($systemd_systemctl, "enable", "lm_sensors.service"); - system($systemd_systemctl, "start", "lm_sensors.service"); - # All done, don't check for /etc/init.d/lm_sensors - } else { - print "Copy prog/init/lm_sensors.service to $systemd_system_dir\n". - "and run 'systemctl enable lm_sensors.service'\n". - "for initialization at boot time.\n"; - } - return; - } + print "To load everything that is needed, add this to /etc/modules:\n"; + print "#----cut here----\n"; + if (@{$bus_modules}) { + print "# Adapter drivers\n"; + print "$_\n" foreach (@{$bus_modules}); + } + print "# Chip drivers\n"; + print "$_\n" foreach (@{$hwmon_modules}); + print "#----cut here----\n"; - 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"; - - 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") { - system("/sbin/chkconfig", "lm_sensors", "on"); - if (-x "/sbin/service") { - 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"; - } - } 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"; + print "If you have some drivers built into your kernel, the list above will\n". + "contain too many modules. Skip the appropriate ones!\n"; + + print "\nDo you want to add these lines automatically to /etc/modules? (yes/NO)"; + $_ = read_answer(); + if (m/^\s*[Yy]/) { + open(MODULES, ">>/etc/modules") + or die "Sorry, can't create /etc/modules ($!)?!?"; + print MODULES "\n# Generated by sensors-detect on " . scalar localtime() . "\n"; if (@{$bus_modules}) { - print "# Adapter drivers\n"; - print "modprobe $_\n" foreach (@{$bus_modules}); + print MODULES "# Adapter drivers\n"; + print MODULES "$_\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"; + print MODULES "# Chip drivers\n"; + print MODULES "$_\n" foreach (@{$hwmon_modules}); + close(MODULES); + + print "Successful!\n\n"; + print "Monitoring programs won't work until the needed modules are\n". + "loaded. You may want to run '/etc/init.d/kmod start'\n". + "to load them.\n"; } + print "\n"; } sub main