# hostname not set

## wpkzz

This may seem very dumb, but i cannot set it straight.

I cannot set the hostname.

The file /etc/init.d/hostname has the content it has to have, namely:

```

#!/sbin/runscript

# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>

# Released under the 2-clause BSD license.

description="Sets the hostname of the machine."

depend() {

        keyword -prefix -lxc

}

start()

{

        hostname=${hostname-${HOSTNAME-localhost}}

        ebegin "Setting hostname to $hostname"

        hostname "$hostname"

        eend $? "Failed to set the hostname"

}

```

As well the file /etc/conf.d/hostname :

```

# Set to the hostname of this machine

hostname="monstruona"

```

When the machine is booting up, syslog-ng complains that no hostname is set,

hence, it cannot work. The "issue" greetings shows

```

This is (none). <date>

```

The command hostname also gives me a (none) answer.

But if i give the command 

```

rc-update add hostname boot

```

, she tells me that hostname is allready in the boot runlevel.

And the command rc-update show shows absolutely none of it.

I tried deleting and adding it again, to no gain.

Seems like a simple problem, so simple, that it shouldn't be.

Thanks in advance,

----------

## jeracho

Have you tried running env-update && source /etc/profile?

----------

## mv

You can try to check manually whether /etc/runlevels/boot/hostname is a symlink to /etc/init.d/hostname

Also, are the permissions of /etc/init.d/hostname correct?

----------

## wpkzz

Okey, yes, I did try the env-update and source profile many times. That is not it. 

The symlink thing... I didn't know about that one. If  I check with ls -lah the directory  /etc/runlevels/boot/

I obtain the following list:

```

monstruona boot # ls -lah

total 8.0K

drwxr-xr-x 2 root root 4.0K May  9 20:25 .

drwxr-xr-x 6 root root 4.0K Apr 24 21:21 ..

lrwxrwxrwx 1 root root   21 May  9 20:25 alsasound -> /etc/init.d/alsasound

lrwxrwxrwx 1 root root   20 Apr 24 21:21 bootmisc -> /etc/init.d/bootmisc

lrwxrwxrwx 1 root root   16 Apr 24 21:21 fsck -> /etc/init.d/fsck

lrwxrwxrwx 1 root root   32 May  9 18:56 hostname -> /etc/init.d//etc/init.d/hostname

lrwxrwxrwx 1 root root   19 Apr 24 21:21 hwclock -> /etc/init.d/hwclock

lrwxrwxrwx 1 root root   19 Apr 24 21:21 keymaps -> /etc/init.d/keymaps

lrwxrwxrwx 1 root root   22 Apr 24 21:21 localmount -> /etc/init.d/localmount

lrwxrwxrwx 1 root root   19 Apr 24 21:21 modules -> /etc/init.d/modules

...

```

I notice two things: the path for the symlinl is differently stated to the rest, and it comes in different colours. 

Actually is the only one which is covered in red outline with white letters in my terminal, instead of the usual cyan -> green scheme that the others follow. What is that supposed to mean?

----------

## khayyam

 *wpkzz wrote:*   

> 
> 
> ```
> lrwxrwxrwx 1 root root   32 May  9 18:56 hostname -> /etc/init.d//etc/init.d/hostname
> ```
> ...

 

wpkzz ... I'm not sure what would have caused this but the fix is simple:

```
# ln -sf /etc/init.d/hostname /etc/runlevels/boot/hostname
```

best ... khay

----------

## mv

 *wpkzz wrote:*   

> Actually is the only one which is covered in red outline with white letters in my terminal, instead of the usual cyan -> green scheme that the others follow. What is that supposed to mean?

 

It means that it is a dangliing symlink, i.e. not pointing to any file (the path it points to does not exist). As khayyam has noticed, such a link is usually caused by a bug which, however, is now hard to reproduce.

----------

## wpkzz

Hi crew:

I am just discovering that this seems to be part of a bigger issue. dbus-daemon is also not starting, and other 

services are also messed up. I'll check the details and get back to you if I manage to do something usefull.

Thanks!

----------

## wpkzz

Well, this sure is annoying... I have looked everything, read all rc man pages, and even changed the kernel with no avail. Not only hostname doesn't start, but net.*, wicd, wpa_supplicant, etc. Its like rc is not even there. Everything has to be done manually.

----------

## mv

You might reemerge openrc, but before I would check with

```
qcheck openrc
```

what is going on. Perhaps a filesystem corruption broke half of your system. 

```
qcheck -a
```

 might be appropriate.

----------

## wpkzz

I had reemerged openrc a few days ago and it didn't solve the problem. I read on an external forum (which i do not remember) to call

rc with full path, 

```

# /sbin/rc-update add service default

```

And, hello, it worked... I sure do not know why. I checked if I had to rc-update, allias or somethin of the sort. 

But I followed mv's advice and did a qcheck, and this is what I got. It seems that there are a bunch of odd ends here.

```

# qcheck -a -B

media-sound/alsa-utils

dev-texlive/texlive-mathextra

dev-texlive/texlive-latex

dev-texlive/texlive-formatsextra

dev-texlive/texlive-basic

app-text/texlive-core

sys-process/cronbase

dev-lang/ghc

net-wireless/wpa_supplicant

sys-apps/sysvinit

sys-apps/openrc

sys-apps/baselayout

sys-devel/gcc

app-emulation/emul-linux-x86-opengl

net-print/cups

```

and

```

Checking sys-apps/openrc-0.11.8 ...

 MD5-DIGEST: /etc/init.d/net.lo

 MD5-DIGEST: /etc/conf.d/hostname

 MD5-DIGEST: /etc/conf.d/hwclock

 MD5-DIGEST: /etc/rc.conf

  * 298 out of 302 files are good

```

woooo.. . hostname and hwclock and rc.conf have bad md5 digest... but doesn't mean anything, does it? These are text files which I can change.

----------

## mv

 *wpkzz wrote:*   

> woooo.. . hostname and hwclock and rc.conf have bad md5 digest... but doesn't mean anything, does it? These are text files which I can change.

 

These two are files which you probably have changed - therefore the differing md5 from the fresh install. However, init.d/net.lo looks more serious, since you shouldn't have a reason to modify that file

----------

## wpkzz

No, it is not serious at all. I just put a crazy comment in one line of net.lo to see if it was really being used. It was when I discovered that many services were not starting.

----------

## Captain Newbie

A recent (funtoo, don't taze me) install has the same problem. Standby one, gonna re-merge openrc and see if that'll fix it. (Seems to be that something is rotten with openrc.)

edit: yeah, that:

```
emerge -1 openrc

rc
```

<solved>

----------

## Deathwing00

Did you add your hostname to /etc/hosts?

Something like 127.0.0.1 <FQDN> <hostname> localhost ... should do the thing.

----------

## Deathwing00

Moved from Installing Gentoo to Networking & Security.

----------

