This is an automated email from the ASF dual-hosted git repository.

rawlin pushed a commit to branch 4.1.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/4.1.x by this push:
     new 393af88  Updates for traffic_ops_ort.pl for 4.0.x for CentOS 8 (#4927)
393af88 is described below

commit 393af881c0a7359b4a55171f54ab0e8282a0b0b9
Author: Hank Beatty <[email protected]>
AuthorDate: Mon Sep 21 16:15:42 2020 -0400

    Updates for traffic_ops_ort.pl for 4.0.x for CentOS 8 (#4927)
    
    And some minor bug fixes for starting ATS
---
 traffic_ops/ort/traffic_ops_ort.pl | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/traffic_ops/ort/traffic_ops_ort.pl 
b/traffic_ops/ort/traffic_ops_ort.pl
index 674f2e2..86b8eb8 100755
--- a/traffic_ops/ort/traffic_ops_ort.pl
+++ b/traffic_ops/ort/traffic_ops_ort.pl
@@ -16,6 +16,7 @@
 use strict;
 use warnings;
 use feature qw(switch);
+no if $] >= 5.018, warnings => qw( experimental::smartmatch );
 use JSON;
 use File::Basename;
 use File::Path;
@@ -29,7 +30,7 @@ chomp($date);
 print "$date\n";
 
 # supported redhat/centos releases
-my %supported_el_release = ( "EL6" => 1, "EL7" => 1);
+my %supported_el_release = ( "EL6" => 1, "EL7" => 1, "EL8" = 1);
 
 my $dispersion = 300;
 my $retries = 5;
@@ -290,7 +291,7 @@ sub revalidate_while_sleeping {
 
 sub os_version {
        my $release = "UNKNOWN";
-       if (`uname -r` =~ m/.+(el\d)(?:\.\w+)*\.x86_64/)  {
+       if (`uname -r` =~ m/.+(el\d)((?:\.\w+)|(?:_\w+))*\.x86_64/)  {
                $release = uc $1;
        }
        if (!exists $supported_el_release{$release} && !$skip_os_check) {
@@ -484,7 +485,7 @@ sub start_service {
        ( $log_level >> $DEBUG ) && print "DEBUG start_service called for 
$pkg_name.\n";
 
        my $pkg_running;
-       if ($RELEASE eq "EL7") {
+       if (($RELEASE eq "EL7") || ($RELEASE eq "EL8")) {
                $pkg_running = &systemd_service_status($pkg_name);
        } else {
                $pkg_running  = `/sbin/service $pkg_name status`;
@@ -506,7 +507,7 @@ sub start_service {
                                ( $log_level >> $ERROR ) && print "ERROR 
$pkg_name needs started. Trying to do that now.\n";
                                my $pkg_start_output = `/sbin/service $pkg_name 
start`;
                                my $pkg_started = 0;
-                               if ($RELEASE eq "EL7") {
+                               if (($RELEASE eq "EL7") || ($RELEASE eq "EL8")) 
{
                                        my $_st = 
&systemd_service_status($pkg_name);
                                        if ($_st =~ m/\(pid\s+(\d+)\) is 
running.../) {
                                                $pkg_started++;
@@ -539,7 +540,7 @@ sub start_service {
                                        ( $log_level >> $ERROR ) && print 
"ERROR $pkg_name needs started. Trying to do that now.\n";
                                        my $pkg_start_output = `/sbin/service 
$pkg_name start`;
                                        my $pkg_started = 0;
-                                       if ($RELEASE eq "EL7") {
+                                       if (($RELEASE eq "EL7") || ($RELEASE eq 
"EL8")) {
                                                my $_st = 
&systemd_service_status($pkg_name);
                                                if ($_st =~ m/\(pid\s+(\d+)\) 
is running.../) {
                                                        $pkg_started++;
@@ -571,6 +572,7 @@ sub start_service {
        }
        else {
                ( $log_level >> $FATAL ) && print "FATAL Unrecognized service: 
$pkg_name. Not starting $pkg_name.\n";
+               $pkg_running = $START_NOT_ATTEMPTED;
        }
        return $pkg_running;
 }
@@ -579,7 +581,7 @@ sub restart_service {
        my $pkg_name = $_[0];
 
        my $pkg_running;
-       if ($RELEASE eq "EL7") {
+       if (($RELEASE eq "EL7") || ($RELEASE eq "EL8")) {
                $pkg_running = &systemd_service_status($pkg_name);
        } else {
                $pkg_running  = `/sbin/service $pkg_name status`;
@@ -605,11 +607,12 @@ sub restart_service {
                                }
                                if ($pkg_started) {
                                        ( $log_level >> $ERROR ) && print 
"ERROR $pkg_name restarted successfully.\n";
-                                       $pkg_running++;
+                                       $pkg_running = $START_SUCCESSFUL;;
                                }
                                else {
                                        $pkg_start_output =~ s/\n/\t/g;
                                        ( $log_level >> $ERROR ) && print 
"ERROR $pkg_name failed to restart, error is: $pkg_start_output.\n";
+                                       $pkg_running = $START_FAILED;
                                }
                        }
                        if ( $script_mode == $INTERACTIVE ) {
@@ -629,22 +632,24 @@ sub restart_service {
                                        }
                                        if ($pkg_started) {
                                                ( $log_level >> $DEBUG ) && 
print "DEBUG $pkg_name restarted successfully.\n";
-                                               $pkg_running++;
+                                               $pkg_running = 
$START_SUCCESSFUL;;
                                        }
                                        else {
                                                $pkg_start_output =~ s/\n/\t/g;
                                                ( $log_level >> $ERROR ) && 
print "ERROR $pkg_name failed to restart, error is: $pkg_start_output.\n";
+                                               $pkg_running = $START_FAILED;
                                        }
                                }
                        }
                }
                else {
                        ( $log_level >> $DEBUG ) && print "DEBUG $pkg_name is 
not running! This shouldn't happnen, $pkg_name must have died recently!\n";
-                       $pkg_running++;
+                       $pkg_running = $START_FAILED;
                }
        }
        else {
                ( $log_level >> $FATAL ) && print "FATAL Unrecognized service: 
$pkg_name. Not restarting $pkg_name.\n";
+               $pkg_running = $START_NOT_ATTEMPTED;
        }
        return $pkg_running;
 }
@@ -2044,7 +2049,7 @@ sub chkconfig_matches {
        # This will work for now as  it trys to map from chkconfig run level 
settings to systemd enabled/disabled state.
        # I think that a new generic endpoint should be added to traffic opts 
for chkconfig and systemd state settings and that functions
        # here in the ort script should abstract the checking of 
chkconfig/systemd states with traffic ops.
-       if ($RELEASE eq "EL7") {
+       if (($RELEASE eq "EL7") || ($RELEASE eq "EL8")) {
                my $service_state = systemd_service_chk($service);
                if ($service_state eq "enabled") {
                        if ($service_settings =~ m/on/) {
@@ -2120,7 +2125,7 @@ sub process_chkconfig {
 
                                                if ($fixit) {
                                                        #use systemd commands 
by mapping chkconfig runlrvrld to either enable or disable.
-                                                       if ($RELEASE eq "EL7") {
+                                                       if (($RELEASE eq "EL7") 
|| ($RELEASE eq "EL8")) {
                                                                my 
$systemd_service_enable = "disable";
                                                                if 
($chkconfig->{"value"} =~ m/on/) {
                                                                        
$systemd_service_enable = "enable";

Reply via email to