From 5988359b12b4fcab06c07bbcef5f0d3ff3191173 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Wed, 16 Nov 2016 14:37:35 +0100 Subject: [PATCH] library/roles/smartgears/smartgears_egi_image: Fixes to the smartgears-setup script. Now the token is removed from the cloud-init data files. Add more logging info to the get-gcube-keys script. --- .../templates/get-gcube-keys.sh.j2 | 21 ++++++++++++------- .../templates/smartgears-setup.sh.j2 | 18 ++++++++++------ 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/smartgears/smartgears_egi_image/templates/get-gcube-keys.sh.j2 b/smartgears/smartgears_egi_image/templates/get-gcube-keys.sh.j2 index e798768..7c80138 100644 --- a/smartgears/smartgears_egi_image/templates/get-gcube-keys.sh.j2 +++ b/smartgears/smartgears_egi_image/templates/get-gcube-keys.sh.j2 @@ -4,10 +4,13 @@ SM_DIR={{ smartgears_install_path }} SM_LIB_DIR=${SM_DIR}/lib # The dataminer wants the gcube keys in a different directory too SM_DATAMINER_PARALLEL_PROC={{ smartgears_user_home }}/tomcat/webapps/wps/ecocfg/PARALLEL_PROCESSING -LOG_FILE=/var/log/smartgears-gcubekeys-setup.log +LOG_DIR=/var/log/smartgears-gcubekeys-setup +LOG_FILE=${LOG_DIR}/gcubekeys-setup.log INFRA_NAME=$1 -> $LOG_FILE +rm -f $LOG_DIR/* +rmdir $LOG_DIR +mkdir -p $LOG_DIR if [ ! -d $SM_LIB_DIR ] ; then echo "$0: The lib directory: $SM_LIB_DIR does not exist, aborting" >> $LOG_FILE @@ -17,13 +20,15 @@ else fi if [ "$INFRA_NAME" == "gcube" ] ; then - wget {{ gcube_dkey_1 }} --no-check-certificate -o /dev/null -O gcube.gcubekey - wget {{ gcube_dkey_2 }} --no-check-certificate -o /dev/null -O devsec.gcubekey - wget {{ gcube_dkey_3 }} --no-check-certificate -o /dev/null -O devNext.gcubekey + echo "Downloading the keys for the $INFRA_NAME infra" >> $LOG_FILE + wget {{ gcube_dkey_1 }} --no-check-certificate -o $LOG_FILE.gcube -O gcube.gcubekey + wget {{ gcube_dkey_2 }} --no-check-certificate -o $LOG_FILE.devsec -O devsec.gcubekey + wget {{ gcube_dkey_3 }} --no-check-certificate -o $LOG_FILE.devNext -O devNext.gcubekey elif [ "$INFRA_NAME" == "d4science.research-infrastructures.eu" ] ; then - wget {{ gcube_pkey_1 }} --no-check-certificate -o /dev/null -O d4science.research-infrastructures.eu.gcubekey - wget {{ gcube_pkey_2 }} --no-check-certificate -o /dev/null -O FARM.gcubekey - wget {{ gcube_pkey_3 }} --no-check-certificate -o /dev/null -O gCubeApps.gcubekey + echo "Downloading the keys for the $INFRA_NAME infra" >> $LOG_FILE + wget {{ gcube_pkey_1 }} --no-check-certificate -o $LOG_FILE.d4science -O d4science.research-infrastructures.eu.gcubekey + wget {{ gcube_pkey_2 }} --no-check-certificate -o $LOG_FILE.FARM -O FARM.gcubekey + wget {{ gcube_pkey_3 }} --no-check-certificate -o $LOG_FILE.gCubeApps -O gCubeApps.gcubekey chmod 400 $SM_LIB_DIR/*.gcubekey else echo "The Infra name is unknown, no keys downloaded" >> $LOG_FILE diff --git a/smartgears/smartgears_egi_image/templates/smartgears-setup.sh.j2 b/smartgears/smartgears_egi_image/templates/smartgears-setup.sh.j2 index 8374c14..cb1395a 100755 --- a/smartgears/smartgears_egi_image/templates/smartgears-setup.sh.j2 +++ b/smartgears/smartgears_egi_image/templates/smartgears-setup.sh.j2 @@ -18,6 +18,7 @@ PUB_FQDN_HOST= PUBLIC_IP= MAIN_IP= RETVAL=0 +CLOUD_INSTANCE_DIR=/var/lib/cloud/instance MEM=$( free -m | egrep ^Mem | awk '{ print $2 }' ) JAVA_MAX_HEAP=$( expr $MEM - 2048 ) @@ -86,10 +87,6 @@ function smartgears_config_parameters_check() { echo "The infrastructure name is void" >> $LOG_FILE RETVAL=1 fi - if [ -z "${SCOPE}" ] ; then - echo "The scope is void" >> $LOG_FILE - RETVAL=1 - fi if [ -z "${COUNTRY}" ] ; then echo "The country code is void, setting a default" >> $LOG_FILE export COUNTRY="IT" @@ -167,10 +164,18 @@ function set_java_heap() { JAVA_MAX_HEAP=1024 fi grep -v ^JAVA_HEAP $TOMCAT_DEFAULT > $TOMCAT_DEFAULT.tmp - echo 'JAVA_HEAP="-Xms${JAVA_MAX_HEAP}m -Xmx${JAVA_MAX_HEAP}m"' >> $TOMCAT_DEFAULT.tmp - mv $TOMCAT_DEFAULT.tmp $TOMCAT_DEFAULT + echo "JAVA_HEAP='-Xms${JAVA_MAX_HEAP}m -Xmx${JAVA_MAX_HEAP}m'" > $TOMCAT_DEFAULT.heap + cat $TOMCAT_DEFAULT.heap $TOMCAT_DEFAULT.tmp > $TOMCAT_DEFAULT } +function cleanup_cloud_user_data() { + # Remove the token from the use provided data file + echo "-- cleanup_cloud_user_data" >> $LOG_FILE + grep -v SMARTGEARS_TOKEN $CLOUD_INSTANCE_DIR/user-data.txt > $CLOUD_INSTANCE_DIR/user-data.txt.tmp + mv $CLOUD_INSTANCE_DIR/user-data.txt.tmp $CLOUD_INSTANCE_DIR/user-data.txt + grep -v SMARTGEARS_TOKEN $CLOUD_INSTANCE_DIR/user-data.txt.i > $CLOUD_INSTANCE_DIR/user-data.txt.i.tmp + mv $CLOUD_INSTANCE_DIR/user-data.txt.i.tmp $CLOUD_INSTANCE_DIR/user-data.txt.i +} ############################## # @@ -191,6 +196,7 @@ get_smartgears_scope_tokens merge_container_xml get_gcube_keys set_java_heap +cleanup_cloud_user_data /usr/sbin/update-rc.d ${SVC} enable >> $LOG_FILE 2>&1 /etc/init.d/${SVC} start >> $LOG_FILE 2>&1