From 5b4d39f62c6b4892b80d2826a4091fd569e61f7e Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 14 May 2015 19:26:34 +0200 Subject: [PATCH] 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 --- base/etc/one-context.d/99-start-script | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 base/etc/one-context.d/99-start-script diff --git a/base/etc/one-context.d/99-start-script b/base/etc/one-context.d/99-start-script new file mode 100755 index 0000000..8f872d9 --- /dev/null +++ b/base/etc/one-context.d/99-start-script @@ -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 +