--- doc/install/linux/install.pl 2011/09/20 20:54:47 1.22 +++ doc/install/linux/install.pl 2011/10/25 02:03:16 1.23 @@ -72,7 +72,7 @@ if (!open(LOG,">>loncapa_install.log")) &mt('Stopping execution.')."\n"; exit; } else { - print LOG '$Id: install.pl,v 1.22 2011/09/20 20:54:47 raeburn Exp $'."\n"; + print LOG '$Id: install.pl,v 1.23 2011/10/25 02:03:16 raeburn Exp $'."\n"; } # @@ -405,6 +405,7 @@ sub check_required { sub check_mysql_running { my ($distro) = @_; + my $use_systemctl; my $mysqldaemon ='mysqld'; if ($distro =~ /^(suse|sles|debian|ubuntu)/) { $mysqldaemon = 'mysql'; @@ -417,6 +418,13 @@ sub check_mysql_running { $proc_owner = 'mysql'; } } + if ($distro =~ /^fedora(\d+)/) { + if ($1 >= 16) { + $process = 'mysqld'; + $proc_owner = 'mysql'; + $use_systemctl = 1; + } + } if (open(PIPE,"ps -ef |grep $process |grep -v grep 2>&1 |")) { my $status = ; close(PIPE); @@ -425,7 +433,11 @@ sub check_mysql_running { print_and_log(&mt('MySQL is running.')."\n"); return 1; } else { - system("/etc/init.d/$mysqldaemon start >/dev/null 2>&1 "); + if ($use_systemctl) { + system("/bin/systemctl start $mysqldaemon.service >/dev/null 2>&1 "); + } else { + system("/etc/init.d/$mysqldaemon start >/dev/null 2>&1 "); + } print_and_log(&mt('Waiting for MySQL to start.')."\n"); sleep 5; if (open(PIPE,"ps -ef |grep $process |grep -v grep 2>&1 |")) { @@ -460,8 +472,9 @@ sub check_mysql_running { sub chkconfig { my ($distro,$instdir) = @_; - my (%needfix,%tostop); + my (%needfix,%tostop,%uses_systemctl); my $checker_bin = '/sbin/chkconfig'; + my $sysctl_bin = '/bin/systemctl'; my %daemon = ( mysql => 'mysqld', apache => 'httpd', @@ -491,66 +504,82 @@ sub chkconfig { if (($distro =~ /^ubuntu/) && ($version <= 8)) { $daemon{'cups'} = 'cupsys'; } + } elsif ($distro =~ /^(?:fedora)(\d+)/) { + my $version = $1; + if ($version >= 15) { + $uses_systemctl{'ntp'} = 1; + } + if ($version >= 16) { + $uses_systemctl{'mysql'} = 1; + $uses_systemctl{'apache'} = 1; + } } + my $nocheck; if (! -x $checker_bin) { + if ($uses_systemctl{'mysql'} && $uses_systemctl{'apache'}) { + if (! -x $sysctl_bin) { + $nocheck = 1; + } + } else { + $nocheck = 1; + } + } + if ($nocheck) { print &mt('Could not check runlevel status for MySQL or Apache')."\n"; return; } my $rlstr = join('',@runlevels); my $nrlstr = join('',@norunlevels); + foreach my $type ('apache','mysql','ntp','cups','memcached') { my $service = $daemon{$type}; - if ($type eq 'ntp') { - if ($distro =~ /^(?:fedora)(\d+)/) { - my $version = $1; - if ($version >= 15) { - if (!-l "/etc/systemd/system/multi-user.target.wants/ntpd.service") { - $needfix{$type} = 'systemctl enable ntpd.service'; + if ($uses_systemctl{$type}) { + if (!-l "/etc/systemd/system/multi-user.target.wants/$service.service") { + $needfix{$type} = "systemctl enable $service.service"; + } + next; + } else { + my $command = $checker_bin.' --list '.$service.' 2>/dev/null'; + if ($type eq 'cups') { + if ($distro =~ /^(?:debian|ubuntu)(\d+)/) { + my $version = $1; + if (($distro =~ /^ubuntu/) && ($version <= 8)) { + $command = $checker_bin.' --list cupsys 2>/dev/null'; } - next; } } - } - my $command = $checker_bin.' --list '.$service.' 2>/dev/null'; - if ($type eq 'cups') { - if ($distro =~ /^(?:debian|ubuntu)(\d+)/) { - my $version = $1; - if (($distro =~ /^ubuntu/) && ($version <= 8)) { - $command = $checker_bin.' --list cupsys 2>/dev/null'; + my $results = `$command`; + my $tofix; + if ($results eq '') { + if (($type eq 'apache') || ($type eq 'mysql') || ($type eq 'ntp')) { + if ($distro =~ /^(debian|ubuntu)/) { + $tofix = "update-rc.d $type defaults"; + } else { + $tofix = "$checker_bin --add $service\n"; + } } - } - } - my $results = `$command`; - my $tofix; - if ($results eq '') { - if (($type eq 'apache') || ($type eq 'mysql') || ($type eq 'ntp')) { - if ($distro =~ /^(debian|ubuntu)/) { - $tofix = "update-rc.d $type defaults"; - } else { - $tofix = "$checker_bin --add $service\n"; + } else { + my %curr_runlevels; + for (my $rl=0; $rl<=6; $rl++) { + if ($results =~ /$rl:on/) { $curr_runlevels{$rl}++; } } - } - } else { - my %curr_runlevels; - for (my $rl=0; $rl<=6; $rl++) { - if ($results =~ /$rl:on/) { $curr_runlevels{$rl}++; } - } - if (($type eq 'apache') || ($type eq 'mysql') || ($type eq 'ntp')) { - my $warning; - foreach my $rl (@runlevels) { - if (!exists($curr_runlevels{$rl})) { - $warning = 1; + if (($type eq 'apache') || ($type eq 'mysql') || ($type eq 'ntp')) { + my $warning; + foreach my $rl (@runlevels) { + if (!exists($curr_runlevels{$rl})) { + $warning = 1; + } } + if ($warning) { + $tofix = "$checker_bin --level $rlstr $service on\n"; + } + } elsif (keys(%curr_runlevels) > 0) { + $tostop{$type} = 1; } - if ($warning) { - $tofix = "$checker_bin --level $rlstr $service on\n"; - } - } elsif (keys(%curr_runlevels) > 0) { - $tostop{$type} = 1; } - } - if ($tofix) { - $needfix{$type} = $tofix; + if ($tofix) { + $needfix{$type} = $tofix; + } } } if ($distro =~ /^(suse|sles)([\d\.]+)$/) {