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

fix: hostname -I not supported on Arch Linux #4642

Open
wants to merge 2 commits into
base: next
Choose a base branch
from

Conversation

nktnet1
Copy link

@nktnet1 nktnet1 commented Dec 22, 2024

Update 2024-12-24

Refactored to use

ip -o addr show scope global | awk '{print $4}' | cut -d/ -f1

if hostname -I is not supported, e.g. on Arch Linux.

Original PR

This provides the hostname command used in the install.sh script, which is not available by default on Arch Linux.

The hostname command is used here:

PRIVATE_IPS=$(hostname -I)

Some relevant resources:

Changes

From:

coolify/scripts/install.sh

Lines 161 to 164 in ef56797

case "$OS_TYPE" in
arch)
pacman -Sy --noconfirm --needed curl wget git jq openssl >/dev/null || true
;;

The inetutils package was added to the pacman install command for Arch Linux

Issues

Arch Linux does not ship with the hostname command by default (provided by inetutils). For example:

Reproduction Steps

Reproduction command logs
$ sudo docker run -it --rm archlinux:latest
Unable to find image 'archlinux:latest' locally
latest: Pulling from library/archlinux
7fa4bb7a964d: Pull complete 
f8d609407a8e: Pull complete 
Digest: sha256:901cf83a14f09d9ba70b219e22f67abd4d6346cb6d3f0c048cd08f22fb9a7425
Status: Downloaded newer image for archlinux:latest
[root@13a16f1a73a0 /]# hostname
bash: hostname: command not found
[root@13a16f1a73a0 /]# pacman -Sy --noconfirm --needed inetutils
:: Synchronizing package databases...
 core downloading...
 extra downloading...
error: restricting filesystem access failed because the landlock ruleset could not be applied!
resolving dependencies...
looking for conflicting packages...

Package (1)     New Version  Net Change  Download Size

core/inetutils  2.5-1          1.07 MiB       0.30 MiB

Total Download Size:   0.30 MiB
Total Installed Size:  1.07 MiB

:: Proceed with installation? [Y/n] 
:: Retrieving packages...
 inetutils-2.5-1-x86_64 downloading...
error: restricting filesystem access failed because the landlock ruleset could not be applied!
checking keyring...
checking package integrity...
loading package files...
checking for file conflicts...
:: Processing package changes...
installing inetutils...
:: Running post-transaction hooks...
(1/3) Creating system user accounts...
Creating group '_talkd' with GID 972.
Creating user '_talkd' (User for legacy talkd server) with UID 972 and GID 972.
(2/3) Reloading system manager configuration...
  Skipped: Current root is not booted.
(3/3) Arming ConditionNeedsUpdate...
[root@13a16f1a73a0 /]# hostname
13a16f1a73a0

As an aside, I also tested the other OS-es, and most come with the hostname command available by default, except Arch and Opensuse, at least based on their docker images.

This provides the `hostname` command used in the install.sh script,
which is not available by default on Arch Linux.

Some relevant resources:
- https://bbs.archlinux.org/viewtopic.php?id=125308
- https://archlinux.org/news/deprecation-of-net-tools/
- https://man.archlinux.org/man/hostname.1.en
@peaklabs-dev
Copy link
Member

I think a better approach would be to use ip or another arch specific command if the first one fails instead of adding another package, can you please change this.

@peaklabs-dev peaklabs-dev added the 💤 Waiting for changes PRs awaiting changes from the author. label Dec 23, 2024
@nktnet1
Copy link
Author

nktnet1 commented Dec 23, 2024

Thanks @peaklabs-dev - I also realised that even with inetutils providing hostname for arch, the -I flag isn't supported.

image

I've changed the PRIVATE_IPS variable to use:

hostname -I 2>/dev/null || ip -o addr show scope global | awk '{print $4}' | cut -d/ -f1

where both the hostname + ip command gives the same addresses (different order) on a Debian/Ubuntu host, and fallback to the ip command when hostname -I is invalid, e.g. on Arch Linux.

@nktnet1 nktnet1 changed the title fix: install inetutils on Arch Linux fix: hostname -I not suppored on Arch Linux Dec 23, 2024
@nktnet1 nktnet1 changed the title fix: hostname -I not suppored on Arch Linux fix: hostname -I not supported on Arch Linux Dec 23, 2024
@peaklabs-dev peaklabs-dev removed the 💤 Waiting for changes PRs awaiting changes from the author. label Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants