<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<font size="-1">OK, it seems I wasn't right. Opennebula DOES honor
the </font><span
style="font-size:13px;font-family:arial,sans-serif">INIT_SCRIPTS
entry.<br>
<br>
I am sorry for blaming you!<br>
<br>
Why I got confused, though? Well, I was testing with a VM and its
template. With every new change that I made to the template I went
to the VM (via Sunstone GUI) and chose from the toolbar the button
that says "Delete recreate", thinking that it will do what it says
- namely it will delete the VM and then recreate it. Appears that
wasn't quite the case. When I clicked the rightmost red button and
chose "Delete" and then deployed the template again, the changes
that I had made to the template actually took effect.<br>
<br>
Question: Why </span><span
style="font-size:13px;font-family:arial,sans-serif"><span
style="font-size:13px;font-family:arial,sans-serif">"Delete
recreate"</span> doesn't do just like when you manually delete
the VM and then re-deploy from template?<br>
<br>
P.S.: </span><span
style="font-size:13px;font-family:arial,sans-serif">Kerry, I
discovered how to create CONTEXT files and put them to the "files"
datastore, don't need to answer me. There is a nice menu in
Sunstone called "Files & Kernels" which I somehow kept
skipping. :)<br>
About your problem with test.sh - see if you have fallen in the
same trap as me - try to first manually delete the VM and then
re-deploy it from template for your changes to take effect. Other
than that, all settings work like expected.<br>
<br>
Thanks,<br>
Pavel Tankov<br>
<br>
</span><span style="font-size:13px;font-family:arial,sans-serif"></span>
<div class="moz-cite-prefix">On 28.11.2014 12:44, Pavel Tankov
wrote:<br>
</div>
<blockquote cite="mid:5478521E.8060209@strategyobject.com"
type="cite">
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
Hello Kerry,<br>
<br>
I am having the same problem. I think I discovered why your
test.sh script doesn't get executed:<br>
<br>
!!! Opennebula completely disregards the <span
style="font-size:13px;font-family:arial,sans-serif">INIT_SCRIPTS="test.sh"</span>
entry in your <tt>CONTEXT=[...]</tt> section of the template !!!<br>
<br>
How to verify? After your VM spins up, login and mount the CONTEXT
image like so:<br>
<br>
<tt>mount -t iso9660 /dev/sr0 /mnt</tt><br>
<br>
Enter <tt>/mnt</tt> and you will find your <tt>test.sh</tt> file
there. So far so good. There is one more file there - <tt>context.sh</tt>.
You can see that it contains the variables from your <tt>CONTEXT=[...]</tt>
section of the template. You can see that it contains an entry
like <tt>FILES_DS='...'</tt> or <tt>FILES='/var/lib/one/datastores/2/test.sh'</tt>
that mentions your script. HOWEVER, it does NOT contain an entry
like <span style="font-size:13px;font-family:arial,sans-serif">INIT_SCRIPTS="test.sh"</span>.
OK, so now open <tt>/etc/one-context.d/99-execute-scripts</tt>.
That script is responsible for executing your custom scripts. Here
it is:<br>
<br>
<tt>#!/bin/bash</tt><tt><br>
</tt><tt><br>
</tt><tt>MOUNT_DIR=/mnt</tt><tt><br>
</tt><tt>TMP_DIR=/tmp/one-context-tmp</tt><tt><br>
</tt><tt><br>
</tt><tt>if [ -z "$INIT_SCRIPTS" ]; then</tt><tt><br>
</tt><tt> if [ -f "$MOUNT_DIR/init.sh" ]; then</tt><tt><br>
</tt><tt> INIT_SCRIPTS=init.sh</tt><tt><br>
</tt><tt> fi</tt><tt><br>
</tt><tt>fi</tt><tt><br>
</tt><tt><br>
</tt><tt>mkdir -p $TMP_DIR</tt><tt><br>
</tt><tt>cd $MOUNT_DIR</tt><tt><br>
</tt><tt><br>
</tt><tt>for f in $INIT_SCRIPTS; do</tt><tt><br>
</tt><tt> cp $f $TMP_DIR</tt><tt><br>
</tt><tt> chmod +x $TMP_DIR/$f</tt><tt><br>
</tt><tt> $TMP_DIR/$f</tt><tt><br>
</tt><tt>done</tt><tt><br>
</tt><br>
In the beginning it checks to see if there is an environment
variable<tt> INIT_SCRIPTS</tt> defined. It is never defined, no
matter whether you put <span
style="font-size:13px;font-family:arial,sans-serif">INIT_SCRIPTS="test.sh"</span>
in your <tt>CONTEXT=[...]</tt> or not because, as it seems,
Opennebula silently disregards it. So, in that case the <tt>99-execute-scripts</tt>
script continues with the default, which is <tt>init.sh</tt>.<br>
<br>
TL; DR;<br>
Name your script <tt>init.sh</tt> and it will be executed.<br>
<br>
Opennebula devs, please, fix this!<br>
<br>
P.S.: Kerry, you say:<br>
<pre><i>> I have created "test.sh" and put it into the "files" datastore on the </i><i>head node.</i></pre>
Please, explain how you did it, because I can't seem to find a
step-by-step explanation about this in the documentation.<br>
<br>
Thanks,<br>
-- Pavel Tankov<br>
<br>
<div class="moz-cite-prefix">On 12.09.2014 02:28, kerryhall .
wrote:<br>
</div>
<blockquote
cite="mid:CAGMXp2vgAfZgmoABYCx=7K8CCYE3S12EPUwkOFyZYETgOFTMgg@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>Hi Valentin,<br>
<br>
I appreciate the help! I managed to create a new CONTEXT
image, which copied my test.sh to the datastore
successfully, and I updated my template to include those two
lines you specified.<br>
<br>
</div>
<div>However, it looks like test.sh is not executing on vm
spin up. Currently all it does is "touch /root/test.tmp" to
confirm execution. However when I booted my vm, this file
was not created. Also tried doing "useradd tmp" as well,
with no luck. test.sh has executable flag set for user,
group, and other. I also tried setting permissions of
test.sh to 777, still no luck. <br>
<br>
</div>
<div>Thanks!!<br>
</div>
<div>Kerry<br>
</div>
<div><br>
<br>
<br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Sep 8, 2014 at 11:27 PM,
Valentin Bud <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:valentin.bud@gmail.com" target="_blank">valentin.bud@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hello Kerry,
<div><br>
</div>
<div>Do you have a registered image of type CONTEXT with
the name of `test.sh`</div>
<div>in the files datastore?</div>
<div><br>
</div>
<div>The file you specify in FILES_DS can be found in
the contextualization CDROM</div>
<div>on the VM (/dev/disk/by-label/CONTEXT). </div>
<div><br>
</div>
<div>The following would run a `test.sh` script when the
VM is spun up at the end</div>
<div>of the contextualization routine [1].</div>
<div><br>
</div>
<div>CONTEXT = [</div>
<div> <span
style="font-size:13px;font-family:arial,sans-serif">FILES_DS="$FILE[IMAGE=\"test.</span><span
style="font-size:13px;font-family:arial,sans-serif">sh\"]",</span></div>
<div><span
style="font-size:13px;font-family:arial,sans-serif">
INIT_SCRIPTS="test.sh",</span></div>
<div><span
style="font-size:13px;font-family:arial,sans-serif">
...</span></div>
<div><font face="arial, sans-serif">]</font></div>
<div><br>
</div>
<div><font face="arial, sans-serif">[1]: <a
moz-do-not-send="true"
href="https://github.com/OpenNebula/addon-context-linux/blob/master/base/etc/one-context.d/99-execute-scripts"
target="_blank">https://github.com/OpenNebula/addon-context-linux/blob/master/base/etc/one-context.d/99-execute-scripts</a></font></div>
<div><br>
</div>
<div>Best,</div>
<div>Valentin</div>
</div>
<div class="HOEnZb">
<div class="h5">
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Mon, Sep 8, 2014 at
11:09 PM, kerryhall . <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:kerryhall@gmail.com"
target="_blank">kerryhall@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0
0 .8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div dir="ltr">Thanks! I'm still having issues
here unfortunately. I tried putting:<br>
<br>
<div>FILES_DS="$FILE[IMAGE=\"test.sh\"]"<br>
<br>
</div>
<div>into my template context section, but I
get:<br>
<br>
</div>
<div>"User 0 does not own an image with name:
test.sh"<br>
<br>
</div>
<div>I'm not trying to include an image, I
just want test.sh (a file in my file
datastore) to get copied to anywhere on my
vm's filesystem. (And eventually, I want
test.sh to get run on vm creation, or
failing that, every time the vm starts)<br>
<br>
Thanks!!<br>
</div>
</div>
<div>
<div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Fri, Jul 25,
2014 at 11:18 PM, Valentin Bud <span
dir="ltr"><<a
moz-do-not-send="true"
href="mailto:valentin.bud@gmail.com"
target="_blank">valentin.bud@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote"
style="margin:0 0 0
.8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div dir="ltr">Hello Kerry,
<div><br>
</div>
<div>Under "Defining Context" [1]
there is an example how to use
FILES_DS.</div>
<div><br>
</div>
<div>FILES_DS="$FILE[IMAGE=\"test.sh\"]</div>
<div><br>
</div>
<div>[1]: <a moz-do-not-send="true"
href="http://docs.opennebula.org/4.6/user/virtual_machine_setup/cong.html"
target="_blank">http://docs.opennebula.org/4.6/user/virtual_machine_setup/cong.html</a></div>
<div><br>
</div>
<div>Best,</div>
<div>Valentin</div>
<div><br>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">
<div>
<div>On Fri, Jul 25, 2014 at
11:29 PM, kerryhall . <span
dir="ltr"><<a
moz-do-not-send="true"
href="mailto:kerryhall@gmail.com"
target="_blank">kerryhall@gmail.com</a>></span>
wrote:<br>
</div>
</div>
<blockquote class="gmail_quote"
style="margin:0 0 0
.8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div>
<div>
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>Hi folks,<br>
<br>
I am trying to
run a bash
script on a vm
as it gets
spun up. I've
read:<br>
<a
moz-do-not-send="true"
href="http://docs.opennebula.org/4.6/user/virtual_machine_setup/cong.html"
target="_blank">http://docs.opennebula.org/4.6/user/virtual_machine_setup/cong.html</a><br>
<br>
</div>
but there
isn't too much
to go on
there. <br>
<br>
</div>
I have created
"test.sh" and
put it into
the "files"
datastore on
the head node.
<br>
<br>
</div>
The issue I am
having is that
the syntax in
the "Defining
Context"
section of <a
moz-do-not-send="true"
href="http://docs.opennebula.org/4.6/user/virtual_machine_setup/cong.html"
target="_blank">http://docs.opennebula.org/4.6/user/virtual_machine_setup/cong.html</a>
is ambiguous,
specifically
the "files_ds"
section. I
have tried:<br>
<br>
</div>
FILES_DS="$FILE[\"test.sh\"]"<br>
<br>
</div>
and <br>
</div>
FILES_DS="/var/lib/one/datastores/2/test.sh"<br>
<br>
</div>
<div>As a first step,
I'm just trying to
get this file
included in my vm at
all.<br>
</div>
<div><br>
</div>
Thanks!<br>
</div>
Kerry<br>
<div>
<div>
<div>
<div>
<div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
</div>
</div>
_______________________________________________<br>
Users mailing list<br>
<a moz-do-not-send="true"
href="mailto:Users@lists.opennebula.org"
target="_blank">Users@lists.opennebula.org</a><br>
<a moz-do-not-send="true"
href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org"
target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Users mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:Users@lists.opennebula.org">Users@lists.opennebula.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a>
</pre>
</blockquote>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opennebula.org">Users@lists.opennebula.org</a>
<a class="moz-txt-link-freetext" href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a>
</pre>
</blockquote>
<br>
</body>
</html>