Froxlor
Froxlor copied to clipboard
hostname -I in /lib/Froxlor/Cli/InstallCommand.php
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]" "}'
apart from that, congratz on v2. Upgrade went smooth and new interface is really nice !
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
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' ' '
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]" "}'