Skip to content

Commit

Permalink
Merge pull request #435 from mchf/SLE-12-SP1
Browse files Browse the repository at this point in the history
AY profile generated at the end of installation contains valid hostname
  • Loading branch information
mchf committed Feb 5, 2016
2 parents cdcec99 + ce3a0dd commit 1ec8f7e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
28 changes: 9 additions & 19 deletions library/types/src/modules/Hostname.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def main
Yast.import "IP"
Yast.import "String"
Yast.import "FileUtils"
Yast.import "Mode"
Yast.import "Stage"

# i18n characters in domain names are still not allowed
#
Expand Down Expand Up @@ -155,30 +155,20 @@ def MergeFQ(hostname, domain)
# (uses hostname --fqdn)
# @return FQ hostname
def CurrentFQ
fqhostname = ""
hostname_data = SCR.Execute(path(".target.bash_output"), "hostname --fqdn")

hostname_data = Convert.to_map(
SCR.Execute(path(".target.bash_output"), "hostname --fqdn")
)
if hostname_data.nil? || hostname_data["exit"] != 0 || invalid_hostname?(hostname_data["stdout"].to_s.strip)
fqhostname = if FileUtils.Exists("/etc/hostname")
SCR.Read(path(".target.string"), "/etc/hostname")
else
""
end

if fqhostname == "" || fqhostname.nil?
# last resort (#429792)
fqhostname = "linux.#{@DefaultDomain}"
end
Builtins.y2warning("Using fallback hostname %1", fqhostname)
Builtins.y2warning("Using fallback hostname")

fqhostname = SCR.Read(path(".target.string"), "/etc/hostname") || ""
fqhostname = "linux.#{@DefaultDomain}" if fqhostname.empty?
else
fqhostname = Ops.get_string(hostname_data, "stdout", "")
fqhostname = hostname_data["stdout"]
end

fqhostname = String.FirstChunk(fqhostname, "\n")

Builtins.y2debug("Current FQDN: %1", fqhostname)
Builtins.y2milestone("Current FQDN: %1", fqhostname)
fqhostname
end

Expand Down Expand Up @@ -247,7 +237,7 @@ def CurrentDomain
#
# Basicaly, linuxrc sometimes resolves IP when querying "hostname --fqdn"
def invalid_hostname?(hostname)
Mode.installation && IP.Check(hostname)
Stage.initial && IP.Check(hostname)
end
end

Expand Down
8 changes: 8 additions & 0 deletions package/yast2.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Fri Feb 5 08:21:00 UTC 2016 - mfilka@suse.com

- bsc#960040
- put valid hostname into AY profile generated at the end of
installation
- 3.1.155.2

-------------------------------------------------------------------
Tue Nov 17 12:11:54 UTC 2015 - igonzalezsosa@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2
Version: 3.1.155.1
Version: 3.1.155.2
Release: 0
Url: https://github.com/yast/yast-yast2

Expand Down

0 comments on commit 1ec8f7e

Please sign in to comment.