From 71a434d123427daf29ece1599e6da86a036d1ceb Mon Sep 17 00:00:00 2001 From: Anssi Hannula Date: Sun, 17 Apr 2011 14:33:56 +0000 Subject: service_harddrake: ask for a reboot after a driver switch if needed, and load the new driver if no reboot is needed --- perl-install/standalone/service_harddrake | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'perl-install/standalone/service_harddrake') diff --git a/perl-install/standalone/service_harddrake b/perl-install/standalone/service_harddrake index f9409d01d..c465575ce 100755 --- a/perl-install/standalone/service_harddrake +++ b/perl-install/standalone/service_harddrake @@ -30,6 +30,7 @@ use Storable qw(store retrieve); my $force = member('--force', @ARGV); +my $reboot_needed; my $invert_do_it = $ARGV[0] eq 'X11' ? 1 : 0; my ($hw_sysconfdir, $timeout) = ("/etc/sysconfig/harddrake2", $invert_do_it ? 600 : 25); @@ -124,6 +125,15 @@ sub switch_x_driver { log::explanations("switch X.org driver from '$old_driver' to '$new_driver' ($reason)"); Xconfig::card::libgl_config_and_more({ Driver => $new_driver }); Xconfig::various::setup_kms(); + + # If a wrong driver is loaded, ask for a reboot. + my $reboot_needed = -x "/sbin/display_driver_helper" && system("/sbin/display_driver_helper", "--check-loaded") != 0; + if (!$reboot_needed) { + # Load any new drivers. + system("udevadm", "trigger", "--subsystem-match=pci", "--attr-match=class=0x03*"); + system("udevadm", "settle", "--timeout=10"); + } + $reboot_needed; } sub should_reconfigure_x_driver { @@ -188,7 +198,7 @@ foreach my $device (@devices) { # auto reconfigure x11 only on first time default driver have changed: my ($should_reconfigure, $reason) = should_reconfigure_x_driver($card_data, $device, $current_driver); if ($should_reconfigure) { - switch_x_driver($current_driver, $card_data->{Driver}, $reason); + $reboot_needed |= switch_x_driver($current_driver, $card_data->{Driver}, $reason); schedule_warn_about_switch($reason) if any { $current_driver =~ $_->{xorg_driver_regexp} } @cards; # Update $current_driver with the new one $current_driver = $card_data->{Driver}; @@ -229,7 +239,7 @@ foreach my $card (@cards) { if ($old_driver) { my $reason = N("The proprietary kernel driver was not found for '%s' X.org driver", $old_driver); - switch_x_driver($card->{xorg_driver_regexp}, $driver, $reason); + $reboot_needed |= switch_x_driver($card->{xorg_driver_regexp}, $driver, $reason); schedule_warn_about_switch($reason); } } @@ -391,4 +401,15 @@ foreach my $hw_class (@harddrake::data::tree) { log::explanations("created file $last_boot_config"); Storable::store(\%config, $last_boot_config); +# Handle $reboot_needed from earlier: +my ($reply, $timedout); +# Don't do autoreboot if X was somehow already started (not normally the case). +if ($reboot_needed && ! -e "/tmp/.X11-unix/X0") { + ($reply, $timedout) = ask_with_timeout(N("Display driver setup"), N("The system has to be rebooted due to a display driver change.") . "\n\n" + . N("Press Cancel within %d seconds to abort.", 30), 30, $plymouth); + if ($reply || $timedout) { + exec("/sbin/reboot"); + } +} + $in->exit(0) if $in; -- cgit v1.2.1