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

hostname -I in /lib/Froxlor/Cli/InstallCommand.php #1095

Open
ZARk-be opened this issue Feb 5, 2023 · 4 comments
Open

hostname -I in /lib/Froxlor/Cli/InstallCommand.php #1095

ZARk-be opened this issue Feb 5, 2023 · 4 comments
Assignees
Milestone

Comments

@ZARk-be
Copy link

ZARk-be commented Feb 5, 2023

When running /lib/Froxlor/Cli/InstallCommand.php i'm getting an error with hostname -I not being a valid command

System information

  • Froxlor version: 2.0.10
  • Web server: apache2
  • DNS server: Bind
  • POP/IMAP server: Dovecot
  • SMTP server: postfix
  • FTP server: proftpd
  • OS/Version: Gentoo 17.1 (OpenRC)

To Reproduce
php ./bin/froxlor-cli froxlor:install

Logfiles
hostname: invalid option -- 'I'

Additional context
hostname utility is part of sys-apps/net-tools package on Gentoo.
All linux distro don't have the -I option for hostname.
I suggest the following one liner which will give you similar results, the output is one ip per line, so you shouldn't need to do an explode as it should directly be an array
ip addr show | awk '/inet / {split($2, a, "/"); if (a[1] != "127.0.0.1") print a[1]}'

if you want it to have the same output as you already have :
ip addr show | awk '/inet / {split($2, a, "/"); if (a[1] != "127.0.0.1") printf a[1]" "}'

@ZARk-be
Copy link
Author

ZARk-be commented Feb 5, 2023

apart from that, congratz on v2. Upgrade went smooth and new interface is really nice !

@d00p
Copy link
Member

d00p commented Feb 5, 2023

All linux distro don't have the -I option for hostname.

Simply not true: -I, --all-ip-addresses all addresses for the host
Looks like gentoo provides hostname in a different manner that the debian/ubuntu based ones.

We'll consider a more generalized way of retrieving all ip addresses of the host, thx

@d00p d00p added this to the 2.0.x milestone Feb 5, 2023
@d00p d00p self-assigned this Feb 5, 2023
@d00p
Copy link
Member

d00p commented Feb 7, 2023

Your solution did not return any ipv6 addresses, could you verify that the following snippet works as intended?

ip addr show | grep inet | grep 'scope global' | awk '{print $2}' | cut -d/ -f1 | tr '\n' ' '

@ZARk-be
Copy link
Author

ZARk-be commented Feb 8, 2023

true, i didn't think of ipv6.
Yes your snippet works as intended.
good idea using scope global.. here's my initial code using scope global and including ipv6

ip addr show | awk '/inet6? / && index($0, "scope global") > 0 {split($2, a, "/"); printf a[1]" "}'

@d00p d00p modified the milestones: 2.0.x, 2.1.x Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: To do
Development

No branches or pull requests

2 participants