Skip to content

Commit

Permalink
Add better fqdn hostname detection method
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecrs committed Aug 14, 2024
1 parent 441ab3a commit f0db091
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions home/.chezmoi.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@

{{- $minimum := or $devcontainer (not $ubuntu) -}}

{{- $fqdnHostname := .chezmoi.fqdnHostname -}}
{{- if and (not (contains "." $fqdnHostname)) (lookPath "hostname") -}}
{{- $fqdnHostname = output "hostname" "-f" | trim -}}
{{- if not (contains "." $fqdnHostname) -}}
{{- $fqdnHostname = output "sh" "-c" "hostname -A 2>/dev/null | cut -d' ' -f1" | trim -}}
{{- if not (contains "." $fqdnHostname) -}}
{{- $fqdnHostname = .chezmoi.fqdnHostname -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{- if hasKey . "name" -}}
{{- $name = .name -}}
{{- end -}}
Expand Down Expand Up @@ -113,3 +124,4 @@ data:
editor: "code --wait"

uname_arch: "{{ output "uname" "-m" | trim }}"
fqdn_hostname: "{{ $fqdnHostname }}"

0 comments on commit f0db091

Please sign in to comment.