You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by fa...@apache.org on 2014/12/19 18:52:50 UTC
svn commit: r1646807 - /vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm
Author: fapeeler
Date: Fri Dec 19 17:52:50 2014
New Revision: 1646807
URL: http://svn.apache.org/r1646807
Log:
VCL-637
for latest Linux OS's that use /etc/hostname
Modified:
vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm
Modified: vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm?rev=1646807&r1=1646806&r2=1646807&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm Fri Dec 19 17:52:50 2014
@@ -709,22 +709,30 @@ sub update_hostname_file {
my $computer_node_name = $self->data->get_computer_node_name();
my $network_file_path = '/etc/sysconfig/network';
+
+ my $hostname_file_path = '/etc/hostname';
+ # For Linux OS that are using /etc/hostname
+ if($self->file_exists($hostname_file_path)) {
+ my $update_hostname_file_cmd = "echo $public_hostname > $hostname_file_path";
+ if($self->execute($update_hostname_file_cmd)) {
+ notify($ERRORS{'OK'}, 0, "updated $hostname_file_path on $computer_node_name to $public_hostname");
+ }
+ }
my $command = "sed -i -e \"/^HOSTNAME=/d\" $network_file_path; echo \"HOSTNAME=$public_hostname\" >> $network_file_path";
my ($exit_status, $output) = $self->execute($command);
if (!defined($output)) {
notify($ERRORS{'WARNING'}, 0, "failed to SSH command to set hostname on $computer_node_name to $public_hostname, command: '$command'");
- return 0;
}
elsif ($exit_status == 0) {
notify($ERRORS{'OK'}, 0, "set public hostname on $computer_node_name to $public_hostname");
- return 1;
}
else {
notify($ERRORS{'WARNING'}, 0, "failed to set public hostname on $computer_node_name to $public_hostname, exit status: $exit_status, output:\n" . join("\n", @ $output));
- return 0;
}
+ return 1;
+
}
#/////////////////////////////////////////////////////////////////////////////
@@ -4477,6 +4485,13 @@ sub clean_known_files {
if ($self->execute("/usr/sbin/tmpwatch -f 0 /tmp; /bin/cp /dev/null /var/log/wtmp")) {
notify($ERRORS{'DEBUG'}, 0, "cleared /tmp on $computer_node_name");
}
+
+ # Clear /etc/hostname file
+ if($self->file_exists("/etc/hostname")) {
+ if ($self->execute("/bin/cp /dev/null /etc/hostname")) {
+ notify($ERRORS{'DEBUG'}, 0, "cleared /etc/hostname on $computer_node_name");
+ }
+ }
# Clear SSH idenity keys from /root/.ssh
if (!$self->clear_private_keys()) {
@@ -4508,7 +4523,7 @@ sub clean_known_files {
notify($ERRORS{'WARNING'}, 0, "unable to remove /var/log/secure");
}
}
-
+
return 1;
}