Project

General

Profile

Tâche #13661

Updated by Klaas TJEBBES over 5 years ago



Ajout dans /etc/one/oned.conf
<pre><code class="ruby"> class="ruby"/>
VM_HOOK = [
name = "AppMarket_Vm",
on = "SHUTDOWN",
command = "eole/appmarket_update.sh",
arguments = "VM_HOOK $ID",
remote = "YES"
]
IMAGE_HOOK = [
name = "AppMarket_Image",
on = "RUNNING",
command = "eole/appmarket_update.sh",
arguments = "IMAGE_HOOK $ID",
remote = "YES"
]
</code>


</pre>

Script /var/lib/one/remotes/hooks/eole/appmarket_update.sh
<pre><code class="ruby"> class="ruby"/>
#!/bin/bash

typeHook=${1}
ID=${2}

function log()
{
echo "$*" >>/var/log/one/appmarket_update.log
}

function xpath()
{
echo "$template" | /var/lib/one/remotes/datastore/xpath.rb --stdin $*
}

function getProperty()
{
echo "$template" | grep "$1"
}

case "$typeHook" in
VM_HOOK)
template=$(onevm show $ID -x )
USER_NAME=$(xpath UNAME)
OWNER_USE_PERMISSION=$(xpath PERMISSIONS/OWNER_U)
log "$typeHook $ID $USER_NAME $OWNER_USE_PERMISSION"
log "$template"
exit 0
;;

IMAGE_HOOK)
template=$(oneimg show $ID )
USER_NAME=$(xpath UNAME)
SOURCE=$(getProperty SOURCE)
log "$typeHook $ID $USER_NAME $SOURCE"
log "$template"
exit 0
;;

*)
log "$typeHook inconnu !"
exit 1
;;
esac
</code>

</pre>

Back