feature #3651: Add support for start script in context

If START_SCRIPT_BASE64 or START_SCRIPT is found in the context it is saved
to a temporary file and executed.

For OpenNebula ticket: http://dev.opennebula.org/issues/3651
pull/15/head
Javi Fontan 10 years ago
parent d54cad784b
commit 5b4d39f62c

@ -0,0 +1,24 @@
#!/bin/bash
MOUNT_DIR=/mnt
TMP_DIR=/tmp/one-context-tmp
TMP_FILE=$TMP_DIR/one-start-script
START_SCRIPT_AVAILABLE=no
mkdir -p $TMP_DIR
if [ -n "$START_SCRIPT_BASE64" ]; then
echo -en "$START_SCRIPT_BASE64" | openssl enc -d -base64 -A > $TMP_FILE
START_SCRIPT_AVAILABLE=yes
elif [ -n "$START_SCRIPT" ]; then
echo -en "$START_SCRIPT" > $TMP_FILE
START_SCRIPT_AVAILABLE=yes
fi
if [ "$START_SCRIPT_AVAILABLE" = "yes" ]; then
cd $MOUNT_DIR
chmod +x $TMP_FILE
$TMP_FILE
fi
Loading…
Cancel
Save