HorlogeSkynet / archey4

:computer: Maintained fork of the original Archey (Linux) system tool
https://git.io/archey4
GNU General Public License v3.0
295 stars 37 forks source link

Wrong hostname command parameter #18

Closed NuclearPhoenixx closed 6 years ago

NuclearPhoenixx commented 6 years ago

Expected behavior

I looked through the code and especially the networking detection. I found that you want to primarily use hostname -I to check for the LAN IP.

Current behavior

However, after checking there is no such command as hostname -I and thus it will always choose the slow workaround. I don't actually know what would be a nice and fast replacement though.

Possible solution

Use wget -qO- https://v4.ident.me/ to easily get the ipv4. That's the same method like the ipv6 workaround but is rather slow and crude.

Your environment

HorlogeSkynet commented 6 years ago

Hey back !

Yeah the workaround has been added due to #4

Look (in my case) :

image

It's just that some OSs got old versions of the package providing hostname 😕

The manual workaround is here as a "backward compatibility" solution

EDIT : Plus, the v4.ident.me query will output the public IP (WAN), and hostname -I is for local only (LAN) 😉

NuclearPhoenixx commented 6 years ago

"EDIT : Plus, the v4.ident.me query will output the public IP (WAN), and hostname -I is for local only (LAN) 😉" Right mixed that up, oops.

Anyways, that's really strange, since I'm using Arch I really should have the latest versions of the packages, but when I do that I'll just get

hostname: invalid option -- 'I'
Try 'hostname --help' or 'hostname --usage' for more information.

back...

HorlogeSkynet commented 6 years ago

Np 🙇

--> Yeah that's what we figured out during #4 with @AdJaGu... Some packages might need an upgrade on AUR. Or we are totally wrong and missing the point here.

But as hostname is supposed to be the same program behind, it's very weird

NuclearPhoenixx commented 6 years ago

Ah, I see. That's really strange, I guess Arch has some dark places where there are old, dead packages 😄

HorlogeSkynet commented 6 years ago

This is really something that we need to understand for the future I think, I'll attach the help wanted label for the next wanderer getting lost around here 😉

adjagu commented 6 years ago

@Phoenix1747 and @HorlogeSkynet The thing I've come to realize is this: Arch Linux's hostname command is not outdated because the current version of GNU inetutils is version 1.9.4, the very same Arch Linux uses.

On Arch Linux running hostname -V returns:

Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Debarshi Ray.

And just for laughs I downloaded hostname_3.16ubuntu2_amd64.deb, extracted it to ~/Downloads/hostname_3.16, cd into ~/Downloads/hostname_3.16 and ran ./hostname -V which returned this tiny tidbit of information:

hostname 3.16

From that bit out output I am guessing Debian rolled their own hostname (since GNU plasters their license everywhere)?

Long story short: I don't see Arch Linux getting hostname -I / hostname --all-ip-addresses unless GNU inetutils adds it to their package.

Side note: Running Ubuntu's hostname with the -I flag on Arch Linux does work and works insanely fast.


192.168.1.50 xxxx:xxxx:xxxx:xxxx::xx 

real    0m0.006s
user    0m0.001s
sys 0m0.005s
[doctor@who bin]$ ```
HorlogeSkynet commented 6 years ago

That's perfect, a big thanks @AdJaGu ! It accounts for all of the previous questionings 👌 I remove the help wanted here and #4 then.

NuclearPhoenixx commented 6 years ago

Oh god, yet another strange debian thing.