Skip to content

Commit

Permalink
Fixes #24422 - k-c-h Check hostname is not current hostname
Browse files Browse the repository at this point in the history
For katello-change-hostname, often times users will use
hostnamectl to change the hostname before running k-c-h.
This causes the script to error out and leaves things in
a bad state. This commit adds a check that the hostname
specified is different than the current system's hostname.
  • Loading branch information
John Mitsch committed Jul 30, 2018
1 parent 74b28c9 commit 5fea7d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 7 additions & 2 deletions packages/katello/katello/hostname-change.rb
Expand Up @@ -77,6 +77,11 @@ def precheck
self.fail_with_message("Please specify a hostname.", @opt_parser)
end

if @old_hostname == @new_hostname
self.fail_with_message("The hostname specified must be different from the current hostname. If you have changed the hostname" \
" with another utility, please change it back to the original hostname before running this tool.")
end

STDOUT.puts "\nChecking hostname validity"
# This regex is an approximation of a hostname, it will handle most invalid hostnames and typos.
# Taken from https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9781449327453/ch08s15.html
Expand Down Expand Up @@ -252,11 +257,11 @@ def run
fpc_installer_args = self.get_fpc_answers
end

self.precheck

# Get the hostname from your system
@old_hostname = self.get_hostname

self.precheck

unless @foreman_proxy_content
STDOUT.puts "\nUpdating default #{@proxy}"
proxy_id = self.get_default_proxy_id
Expand Down
5 changes: 4 additions & 1 deletion packages/katello/katello/katello.spec
Expand Up @@ -4,7 +4,7 @@
%global homedir %{_datarootdir}/%{name}
%global confdir common
# %%global prerelease .rc1
%global release 5
%global release 6

Name: katello
Version: 3.9.0
Expand Down Expand Up @@ -204,6 +204,9 @@ Useful utilities for managing Katello services
%{_sysconfdir}/bash_completion.d/katello-service

%changelog
* Mon Jul 30 2018 John Mitsch <jomitsch@redhat.com> - 3.9.0-6
- k-c-h Check hostname is not current hostname

* Wed Jul 25 2018 Jonathon Turel <jturel@gmail.com> - 3.9.0-5
- Obsolete the python-gofer-qpid obsolete

Expand Down

0 comments on commit 5fea7d0

Please sign in to comment.