diff --git a/smartgears/ckan_connector/tasks/main.yml b/smartgears/ckan_connector/tasks/main.yml index c8c396af..a0c004a7 100644 --- a/smartgears/ckan_connector/tasks/main.yml +++ b/smartgears/ckan_connector/tasks/main.yml @@ -17,7 +17,7 @@ creates: '{{ smartgears_instance_path }}/webapps/ckan-connector/WEB-INF/web.xml' - name: Install the CKAN connector web.xml template - template: src=ckan-web.xml.j2 dest={{ smartgears_instance_path }}/webapps/ckan-connector/WEB-INF/web.xml mode=0440 + template: src=ckan-web.xml.j2 dest={{ smartgears_instance_path }}/webapps/ckan-connector/WEB-INF/.web.xml.tpl mode=0440 - name: Install the CKAN connector fixer script become: False diff --git a/smartgears/ckan_connector/templates/ckan-connector-fixer.sh.j2 b/smartgears/ckan_connector/templates/ckan-connector-fixer.sh.j2 index d593b67d..de17df2c 100644 --- a/smartgears/ckan_connector/templates/ckan-connector-fixer.sh.j2 +++ b/smartgears/ckan_connector/templates/ckan-connector-fixer.sh.j2 @@ -1,7 +1,9 @@ #!/bin/bash CK_WEB_DIR={{ smartgears_instance_path }}/webapps/ckan-connector/WEB-INF -CK_WEB_XML=$CK_WEB_DIR/web.xml +CK_WEB_XML=$CK_WEB_DIR/.web.xml.tpl +CK_WEB_XML_TMP=$CK_WEB_DIR/.web.xml.tmp +CK_WEB_XML_DEST=$CK_WEB_DIR/web.xml CK_DB_NAME={{ ckan_db_name }} CK_DB_USER={{ ckan_db_user }} CK_DB_HOST={{ psql_db_host }} @@ -36,29 +38,30 @@ CKAN_KEY=$( grep ^beaker\.session\.secret $CK_INI | awk '{ print $3 }' ) [ $? -ne 0 ] && exit 1 +cp $CK_WEB_XML $CK_WEB_XML_TMP # Use the admin key on the connector web.xml if [ ! -z $API_KEY ] ; then - sed -i -e "s#@CKAN_API_KEY@#${API_KEY}#g" $CK_WEB_XML + sed -i -e "s#@CKAN_API_KEY@#${API_KEY}#g" $CK_WEB_XML_TMP else exit 1 fi # Use the ckan key on the connector web.xml if [ ! -z $CKAN_KEY ] ; then - sed -i -e "s#@CKAN_SECRET@#${CKAN_KEY}#g" $CK_WEB_XML + sed -i -e "s#@CKAN_SECRET@#${CKAN_KEY}#g" $CK_WEB_XML_TMP else exit 1 fi +{% endraw %} -chown {{ smartgears_user }}:{{ smartgears_user }} $CK_WEB_XML -chmod 440 $CK_WEB_XML +mv $CK_WEB_XML_TMP $CK_WEB_XML_DEST +chown {{ smartgears_user }}:{{ smartgears_user }} $CK_WEB_XML_DEST +chmod 440 $CK_WEB_XML_DEST rm -f $SQL_FILE touch $CK_WEB_DIR/.web.xml.configured -{% endraw %} - exit 0