classes/plugins/CouchdbPlugin.tmpl
{{ header }}
if [ "$START_{{softwareComponentName|upper}}" = "YES" ]; then
{{ preparecomp }}
{{ getsource }}
{{ prestart }}
if [ "${{typeSourceVarName}}" == "docker" ]; then
if [ ! -f "{{pidFile}}" ]; then
startDockerNetwork
{{writeDockerConnectionLogic}}
{{writeConfigFiles}}
verbosePrint "docker run --rm -d -p {{ExposedPort}}:{{ExposedPort}} {% if DockerMemory %}-m {{DockerMemory}}{% endif %} --net={{systemName|lower}}net --name={{softwareComponentName}} $ADD_HOST_INTERNAL {{AllEnvVarsDocker}} {{mountToDocker}} {{DockerImage}}:${{typeSourceVarName}}_VERSION"
{{dcId}}=$(docker run --rm -d -p {{ExposedPort}}:{{ExposedPort}} \
{% if DockerMemory %}-m {{DockerMemory}}{% endif %} \
--net={{systemName|lower}}net --name={{softwareComponentName}} $ADD_HOST_INTERNAL \
{{AllEnvVarsDocker}} {{mountToDocker}} {{DockerImage}}:${{typeSourceVarName}}_VERSION)
echo "${{dcId}}">{{pidFile}}
else
{{dcId}}=$(<{{pidFile}})
echo "Reusing already running instance ${{dcId}}"
fi
fi
if [ "${{typeSourceVarName}}" == "local" ]; then
if [ -f "{{pidFile}}" ]; then
echo "couchdb {{softwareComponentName}} running but started from different source type"
exit 1
fi
fi
{{ poststart }}
while [ "$(curl --write-out %{http_code} --silent --output /dev/null http://localhost:{{ExposedPort}})" != "200" ]; do
echo "waiting for couchdb..."
sleep 1
done
{% for couchDBEle in couchDBs %}
if [[ "$(curl -s http://localhost:{{ExposedPort}}/{{couchDBEle.Schema}})" =~ .*"error".*"not_found".* ]]; then
curl -X PUT http://localhost:{{ExposedPort}}/{{couchDBEle.Schema}}
{% for e in couchDBEle.Create %}
curl -X POST -H "Content-Type: application/json" -d @{{e}} http://localhost:{{ExposedPort}}/{{couchDBEle.Schema}}
{% endfor %}
fi
{% endfor %}
{{ leavecomp }}
fi