Skip to content

Commit

Permalink
Update change-hostname to use hostnamectl (#1803)
Browse files Browse the repository at this point in the history
Resolves #1679

This change updates the `change-hostname` script to use `hostnamectl`
instead of editing `/etc/hostname` directly.

<a data-ca-tag
href="https://codeapprove.com/pr/tiny-pilot/tinypilot/1803"><img
src="https://codeapprove.com/external/github-tag-allbg.png" alt="Review
on CodeApprove" /></a>
  • Loading branch information
db39 authored Jun 27, 2024
1 parent c18e634 commit 6f37e68
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions debian-pkg/opt/tinypilot-privileged/scripts/change-hostname
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ printf "%s\n127.0.1.1 %s\n%s\n%s\n" \
"${MARKER_START}" "${NEW_HOSTNAME}" "${MARKER_END}" "${OLD_ETC_HOSTS}" \
> /etc/hosts

# Populate new hostname to `/etc/hostname`.
# Note that the value must be newline-terminated, see:
# https://manpages.debian.org/stretch/systemd/hostname.5.en.html
printf "%s\n" "${NEW_HOSTNAME}" > /etc/hostname
# We use `hostnamectl set-hostname xyz` instead of `hostnamectl hostname xyz`
# because `set-hostname` is backwards compatible with the Bullseye version of
# `hostnamectl`. `hostnamectl hostname xyz` is only supported on the Bookworm
# version.
hostnamectl set-hostname "${NEW_HOSTNAME}"

0 comments on commit 6f37e68

Please sign in to comment.