Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I booted a guest vm on xen, and I want to assign guest-domU's hostname in config file. like this

...
extra='ip=::::myguest-vm-hostname::dhcp'
...

It is a kernel command line to setting netboot networking environment.


It works fine on gentoo. Some codes in the file /etc/init.d/hostname are

start(){
  hostname=${hostname-${HOSTNAME-localhost}}
  hostname $hostname
}

That will assign netboot hostname into real hostname.


But! on ubuntu 12, the script /etc/init/hostname.conf(upstart) only get the hostname value in /etc/hostname, or it will be none...

I've tried that edit the /etc/init/hostname.conf on ubuntu like

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

but it doesn't work...

Any help will be appreciated!! Thanks!

share|improve this question

1 Answer 1

I come here to answer my question... I should not erase all contents in /etc/init/hostname.conf(ubuntu), and write the same code of /etc/init.d/hostname(gentoo) into it. the original /etc/init/hostname.conf is

task
exec hostname -b -F /etc/hostname 

the workable hostname.conf is

task
export hostname=${hostname-${HOSTNAME-localhost}}
exec hostname $hostname

On Ubuntu, I should not direct assign variable like hostname=xxx, and I should prepend export to it.

It looks really stupid... haha.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.