From 644d1f12e3d66d4679af024040c00ccb497592db Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Tue, 12 May 2015 14:44:36 +0200 Subject: [PATCH] Add script to generate environment file in /tmp/one_env Based in the script made by Daniel Molina : https://github.com/OpenNebula/one/blob/5ce7c87cc8da44afe533561b38c83a71c53459f8/share/onegate/init.sh --- base/etc/one-context.d/06-gen-env | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 base/etc/one-context.d/06-gen-env diff --git a/base/etc/one-context.d/06-gen-env b/base/etc/one-context.d/06-gen-env new file mode 100755 index 0000000..74beaac --- /dev/null +++ b/base/etc/one-context.d/06-gen-env @@ -0,0 +1,25 @@ +#!/bin/bash + +ENV_FILE="/tmp/one_env" + +TOKENTXT=$(cat /mnt/token.txt) +echo "export TOKENTXT=\"$TOKENTXT\"" > $ENV_FILE + +function export_rc_vars +{ + if [ -f $1 ] ; then + ONE_VARS=$(cat $1 | egrep -e '^[a-zA-Z\-\_0-9]*=' | sed 's/=.*$//') + + . $1 + + for v in $ONE_VARS; do + echo "export $v=\"${!v}\"" >> $ENV_FILE + done + fi +} + +export_rc_vars /mnt/context.sh + +chown root:root $ENV_FILE +chmod 400 $ENV_FILE +