Thinstation / thinstation

A framework for making thin and light Linux based images for x86 based machines and thinclients.
https://www.thinstation.net/
793 stars 187 forks source link

HOSTNAME get fallback value despite of NET_HOSTNAME=ts_* setting #691

Open stegro opened 2 years ago

stegro commented 2 years ago

Hello everyone, I have built an image based on 252f1ce5 (Nov 2) and have flashed it onto a usb stick. My thinstation.conf.buildtime file has the setting NET_HOSTNAME=ts_* .

However, on most machines, the system does not end up with a HOSTNAME of ts_macaddress but falls back to the name thinstation-linux. I have not yet had the opportunity to investigate a machine which obtains the proper HOSTNAME.

On machines who have the fallback hostname, I find this:

The command systemctl status hostname.service shows that this service is Active: failed and has status=1/FAILURE . The loglines there say

Jan 04 14:18:00 thinstation-linux systemd[1]: Starting Thinstation Hostname Configuration...
Jan 04 14:18:00 thinstation-linux thinstation[5633]: /var/log/net/enp8s0: line 29: PPID: readonly variable
Jan 04 14:18:00 thinstation-linux systemd[1]: hostname.service: Main precess exited, code=exited, status=1/FAILURE
Jan 04 14:18:00 thinstation-linux systemd[1]: hostname.service: Failed with result 'exit-code'
Jan 04 14:18:00 thinstation-linux systemd[1]: Failed to start Thinstation Hostname Configuration.

It seems that this service executes /etc/init.d/hostname which sources all the files at /var/log/net/$adapter. These adapter files contain a line PPID='somenumber'. Of course, trying to set the value of the variable PPID like PPID=foobar fails, since the man page of bash says PPID The process ID of the shell's parent. This variable is readonly.

I have not yet found out how this is supposed to work.

Can somebody give me a hint please? I think there is a bug here.

Clearly, the machine has a network card with a mac adress, so I see no reason not to end up with a ts_macadress hostname, which will allow to identify the client.

thank you very much, and have a happy new year

Thinstation commented 2 years ago

Which networking stack are you using? autonet or networkmanager?

On Tue, Jan 4, 2022 at 6:02 AM Stefan Großhauser @.***> wrote:

Hello everyone, I have built and image based on 252f1ce https://github.com/Thinstation/thinstation/commit/252f1ce5e1f40bae88195c35a6a019b9e97d85eb (Nov 2) and have flashed it onto a usb stick. My thinstation.conf.buildtime file has the setting NETHOSTNAME=ts* .

However, on most machines, the system does not end up with a HOSTNAME of ts_macaddress but falls back to the name thinstation-linux. I habe not yet had the opportunity to investigate a machine which obtains the proper HOSTNAME.

On machines who have the fallback hostname, I find this:

The command systemctl status hostname.service shows that this service is Active: failed and has status=1/FAILURE . The loglines there say

Jan 04 14:18:00 thinstation-linux systemd[1]: Starting Thinstation Hostname Configuration... Jan 04 14:18:00 thinstation-linux thinstation[5633]: /var/log/net/enp8s0: line 29: PPID: readonly variable Jan 04 14:18:00 thinstation-linux systemd[1]: hostname.service: Main precess exited, code=exited, status=1/FAILURE Jan 04 14:18:00 thinstation-linux systemd[1]: hostname.service: Failed with result 'exit-code' Jan 04 14:18:00 thinstation-linux systemd[1]: Failed to start Thinstation Hostname Configuration.

It seems that this service executes /etc/init.d/hostname which sources all the files at /var/log/net/$adapter. These adapter files contain a line PPID='somenumber'. Of course, trying to set the value of the variable PPID like PPID=foobar fails, since the man page of bash says PPID The process ID of the shell's parent. This variable is readonly.

I have not yet found out how this is supposed to work.

Can somebody give me a hint please? I think there is a bug here.

Clearly, the machine has a network card with a mac adress, so I see no reason not to end up with a ts_macadress hostname, which will allow to identify the client.

thank you very much, and have a happy new year

— Reply to this email directly, view it on GitHub https://github.com/Thinstation/thinstation/issues/691, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVW47RIDB5HJDUXF5JOLPLUUL4Y5ANCNFSM5LHQSPUA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

stegro commented 2 years ago

My build.conf contains

#package networkmanager
package autonet

so this looks like autonet is in use.

NETWORKUP=TRUE is not contained in any of the /var/log/net/*.

Doncuppjr commented 2 years ago

Try setting NET_LINKWAIT=120 in thinstation.conf.buildtime

stegro commented 2 years ago

I have merged 6.2.13 in order to be up to date. I have set NET_LINKWAIT=120 in the thinstation.conf.buildtime and made a new ./build --allmodules build. NET_LINKWAIT="120" shows up among the env variables then, but does not have the desired effect, HOSTNAME is still the fallback.

The laptop I am currently testing with is connected with ethernet and gets its IP from dhcp. I can see that /var/log/net/enp0s25 nicely contains a CLIENT_NAME=ts_macadress and also NETWORKUP=TRUE. However, the hostname.service fails before making use of this (I think) because /var/log/net/wls1 contains the PPID='425' line, among many others (ACTION, DEVPATH, DEVTYPE='wlan',HOSTNAME='thinstation-linux',ID_BUS,IDVMODEL_FROM_DATABASE, ID_MODELID,many more ID* variables, IFINDEX,IFS,INTERFACE='wls1','INTERFACE_OLD='wlan0',LINENO,OPTIND,PATH,PPID,PS1,PS2,PS4,PWD,SEQNUM,SHLVL,SUBSYSTEM,SYSTEMD_ALIAS,TAGS,USEC_INITIALIZED. Of course all of them have a value, but I did not want to type everything here.

stegro commented 2 years ago

I see that ts/build/packages/base/etc/udev/scripts/pre-net.sh contains a line set > /var/log/net/$INTERFACE. And the man page for set says: If no ARGs are given, all shell variables are printed. To me, this looks like the origin of the PPID=something line. Is that line in pre-net.sh needed?

stegro commented 2 years ago

If I comment out set > /var/log/net/$INTERFACE in pre-net.sh and build, then I obtain the correct ts_* hostname.

Thinstation commented 2 years ago

Yes, that line is needed. It creates the file at /var/log/net for each interface and records some environment information that's only available when udev makes it's first run. These files are later used by /etc/init.d/autonet. You could try filtering out PPID line. Would networkmanager work better for you? What kind of card is this for?

Thinstation commented 2 years ago

There was a bug in choose-network. That's what I get for expanding simple variables into expressive ones. Would only affect machines that have both eth and wlan.

Thinstation commented 2 years ago

Or if you have multiple adapters that get a link.

Thinstation commented 2 years ago

I've polished the logic of the choose-network script a bit more. Hopefully its now more robust.

stegro commented 2 years ago

With networkmanager the ts_* hostname appears. The machines have either several ethernet ports or one eth and one wifi port. However, only one eth port has the link in all cases. Thank you for your fix ddad50f0b5 . It does not seem to fix this issue with autonet for me, though. I will use networkmanager for now. I will test filtering the PPID line these days. However, it seems to me that filtering that line is not how the bug should be resolved. Rather, the necessary values should be written explicitely to /var/log/net/xyz, I believe.

Thinstation commented 2 years ago

is NET_DEVICE being set correctly on systems that fail?