Skip to content

Commit

Permalink
Remove hostname dependency for Archlinux
Browse files Browse the repository at this point in the history
fixes: QubesOS/qubes-issues#9710

`hostname` is replaced with `hostnamectl` on Archlinux
  • Loading branch information
alimirjamali committed Jan 21, 2025
1 parent 74d07bb commit 748b48e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions archlinux/PKGBUILD.install
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ update_qubesconfig() {
if ! grep -q localhost /etc/hosts; then

cat <<EOF > /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 $(hostname)
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 $(hostnamectl hostname)
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
EOF

Expand All @@ -126,10 +126,10 @@ EOF
if ! is_protected_file /etc/hostname ; then
for ip in '127\.0\.0\.1' '::1'; do
if grep -q "^${ip}\(\s\|$\)" /etc/hosts; then
sed -i "/^${ip}\s/,+0s/\(\s$(hostname)\)\+\(\s\|$\)/\2/g" /etc/hosts
sed -i "s/^${ip}\(\s\|$\).*$/\0 $(hostname)/" /etc/hosts
sed -i "/^${ip}\s/,+0s/\(\s$(hostnamectl hostname)\)\+\(\s\|$\)/\2/g" /etc/hosts
sed -i "s/^${ip}\(\s\|$\).*$/\0 $(hostnamectl hostname)/" /etc/hosts
else
echo "${ip} $(hostname)" >> /etc/hosts
echo "${ip} $(hostnamectl hostname)" >> /etc/hosts
fi
done
fi
Expand Down
6 changes: 5 additions & 1 deletion vm-systemd/qubes-early-vm-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ unset rc
if ! is_protected_file /etc/hostname ; then
name=$(qubesdb-read /name)
if [ -n "$name" ]; then
hostname "$name"
if [ -f /usr/bin/hostname ]; then
hostname "$name"
else
echo "$name" > /etc/hostname
fi
if [ -e /etc/debian_version ]; then
ipv4_localhost_re="127\.0\.1\.1"
else
Expand Down

0 comments on commit 748b48e

Please sign in to comment.