Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting correct hostname using hostnamectl also #129

Merged
merged 1 commit into from
Oct 29, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
setting correct hostname using hostnamectl also
Sometimes for reasons unknown to me a "transient" name was set in hostnamectl and this causes a fight between systemd-resolved and other things trying to set the hostname, as systemd runs many things in parallel it depends which thing runs last to find which hostname you end up with. The addition here will set the hostname using hostnamectl if the command is in the path and it reports either it's static or transient name as different from desired.
  • Loading branch information
baelish committed Oct 29, 2018
commit 751aeac486fce2cc203104882e83a0991a9de83e
10 changes: 10 additions & 0 deletions formulas/hostname/files/set-hostname
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ wickDebug "Setting hostname to $full"
#
reload=false

if which hostnamectl &> /dev/null; then
if [[ "$(hostnamectl status --static)" != "$host" ]]; then
hostnamectl set-hostname "$host"
reload=true
elif [[ "$(hostnamectl status --transient)" != "$host" ]]; then
hostnamectl set-hostname "$host"
reload=true
fi
fi

if [[ -f /etc/hostname ]]; then
if [[ "$(cat /etc/hostname)" != "$host" ]]; then
wickDebug "Setting /etc/hostname to $host"
Expand Down