hostname

Post your comments, questions, bug reports or suggest new features for alphaOS
Scooby
Site Admin
Posts: 826
Joined: 09 Sep 2013, 16:52

hostname

Postby Scooby » 20 Nov 2014, 17:50

I've been playing around with serviio media server but ran into trouble with
alphaos hostname see below.

Code: Select all

java.net.UnknownHostException: alphaos: alphaos
   at java.net.InetAddress.getLocalHost(InetAddress.java:1473)
   at org.serviio.ApplicationInstanceManager.registerInstance(ApplicationInstanceManager.java:68)
   at org.serviio.MediaServer.checkForRunningInstances(MediaServer.java:283)
   at org.serviio.MediaServer.main(MediaServer.java:106)


I got it to work if I doevery time

Code: Select all

hostname -F /etc/hosts


on a freshly booted alphaos I get

Code: Select all

> hostname
alphaos
> getent hosts alphaos
>


after I do hostname -F /etc/hosts I get

Code: Select all

> hostname
127.0.0.1


I this only for me?

Is there some trouble woth hostname? /etc/hosts seems to look OK

simargl
Site Admin
Posts: 466
Joined: 16 May 2013, 10:54
Contact:

Re: hostname

Postby simargl » 21 Nov 2014, 18:43

Scooby wrote:I've been playing around with serviio media server but ran into trouble with
alphaos hostname see below.

Code: Select all

java.net.UnknownHostException: alphaos: alphaos
   at java.net.InetAddress.getLocalHost(InetAddress.java:1473)
   at org.serviio.ApplicationInstanceManager.registerInstance(ApplicationInstanceManager.java:68)
   at org.serviio.MediaServer.checkForRunningInstances(MediaServer.java:283)
   at org.serviio.MediaServer.main(MediaServer.java:106)


I got it to work if I doevery time

Code: Select all

hostname -F /etc/hosts



In file /etc/rc.d/functions there is this line:
hostname -F /etc/hostname

when it needs to be, as you showed:
hostname -F /etc/hosts

That command is from Puppy Linux and was there for so long, since beginning of ArchPup.
https://github.com/puppylinux-woof-CE/w ... sinit#L465

:)

Scooby
Site Admin
Posts: 826
Joined: 09 Sep 2013, 16:52

Re: hostname

Postby Scooby » 22 Nov 2014, 22:52

simargl wrote:That command is from Puppy Linux and was there for so long, since beginning of ArchPup.
https://github.com/puppylinux-woof-CE/w ... sinit#L465

:)


:D

simargl
Site Admin
Posts: 466
Joined: 16 May 2013, 10:54
Contact:

Re: hostname

Postby simargl » 23 Nov 2014, 14:33

I've reverted previous commit, because this new hostname output looks wrong

Code: Select all

[root@127 ~]# hostname
127.0.0.1

Also found that Slitaz uses same hostname code, let's say it's okay to leave it same as was before.
http://www.slitaz.org/en/doc/scratchboo ... ystem.html
(This is from Slitaz)

Code: Select all

#! /bin/sh
# /etc/init.d/rcS: rcS initial script.
#

KMAP=fr_CH

echo "Processing /etc/init.d/rcS... "

/bin/mount proc
/bin/mount -a
/bin/hostname -F /etc/hostname
/sbin/ifconfig lo 127.0.0.1 up
/sbin/loadkmap < /usr/share/kmap/$KMAP.kmap

Scooby
Site Admin
Posts: 826
Joined: 09 Sep 2013, 16:52

Re: hostname

Postby Scooby » 23 Nov 2014, 21:58

After a lot of checking with serviio it accepts hostnames that are "number name"
Example "16 alphaos"

maybe this is a domain thing?

or is it expecting "ip-adress name"
Example "127.0.0.1 alphaos"

Anyway if i set my hostname to "16 alphaos" it works

any input?

Maybe that the error that brings down serviio is

Code: Select all

java.lang.NullPointerException: replacement
   at java.util.regex.Matcher.replaceFirst(Matcher.java:999)
   at java.lang.String.replaceFirst(String.java:2165)
   at org.serviio.profile.ProfilesDefinitionParser.getDeviceDescription(ProfilesDefinitionParser.java:378)
   at org.serviio.profile.ProfilesDefinitionParser.processProfileNode(ProfilesDefinitionParser.java:229)
   at org.serviio.profile.ProfilesDefinitionParser.parseDefinition(ProfilesDefinitionParser.java:164)
   at org.serviio.profile.ProfileManager.parseProfilesFromFile(ProfileManager.java:181)
   at org.serviio.profile.ProfileManager.loadProfiles(ProfileManager.java:156)

Scooby
Site Admin
Posts: 826
Joined: 09 Sep 2013, 16:52

Re: hostname

Postby Scooby » 24 Nov 2014, 17:01

I tracked the problem down to the following lines in java

Code: Select all

try
{
    COMP_NAME = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
    log.warn(String.format("Cannot get name of the local computer: %s", new Object[] { e.getMessage() }));
}


InetAddress.getLocalHost().getHostName throws exception

from API documenatation
If this InetAddress was created with a host name, this host name will be remembered and returned; otherwise, a reverse name lookup will be performed and the result will be returned based on the system configured name lookup service. If a lookup of the name service is required, call getCanonicalHostName.


So why does both fail?

Code: Select all

getent hosts alphaos
nslookup alphaos


but works for localhost??

Code: Select all

> getent hosts localhost
127.0.0.1       localhost
 > nslookup localhost
Server:      192.168.0.1
Address:   192.168.0.1#53

Non-authoritative answer:
Name:   localhost
Address: 127.0.0.1


and why does it work with hostname being a number for instance hostname is "1"

and what is the system configured name lookup service.

seems to me alphaos doesnt give a sh** about whats in /etc/hosts file??

also before I connect to network getent hosts alphaos works
but not after? curiouser and curiouser :shock:

Scooby
Site Admin
Posts: 826
Joined: 09 Sep 2013, 16:52

Re: hostname

Postby Scooby » 25 Nov 2014, 21:55

java portion could possibly be replaced by

Code: Select all

try
  {
       COMP_NAME = InetAddress.getLocalHost().getHostName();
    } catch (UnknownHostException e) {
       log.warn(String.format("Cannot get name of the local computer: %s", new Object[] { e.getMessage() }));
           String host = e.getMessage(); // host = "hostname: hostname"
           if ( host!=null ) {
              int colon = host.indexOf(':');
              if ( colon>0 ) {
                 COMP_NAME=host.substring(0, colon);   
              }
         }
     }

Scooby
Site Admin
Posts: 826
Joined: 09 Sep 2013, 16:52

Re: hostname

Postby Scooby » 25 Nov 2014, 21:58

Found another fix

installed dnsmasq

added in /etc/resolv.conf.head my comp's ip as nameserver
and added an in /etc/dnsmasq.conf

Code: Select all

adress=/alphaos/my.ip.add.res


also configured alphaos to start dnsmasq at startup

Now alphaos gets resolved by nslookup
and serviio is happy as well :lol:

me am happy also


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 13 guests

cron