Froxlor icon indicating copy to clipboard operation
Froxlor copied to clipboard

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

Open ZARk-be opened this issue 2 years ago • 4 comments

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 avatar Feb 05 '23 08:02 ZARk-be

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

ZARk-be avatar Feb 05 '23 08:02 ZARk-be

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 avatar Feb 05 '23 08:02 d00p

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' ' '

d00p avatar Feb 07 '23 11:02 d00p

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]" "}'

ZARk-be avatar Feb 08 '23 20:02 ZARk-be