[one-users] Trouble setting VM's hostname

Pedro Vitti pedrovitti at gmail.com
Tue Apr 17 14:57:07 PDT 2012


Hello,

Are you sure that your init script is running at VM startup?
If so, be sure to 'source' the file context.sh that contains $HOSTNAME
definition, before running your script.

If you are using hdc as your device where the contextualization image will
be available, you can use something like this at startup:

#!/bin/sh -e

mount -t iso9660 /dev/sdc /mnt

if [ -f /mnt/context.sh ]; then
  . /mnt/init.sh
fi

umount /mnt
exit 0

Take a look at last section (EXAMPLE) here:
http://opennebula.org/documentation:archives:rel3.2:cong
For opensuse init script, read this:
http://www.novell.com/coolsolutions/feature/15380.html

Regars,
Pedro Vitti

On Tue, Apr 17, 2012 at 5:56 AM, biro lehel <lehel.biro at yahoo.com> wrote:

> Hello again,
>
> I currently have an init script which I copy to the newly instantiated VM
> using the template's contextualization (FILES=.../init.sh). This script
> contains (among others) the following section:
>
> if [ -n "$HOSTNAME" ]; then
>     hostname $HOSTNAME
>
> HOSTNAME is also a contextualized parameter, as I set HOSTNAME=MyHostName
> also in the contextualization section of my VM's template.
> I would expect this to set my hostname as MyHostName on the instantiated
> VM. However, the hostname remains the same (meaning it still remains the
> same hostname as it is in my image that the respective template uses).
>
> I'm using openSUSE 11.4 and OpenNebula 3.2.0.
>
> What are the other ways to try to set the hostname in my VM's? Since more
> VM's will use the same image, I cannot simply set it in my image. Is
> anything need to be done regarding the hostname in the respective image?
>
> Thanks,
> Lehel.
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opennebula.org
> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opennebula.org/pipermail/users-opennebula.org/attachments/20120417/0e6e3878/attachment-0002.htm>


More information about the Users mailing list