http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/config/blobs.yml ---------------------------------------------------------------------- diff --git a/deployment/pcf/config/blobs.yml b/deployment/pcf/config/blobs.yml new file mode 100644 index 0000000..b05a48d --- /dev/null +++ b/deployment/pcf/config/blobs.yml @@ -0,0 +1,19 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +--- {}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/config/final.yml ---------------------------------------------------------------------- diff --git a/deployment/pcf/config/final.yml b/deployment/pcf/config/final.yml new file mode 100644 index 0000000..784703c --- /dev/null +++ b/deployment/pcf/config/final.yml @@ -0,0 +1,24 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +--- +blobstore: + provider: local + options: + blobstore_path: /tmp/usergrid-blobs +final_name: usergrid_blobstore http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/content_migrations.yml ---------------------------------------------------------------------- diff --git a/deployment/pcf/content_migrations.yml b/deployment/pcf/content_migrations.yml new file mode 100644 index 0000000..80035ff --- /dev/null +++ b/deployment/pcf/content_migrations.yml @@ -0,0 +1,53 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +--- +product: apache-usergrid +installation_version: '1.5' +to_version: 0.1.1 +migrations: +- from_version: 0.0.1 + rules: + - type: update + selector: product_version + to: 0.1.1 +- from_version: 0.0.2 + rules: + - type: update + selector: product_version + to: 0.1.1 +- from_version: 0.0.3 + rules: + - type: update + selector: product_version + to: 0.1.1 +- from_version: 0.0.4 + rules: + - type: update + selector: product_version + to: 0.1.1 +- from_version: 0.0.5 + rules: + - type: update + selector: product_version + to: 0.1.1 +- from_version: 0.1.0 + rules: + - type: update + selector: product_version + to: 0.1.1 http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/createRelease.sh ---------------------------------------------------------------------- diff --git a/deployment/pcf/createRelease.sh b/deployment/pcf/createRelease.sh new file mode 100755 index 0000000..e2c58bf --- /dev/null +++ b/deployment/pcf/createRelease.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +RELEASE_VERSION=2.1.0 + +rm -rf dev_releases .dev_builds +bosh create release --with-tarball --version $RELEASE_VERSION http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/createTile.sh ---------------------------------------------------------------------- diff --git a/deployment/pcf/createTile.sh b/deployment/pcf/createTile.sh new file mode 100755 index 0000000..91db8f1 --- /dev/null +++ b/deployment/pcf/createTile.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +TILE_METADATA_VERSION=1.6 + +# Make sure docker-boshrelease-23.tgz tar ball is available + +mkdir -p product/metadata product/releases product/content_migrations # product/javascript-migrations +cp dev_releases/apache*/apache*tgz product/releases +cp docker-boshrelease-23.tgz product/releases +cp apache-usergrid-tile-${TILE_METADATA_VERSION}.yml product/metadata/apache-usergrid.yml +cp content_migrations.yml product/content_migrations +cd product +zip -r ../usergrid.pivotal * +cd .. http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/jobs/delete-all/monit ---------------------------------------------------------------------- diff --git a/deployment/pcf/jobs/delete-all/monit b/deployment/pcf/jobs/delete-all/monit new file mode 100644 index 0000000..bba851e --- /dev/null +++ b/deployment/pcf/jobs/delete-all/monit @@ -0,0 +1,17 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# \ No newline at end of file http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/jobs/delete-all/spec ---------------------------------------------------------------------- diff --git a/deployment/pcf/jobs/delete-all/spec b/deployment/pcf/jobs/delete-all/spec new file mode 100644 index 0000000..3165c6d --- /dev/null +++ b/deployment/pcf/jobs/delete-all/spec @@ -0,0 +1,44 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +--- +name: delete-all +templates: + delete-all.sh.erb: bin/run +packages: +- cf_cli +- elasticsearch_docker +- cassandra_docker +- usergrid_app +properties: + domain: + description: 'CloudFoundry system domain' + app_domains: + description: 'CloudFoundry application domains' + org: + description: 'Org for the Application' + default: '' + space: + description: 'Space for the Application' + default: '' + ssl.skip_cert_verify: + description: 'Whether to verify SSL certs when making web requests' + cf.admin_user: + description: 'Username of the CF admin user' + cf.admin_password: + description: 'Password of the CF admin user' http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/jobs/delete-all/templates/delete-all.sh.erb ---------------------------------------------------------------------- diff --git a/deployment/pcf/jobs/delete-all/templates/delete-all.sh.erb b/deployment/pcf/jobs/delete-all/templates/delete-all.sh.erb new file mode 100644 index 0000000..9bd29ed --- /dev/null +++ b/deployment/pcf/jobs/delete-all/templates/delete-all.sh.erb @@ -0,0 +1,131 @@ +#!/bin/bash + +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +export PATH="/var/vcap/packages/cf_cli/bin:$PATH" +export CF=`which cf` + +function cf() { + echo cf "$@" + output=$($CF "$@" 2>&1) + result="$?" + if [ "$result" -ne "0" ]; then + echo "$output" + # No exit here - best effort continuation on failure for the delete script + fi +} + +function is_true() { + equals_ignore_case "$1" "true" +} + +function equals_ignore_case() { + echo "$1" | grep -i "^$2\$" >/dev/null +} + +function import_opsmgr_variables() { + export SCHEME=https + export ADMIN_USER=<%= properties.cf.admin_user %> + export ADMIN_PASSWORD=<%= properties.cf.admin_password %> + export DOMAIN=<%= properties.domain %> + export APP_DOMAIN=<%= properties.app_domains[0] %> + export CF_ORG=<%= properties.org %> + export CF_SPACE=<%= properties.space %> + export CF_TARGET=$SCHEME://api.${DOMAIN} + export CF_SKIP_SSL=<%= properties.ssl.skip_cert_verify %> +} + +function prepare_cf_cli { + export PATH="/var/vcap/packages/cf_cli/bin:$PATH" + export CF_HOME=`pwd`/home/cf + mkdir -p $CF_HOME +} + +function authenticate() { + $CF --version + if is_true "$CF_SKIP_SSL"; then + cf api $CF_TARGET --skip-ssl-validation + else + cf api $CF_TARGET + fi + cf auth $ADMIN_USER $ADMIN_PASSWORD +} + +function target_org() { + if [ -z "$CF_ORG" ]; then + CF_ORG=apache-usergrid-org + fi + cf target -o $CF_ORG >/dev/null +} + +function target_space() { + if [ -z "$CF_SPACE" ]; then + CF_SPACE=apache-usergrid-space + fi + cf target -s $CF_SPACE >/dev/null +} + +function delete_empty_space() { + output=`$CF apps | tail -1` + if [ "$output" == "No apps found" ]; then + cf delete-space -f $CF_SPACE + fi +} + +function delete_empty_org() { + output=`$CF spaces | tail -1` + if [ "$output" == "No spaces found" ]; then + cf delete-org -f $CF_ORG + fi +} + +function delete_all_versions() { + $CF apps | grep "$1-" | while read app rest; do + cf delete -f $app + done +} + +function delete_service_broker() { + services=`$CF service-access | awk "/broker: $1/{flag=1;next}/broker: /{flag=0}flag" | egrep -v "access *orgs" | grep "." | awk '{print $1}' | uniq` + for service in $services; do + cf purge-service-offering -f "$service" + done + cf delete-service-broker -f $1 +} + +import_opsmgr_variables +prepare_cf_cli +authenticate +if target_org; then + if target_space; then + + # Delete package usergrid_app + # + delete_all_versions usergrid_app + + # Delete package cassandra_docker + # + + # Delete package elasticsearch_docker + # + + delete_empty_space + fi + delete_empty_org +fi \ No newline at end of file http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/jobs/deploy-all/monit ---------------------------------------------------------------------- diff --git a/deployment/pcf/jobs/deploy-all/monit b/deployment/pcf/jobs/deploy-all/monit new file mode 100644 index 0000000..1c19c35 --- /dev/null +++ b/deployment/pcf/jobs/deploy-all/monit @@ -0,0 +1,18 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/jobs/deploy-all/spec ---------------------------------------------------------------------- diff --git a/deployment/pcf/jobs/deploy-all/spec b/deployment/pcf/jobs/deploy-all/spec new file mode 100644 index 0000000..96bd3e7 --- /dev/null +++ b/deployment/pcf/jobs/deploy-all/spec @@ -0,0 +1,145 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +--- +name: deploy-all +templates: + deploy-all.sh.erb: bin/run +packages: + - cf_cli + - elasticsearch_docker + - cassandra_docker + - usergrid_app +properties: + domain: + description: 'CloudFoundry system domain' + app_domains: + description: 'CloudFoundry application domains' + org: + description: 'Org for the Application' + default: '' + space: + description: 'Space for the Application' + default: '' + ssl.skip_cert_verify: + description: 'Whether to verify SSL certs when making web requests' + cf.admin_user: + description: 'Username of the CF admin user' + cf.admin_password: + description: 'Password of the CF admin user' + org_quota: + description: 'Org Memory Quota for the Application' + default: 1024 + apply_open_security_group: + description: 'Open security group for the app to access outside' + default: true + security.user: + description: 'Basic auth user' + security.password: + description: 'Basic auth password' + + elasticsearch.client.type: + description: 'The NODE or TRANSPORT type of client for connecting to ES' + default: 'TRANSPORT' + + elasticsearch.hosts: + description: 'test' + + cassandra.hosts: + description: 'test' + + usergrid_app.name: + description: 'Name of package' + + usergrid.cluster_name: + description: 'test' + default: 'usergrid' + + usergrid.tomcat_instances: + description: number of instances + default: 1 + + usergrid.sysadmin.approve.users: + description: 'test' + default: false + + usergrid.sysadmin.approve.organizations: + description: 'test' + default: false + + usergrid.sysadmin.login.name: + description: 'test' + + usergrid.sysadmin.login.email: + description: 'test' + default: '[email protected]' + + usergrid.sysadmin.login.password: + description: 'test' + + usergrid.sysadmin.login.allowed: + description: 'true' + default: true + + usergrid.setup_test_account: + description: 'test' + default: true + + usergrid.test_account.app: + description: 'test' + default: test-app + + usergrid.test_account.organization: + description: 'test' + default: test-organization + + usergrid.test_account.admin_user.username: + description: 'test' + default: 'test' + + usergrid.test_account.admin_user.name: + description: 'test' + default: 'Test User' + + usergrid.test_account.admin_user.email: + description: 'test' + default: '[email protected]' + + usergrid.test_account.admin_user.password: + description: 'test' + default: 'test' + + mail.smtps.host: + description: 'test' + default: 'test' + + mail.smtps.port: + description: 'test' + default: 'test' + + mail.smtps.auth: + description: 'test' + default: false + + mail.smtps.username: + description: 'test' + default: 'test' + + mail.smtps.password: + description: 'test' + default: 'test' \ No newline at end of file http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/jobs/deploy-all/templates/deploy-all.sh.erb ---------------------------------------------------------------------- diff --git a/deployment/pcf/jobs/deploy-all/templates/deploy-all.sh.erb b/deployment/pcf/jobs/deploy-all/templates/deploy-all.sh.erb new file mode 100644 index 0000000..b4208f3 --- /dev/null +++ b/deployment/pcf/jobs/deploy-all/templates/deploy-all.sh.erb @@ -0,0 +1,384 @@ +#!/bin/bash + +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +export PATH="/var/vcap/packages/cf_cli/bin:$PATH" +export CF=`which cf` + +function cf() { + echo cf "$@" + output=$($CF "$@" 2>&1) + result="$?" + if [ "$result" -ne "0" ]; then + echo "$output" + exit $result + fi +} + +function is_true() { + equals_ignore_case "$1" "true" +} + +function equals_ignore_case() { + echo "$1" | grep -i "^$2\$" >/dev/null +} + +function import_opsmgr_variables() { + export SCHEME=https + export ADMIN_USER=<%= properties.cf.admin_user %> + export ADMIN_PASSWORD=<%= properties.cf.admin_password %> + export DOMAIN=<%= properties.domain %> + export APP_DOMAIN=<%= properties.app_domains[0] %> + export CF_ORG=<%= properties.org %> + export CF_ORG_QUOTA=<%= properties.org_quota %> + export CF_SPACE=<%= properties.space %> + export CF_TARGET=$SCHEME://api.${DOMAIN} + export CF_SKIP_SSL=<%= properties.ssl.skip_cert_verify %> + export SECURITY_USER_NAME=<%= properties.security.user %> + export SECURITY_USER_PASSWORD=<%= properties.security.password %> + export APPLY_OPEN_SECURITY_GROUP=<%= properties.apply_open_security_group %> +} + +function prepare_cf_cli { + export PATH="/var/vcap/packages/cf_cli/bin:$PATH" + export CF_HOME=`pwd`/home/cf + mkdir -p $CF_HOME +} + +function authenticate() { + $CF --version + if is_true "$CF_SKIP_SSL"; then + cf api $CF_TARGET --skip-ssl-validation + else + cf api $CF_TARGET + fi + cf auth $ADMIN_USER $ADMIN_PASSWORD +} + +function setup_target_org() { + if [ -z "$CF_ORG" ]; then + CF_ORG=apache-usergrid-org + fi + if ! $CF org $CF_ORG >/dev/null; then + cf create-org $CF_ORG + fi + cf target -o $CF_ORG +} + +function setup_org_quota() { + if [ -n "$CF_ORG_QUOTA" ]; then + export CF_QUOTA=${CF_ORG}-quota + if ! $CF quota $CF_QUOTA >/dev/null; then + cf create-quota $CF_QUOTA -m ${CF_ORG_QUOTA}m -r 10 -s 10 + fi + cf update-quota $CF_QUOTA -m ${CF_ORG_QUOTA}m -r 10 -s 10 --disallow-paid-service-plans + cf set-quota $CF_ORG $CF_QUOTA + fi +} + +function setup_target_space() { + if [ -z "$CF_SPACE" ]; then + CF_SPACE=apache-usergrid-space + fi + if ! $CF space $CF_SPACE >/dev/null; then + cf create-space $CF_SPACE + fi + cf target -s $CF_SPACE +} + +function add_target_org_to_admin() { + + SYSTEM_ORG_GUID=`$CF org system --guid` + NEW_ORG_GUID=`$CF org $CF_ORG --guid` + + ADMIN_GUID=`$CF curl /v2/organizations/$SYSTEM_ORG_GUID/users | grep -A 2 "username\": \"admin" | awk '{print $2}' | grep organizations | awk -F '/' '{print $4 }' ` + + $CF curl /v2/users/$ADMIN_GUID/organizations/$NEW_ORG_GUID -X PUT >/dev/null + $CF curl /v2/users/$ADMIN_GUID/managed_organizations/$NEW_ORG_GUID -X PUT >/dev/null +} + +function setup_package_path() { + if [ -z "$PACKAGE_PATH" ]; then + export PACKAGE_PATH=/var/vcap/packages + fi +} + +function apply_open_security_group() { + if ! is_true "$1"; then + return + fi + if ! $CF security-group all_open >/dev/null; then + cf create-security-group all_open $PACKAGE_PATH/templates/all_open.json + fi + cf bind-running-security-group all_open +} + +function add_env_vars() { + cf set-env $1 UAA_HOST "$SCHEME://uaa.$DOMAIN" + cf set-env $1 CC_HOST "$CF_TARGET" + cf set-env $1 LOGIN_HOST "$SCHEME://login.$DOMAIN" + cf set-env $1 ROOT "\$HOME" + cf set-env $1 SCHEME "$SCHEME" + cf set-env $1 VERIFY_SSL "$CF_SKIP_SSL" + + # Adding additional properties that most spring based apps or internal apps seem to be expecting + cf set-env $1 CF_ORG "$CF_ORG" + cf set-env $1 CF_SPACE "$CF_SPACE" + cf set-env $1 CF_TARGET "$CF_TARGET" + cf set-env $1 SECURITY_USER_NAME "$SECURITY_USER_NAME" + cf set-env $1 SECURITY_USER_PASSWORD "$SECURITY_USER_PASSWORD" + cf set-env $1 JBP_CONFIG_TOMCAT "{ tomcat: { version: 7.0.62 }}" + + es_hosts_json="<%= properties.elasticsearch.hosts %>" + ca_hosts_json="<%= properties.cassandra.hosts%>" + + export ES_HOSTS=`echo $es_hosts_json | sed -e 's#\[##;s#\]##'` + export CA_HOSTS=`echo $ca_hosts_json | sed -e 's#\[##;s#\]##'` + + cf set-env $1 elasticsearch.hosts "$ES_HOSTS" + cf set-env $1 cassandra.url "$CA_HOSTS" + + export elasticsearch_client_type="<%= properties.elasticsearch.client.type%>" + export cluster_name="<%= properties.usergrid.cluster_name%>" + export approve_users="<%= properties.usergrid.sysadmin.approve.users%>" + export approve_organizations="<%= properties.usergrid.sysadmin.approve.organizations%>" + export login_name="<%= properties.usergrid.sysadmin.login.name%>" + export login_email="<%= properties.usergrid.sysadmin.login.email%>" + export login_password="<%= properties.usergrid.sysadmin.login.password%>" + export login_allowed="<%= properties.usergrid.sysadmin.login.allowed%>" + export setup_test_account="<%= properties.usergrid.setup_test_account%>" + export test_account_app="<%= properties.usergrid.test_account.app%>" + export test_account_organization="<%= properties.usergrid.test_account.organization%>" + export test_account_admin_user_username="<%= properties.usergrid.test_account.admin_user.username%>" + export test_account_admin_user_name="<%= properties.usergrid.test_account.admin_user.name%>" + export test_account_admin_user_email="<%= properties.usergrid.test_account.admin_user.email%>" + export test_account_admin_user_password="<%= properties.usergrid.test_account.admin_user.password%>" + export smtps_host="<%= properties.mail.smtps.host%>" + export smtps_port="<%= properties.mail.smtps.port%>" + export smtps_auth="<%= properties.mail.smtps.auth%>" + export smtps_username="<%= properties.mail.smtps.username%>" + export smtps_password="<%= properties.mail.smtps.password%>" + + cf set-env $1 JAVA_OPTS " -Dcassandra.url=$CA_HOSTS -Delasticsearch.hosts=$ES_HOSTS \ + -Delasticsearch.client.type=$elasticsearch_client_type -Dusergrid.cluster_name=$cluster_name \ + -Dmail.smtps.auth=$smtps_auth -Dmail.smtps.host=$smtps_host -Dmail.smtps.password=$smtps_password \ + -Dmail.smtps.port=$smtps_port -Dmail.smtps.username=$smtps_username \ + -Dusergrid.setup-test-account=$setup_test_account -Dusergrid.sysadmin.approve.organizations=$approve_organizations \ + -Dusergrid.sysadmin.approve.users=approve_users -Dusergrid.sysadmin.login.allowed=true \ + -Dusergrid.sysadmin.login.email=$login_email -Dusergrid.sysadmin.login.name=$login_name \ + -Dusergrid.sysadmin.login.password=$login_password -Dusergrid.test-account.admin-user.email=baasadmins+...@apigee.com \ + -Dusergrid.test-account.admin-user.name=\"$test_account_admin_user_name\" -Dusergrid.test-account.admin-user.password=test \ + -Dusergrid.test-account.admin-user.username=$test_account_admin_user_username -Dusergrid.test-account.app=$test_account_app \ + -Dusergrid.test-account.organization=$test_account_organization" + + # Dynamic plans (if defined) + + # Custom variables from tile.yml +} + +function add_cf_credentials() { + cf set-env $1 CF_ADMIN_USER "$ADMIN_USER" + cf set-env $1 CF_ADMIN_USERNAME "$ADMIN_USER" + cf set-env $1 CF_ADMIN_PASSWORD "$ADMIN_PASSWORD" +} + +function delete_older_versions() { + PKG_NAME="$1" + APP_NAME="$2" + $CF apps | grep "$PKG_NAME" | grep -v "$APP_NAME" | while read app rest; do + cf delete -f $app + done +} + +function wait_till_running() { + + for i in `seq 1 15`; do + CF_TRACE=true $CF app "$1" | grep RUNNING | grep "$1" >/dev/null + if [ "$?" -ne "0" ]; then + sleep 30 + echo "cf app $1 # waiting for running state" + else + break + fi + done +} + +function bootstrap_usergrid() { + + echo "App is running, attempting Usergrid /system/database/setup" + echo " These calls do the following" + echo "1) Create the cassandra keyspace" + echo "2) Initialize the ElasticSearch indexes" + echo "3) Check the status" + echo "" + + ug_db_setup=`curl -k -X PUT https://${APP_HOST}.${APP_DOMAIN}/system/database/setup -u ${login_name}:${login_password}` + echo "setup output: $ug_db_setup" + + echo "App is running, Usergrid /system/database/setup finished, attempting Usergrid /system/database/bootstrap" + ug_db_bootstrap=`curl -k -X PUT https://${APP_HOST}.${APP_DOMAIN}/system/database/bootstrap -u ${login_name}:${login_password}` + echo "boostrap output: $ug_db_bootstrap" + + ug_db_status=`curl -k https://${APP_HOST}.${APP_DOMAIN}/status -u ${login_name}:${login_password}` + echo "Status: $ug_db_status" + echo "Usergrid Bootstrap complete!!" + echo "" +} + +function deploy_app() { + PKG_NAME="$1" + APP_NAME="$2" + APP_HOST="$3" + DOCKER_IMAGE="$4" + NEEDS_CF_CREDS="$5" + HEALTH_CHECK="$6" + AUTO_SERVICES="$7" + + TOMCAT_INSTANCES="<%= properties.usergrid.tomcat_instances%>" + + cf push ${APP_NAME} -n ${APP_HOST} -d ${APP_DOMAIN} \ + ${DOCKER_IMAGE} -f $PACKAGE_PATH/${PKG_NAME}/manifest.yml -b https://github.com/cloudfoundry/java-buildpack \ + -i $TOMCAT_INSTANCES --no-start + + add_env_vars ${APP_NAME} + if is_true "$NEEDS_CF_CREDS"; then + add_cf_credentials ${APP_NAME} + fi + if [ -n "$HEALTH_CHECK" ]; then + cf set-health-check ${APP_NAME} "$HEALTH_CHECK" + fi + provision_auto_services ${PKG_NAME} ${APP_NAME} ${AUTO_SERVICES} + cf start ${APP_NAME} + wait_till_running ${APP_NAME} + bootstrap_usergrid + delete_older_versions ${PKG_NAME} ${APP_NAME} +} + +function provision_auto_services() { + PKG_NAME="$1" + APP_NAME="$2" + shift; shift + for service in $*; do + if equals_ignore_case "$service" "none"; then + continue + fi + $CF services | grep ${PKG_NAME}-$service >/dev/null + if [ "$?" -ne "0" ]; then + plan=`$CF marketplace | grep $service | awk '{ print $2 }' | sed 's/,//g'` + if [ -n "$plan" ]; then + cf create-service $service $plan ${PKG_NAME}-$service + else + echo "no service matching" $service "in marketplace" + exit 1 + fi + fi + cf bind-service ${APP_NAME} ${PKG_NAME}-$service + done +} + +function register_broker() { + BROKER_NAME="$1" + BROKER_USER="$2" + BROKER_PASS="$3" + BROKER_URL="$4" + GLOBAL_ACCESS="$5" + BROKER_SERVICES="$6" + $CF service-brokers | grep $BROKER_NAME >/dev/null + if [ "$?" -ne "0" ]; then + cf create-service-broker "$BROKER_NAME" "$BROKER_USER" "$BROKER_PASS" "$BROKER_URL" + else + cf update-service-broker "$BROKER_NAME" "$BROKER_USER" "$BROKER_PASS" "$BROKER_URL" + fi + if is_true "$GLOBAL_ACCESS"; then + publicize_services "$BROKER_NAME" "$BROKER_SERVICES" + fi +} + +function publicize_services() { + BROKER_NAME="$1" + BROKER_SERVICES="$2" + services_url=`$CF curl /v2/services?q=label:$BROKER_NAME | grep service_plans_url | awk '{ print $2 }' | sed 's/[",]//g'` + if [ -n "$services_url" ]; then + services=`$CF curl $services_url | grep "\"url\"" | awk '{ print $2 }' | sed 's/[",]//g'` + for service in $services; do + cf curl $service -X PUT -d '{"public": true}' + done + elif [ -n "$BROKER_SERVICES" ] && [ "$BROKER_SERVICES" != "INTERNAL_SERVICE_NAME" ]; then + # Rely on the internal plan names if we cannot get it from the /v2/services on the broker + for service_name in `echo "$BROKER_SERVICES" | sed -e 's/,/ /g;s/;/ /g'` + do + cf enable-service-access $service_name + done + else + services=`$CF service-access | awk "/broker: ${BROKER_NAME}/{flag=1;next}/broker: /{flag=0}flag" | egrep -v "access *orgs" | grep "." | awk '{print $1}' | uniq ` + for service_name in $services; do + cf enable-service-access $service_name + done + fi +} + +function push_buildpack() { + BUILDPACK_NAME="$1" + BUILDPACK_ORDER="$2" + BUILDPACK_FILE="$3" + $CF buildpacks | grep ${BUILDPACK_NAME} >/dev/null + if [ "$?" -eq "0" ]; then + cf update-buildpack $BUILDPACK_NAME -p $BUILDPACK_FILE --enable + else + cf create-buildpack $BUILDPACK_NAME $BUILDPACK_FILE $BUILDPACK_ORDER --enable + fi +} + +import_opsmgr_variables +prepare_cf_cli +authenticate +setup_target_org +setup_org_quota +setup_target_space +add_target_org_to_admin +setup_package_path +apply_open_security_group "$APPLY_OPEN_SECURITY_GROUP" + +# Deploy package elasticsearch_docker +# + + + + +# Deploy package cassandra_docker +# + + + + +# Deploy package usergrid_app +# + +export PKG_NAME=usergrid_app +export APP_NAME=usergrid_app-0.1.0 +export APP_HOST=usergrid_app +export DOCKER_IMAGE="" +export NEEDS_CF_CREDS="" +export HEALTH_CHECK="" +export AUTO_SERVICES="" +export AUTO_SERVICES="${AUTO_SERVICES} <%= properties.usergrid_app.persistence_store_type %>" +deploy_app "$PKG_NAME" "$APP_NAME" "$APP_HOST" "$DOCKER_IMAGE" "$NEEDS_CF_CREDS" "$HEALTH_CHECK" "$AUTO_SERVICES" + + + http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/jobs/docker-bosh-cassandra_docker/monit ---------------------------------------------------------------------- diff --git a/deployment/pcf/jobs/docker-bosh-cassandra_docker/monit b/deployment/pcf/jobs/docker-bosh-cassandra_docker/monit new file mode 100644 index 0000000..39b40e3 --- /dev/null +++ b/deployment/pcf/jobs/docker-bosh-cassandra_docker/monit @@ -0,0 +1,23 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +check process docker-bosh-cassandra_docker + with pidfile /var/vcap/sys/run/docker-bosh-cassandra_docker/docker-bosh-cassandra_docker.pid + start program "/var/vcap/jobs/docker-bosh-cassandra_docker/bin/docker-bosh-cassandra_docker_ctl start" + stop program "/var/vcap/jobs/docker-bosh-cassandra_docker/bin/docker-bosh-cassandra_docker_ctl stop" + group vcap http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/jobs/docker-bosh-cassandra_docker/spec ---------------------------------------------------------------------- diff --git a/deployment/pcf/jobs/docker-bosh-cassandra_docker/spec b/deployment/pcf/jobs/docker-bosh-cassandra_docker/spec new file mode 100644 index 0000000..ed998e7 --- /dev/null +++ b/deployment/pcf/jobs/docker-bosh-cassandra_docker/spec @@ -0,0 +1,26 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +--- +name: docker-bosh-cassandra_docker +templates: + docker-bosh-cassandra_docker.sh.erb: bin/docker-bosh-cassandra_docker_ctl +packages: +- cassandra_docker +- common +properties: {} http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/jobs/docker-bosh-cassandra_docker/templates/docker-bosh-cassandra_docker.sh.erb ---------------------------------------------------------------------- diff --git a/deployment/pcf/jobs/docker-bosh-cassandra_docker/templates/docker-bosh-cassandra_docker.sh.erb b/deployment/pcf/jobs/docker-bosh-cassandra_docker/templates/docker-bosh-cassandra_docker.sh.erb new file mode 100644 index 0000000..5669dda --- /dev/null +++ b/deployment/pcf/jobs/docker-bosh-cassandra_docker/templates/docker-bosh-cassandra_docker.sh.erb @@ -0,0 +1,69 @@ +#!/bin/bash + +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +set -e # exit immediately if a simple command exits with a non-zero status +set -u # report the usage of uninitialized variables + +# Setup env vars and folders +RUN_DIR=/var/vcap/sys/run/docker-bosh-cassandra_docker +LOG_DIR=/var/vcap/sys/log/docker-bosh-cassandra_docker +PACKAGES_DIR=/var/vcap/packages/cassandra_docker + +PIDFILE=$RUN_DIR/docker-bosh-cassandra_docker.pid + +source /var/vcap/packages/common/utils.sh + +case $1 in + + start) + pid_guard $PIDFILE docker-bosh-cassandra_docker + + mkdir -p $RUN_DIR + mkdir -p $LOG_DIR + + chown vcap:vcap $RUN_DIR + chown -R vcap:vcap $LOG_DIR + + echo $$ > $PIDFILE + chown vcap:vcap $PIDFILE + + for image in $PACKAGES_DIR/*.tgz; do + /var/vcap/packages/docker/bin/docker \ + --host unix:///var/vcap/sys/run/docker/docker.sock \ + load -i $image \ + >>$LOG_DIR/docker-bosh-cassandra_docker.stdout.log \ + 2>>$LOG_DIR/docker-bosh-cassandra_docker.stderr.log + done + + # do nothing forever + exec tail -f /dev/null + ;; + + stop) + kill_and_wait $PIDFILE + + ;; + *) + echo "Usage: docker-bosh-cassandra_docker_ctl {start|stop}" + + ;; + +esac +exit 0 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/jobs/docker-bosh-elasticsearch_docker/monit ---------------------------------------------------------------------- diff --git a/deployment/pcf/jobs/docker-bosh-elasticsearch_docker/monit b/deployment/pcf/jobs/docker-bosh-elasticsearch_docker/monit new file mode 100644 index 0000000..1846260 --- /dev/null +++ b/deployment/pcf/jobs/docker-bosh-elasticsearch_docker/monit @@ -0,0 +1,23 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +check process docker-bosh-elasticsearch_docker + with pidfile /var/vcap/sys/run/docker-bosh-elasticsearch_docker/docker-bosh-elasticsearch_docker.pid + start program "/var/vcap/jobs/docker-bosh-elasticsearch_docker/bin/docker-bosh-elasticsearch_docker_ctl start" + stop program "/var/vcap/jobs/docker-bosh-elasticsearch_docker/bin/docker-bosh-elasticsearch_docker_ctl stop" + group vcap http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/jobs/docker-bosh-elasticsearch_docker/spec ---------------------------------------------------------------------- diff --git a/deployment/pcf/jobs/docker-bosh-elasticsearch_docker/spec b/deployment/pcf/jobs/docker-bosh-elasticsearch_docker/spec new file mode 100644 index 0000000..7f66165 --- /dev/null +++ b/deployment/pcf/jobs/docker-bosh-elasticsearch_docker/spec @@ -0,0 +1,26 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +--- +name: docker-bosh-elasticsearch_docker +templates: + docker-bosh-elasticsearch_docker.sh.erb: bin/docker-bosh-elasticsearch_docker_ctl +packages: +- elasticsearch_docker +- common +properties: {} http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/jobs/docker-bosh-elasticsearch_docker/templates/docker-bosh-elasticsearch_docker.sh.erb ---------------------------------------------------------------------- diff --git a/deployment/pcf/jobs/docker-bosh-elasticsearch_docker/templates/docker-bosh-elasticsearch_docker.sh.erb b/deployment/pcf/jobs/docker-bosh-elasticsearch_docker/templates/docker-bosh-elasticsearch_docker.sh.erb new file mode 100644 index 0000000..2f3bab7 --- /dev/null +++ b/deployment/pcf/jobs/docker-bosh-elasticsearch_docker/templates/docker-bosh-elasticsearch_docker.sh.erb @@ -0,0 +1,69 @@ +#!/bin/bash + +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +set -e # exit immediately if a simple command exits with a non-zero status +set -u # report the usage of uninitialized variables + +# Setup env vars and folders +RUN_DIR=/var/vcap/sys/run/docker-bosh-elasticsearch_docker +LOG_DIR=/var/vcap/sys/log/docker-bosh-elasticsearch_docker +PACKAGES_DIR=/var/vcap/packages/elasticsearch_docker + +PIDFILE=$RUN_DIR/docker-bosh-elasticsearch_docker.pid + +source /var/vcap/packages/common/utils.sh + +case $1 in + + start) + pid_guard $PIDFILE docker-bosh-elasticsearch_docker + + mkdir -p $RUN_DIR + mkdir -p $LOG_DIR + + chown vcap:vcap $RUN_DIR + chown -R vcap:vcap $LOG_DIR + + echo $$ > $PIDFILE + chown vcap:vcap $PIDFILE + + for image in $PACKAGES_DIR/*.tgz; do + /var/vcap/packages/docker/bin/docker \ + --host unix:///var/vcap/sys/run/docker/docker.sock \ + load -i $image \ + >>$LOG_DIR/docker-bosh-elasticsearch_docker.stdout.log \ + 2>>$LOG_DIR/docker-bosh-elasticsearch_docker.stderr.log + done + + # do nothing forever + exec tail -f /dev/null + ;; + + stop) + kill_and_wait $PIDFILE + + ;; + *) + echo "Usage: docker-bosh-elasticsearch_docker_ctl {start|stop}" + + ;; + +esac +exit 0 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/packages/cassandra_docker/packaging ---------------------------------------------------------------------- diff --git a/deployment/pcf/packages/cassandra_docker/packaging b/deployment/pcf/packages/cassandra_docker/packaging new file mode 100644 index 0000000..2b1f9d5 --- /dev/null +++ b/deployment/pcf/packages/cassandra_docker/packaging @@ -0,0 +1,26 @@ +#!/bin/bash + +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +# abort script on any command that exit with a non zero value +set -e + +cp -r templates ${BOSH_INSTALL_TARGET} + +cp cassandra_docker/cassandra-2.1.tgz ${BOSH_INSTALL_TARGET} http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/packages/cassandra_docker/spec ---------------------------------------------------------------------- diff --git a/deployment/pcf/packages/cassandra_docker/spec b/deployment/pcf/packages/cassandra_docker/spec new file mode 100644 index 0000000..17cc214 --- /dev/null +++ b/deployment/pcf/packages/cassandra_docker/spec @@ -0,0 +1,26 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +--- +name: cassandra_docker + +dependencies: [] + +files: +- templates/all_open.json +- cassandra_docker/cassandra-2.1.tgz http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/packages/cf_cli/packaging ---------------------------------------------------------------------- diff --git a/deployment/pcf/packages/cf_cli/packaging b/deployment/pcf/packages/cf_cli/packaging new file mode 100644 index 0000000..b2c38ba --- /dev/null +++ b/deployment/pcf/packages/cf_cli/packaging @@ -0,0 +1,26 @@ +#! /bin/bash + +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +set -e + +mkdir -p ${BOSH_INSTALL_TARGET}/bin +cd cf_cli +tar zxvf cf-linux-amd64.tgz +cp cf ${BOSH_INSTALL_TARGET}/bin/ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/packages/cf_cli/spec ---------------------------------------------------------------------- diff --git a/deployment/pcf/packages/cf_cli/spec b/deployment/pcf/packages/cf_cli/spec new file mode 100644 index 0000000..f9bc92b --- /dev/null +++ b/deployment/pcf/packages/cf_cli/spec @@ -0,0 +1,25 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +--- +name: cf_cli + +dependencies: [] + +files: +- cf_cli/cf-linux-amd64.tgz http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/packages/common/packaging ---------------------------------------------------------------------- diff --git a/deployment/pcf/packages/common/packaging b/deployment/pcf/packages/common/packaging new file mode 100644 index 0000000..7ca503a --- /dev/null +++ b/deployment/pcf/packages/common/packaging @@ -0,0 +1,23 @@ +#!/bin/bash + +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +set -e -x + +cp -a common/* ${BOSH_INSTALL_TARGET} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/packages/common/spec ---------------------------------------------------------------------- diff --git a/deployment/pcf/packages/common/spec b/deployment/pcf/packages/common/spec new file mode 100644 index 0000000..ad325c9 --- /dev/null +++ b/deployment/pcf/packages/common/spec @@ -0,0 +1,25 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +--- +name: common + +dependencies: [] + +files: +- common/* http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/packages/elasticsearch_docker/packaging ---------------------------------------------------------------------- diff --git a/deployment/pcf/packages/elasticsearch_docker/packaging b/deployment/pcf/packages/elasticsearch_docker/packaging new file mode 100644 index 0000000..a1306d1 --- /dev/null +++ b/deployment/pcf/packages/elasticsearch_docker/packaging @@ -0,0 +1,26 @@ +#!/bin/bash + +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +# abort script on any command that exit with a non zero value +set -e + +cp -r templates ${BOSH_INSTALL_TARGET} + +cp elasticsearch_docker/elasticsearch-1.7.tgz ${BOSH_INSTALL_TARGET} http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/packages/elasticsearch_docker/spec ---------------------------------------------------------------------- diff --git a/deployment/pcf/packages/elasticsearch_docker/spec b/deployment/pcf/packages/elasticsearch_docker/spec new file mode 100644 index 0000000..4a553ab --- /dev/null +++ b/deployment/pcf/packages/elasticsearch_docker/spec @@ -0,0 +1,26 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +--- +name: elasticsearch_docker + +dependencies: [] + +files: +- templates/all_open.json +- elasticsearch_docker/elasticsearch-1.7.tgz http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/packages/usergrid_app/packaging ---------------------------------------------------------------------- diff --git a/deployment/pcf/packages/usergrid_app/packaging b/deployment/pcf/packages/usergrid_app/packaging new file mode 100644 index 0000000..586922b --- /dev/null +++ b/deployment/pcf/packages/usergrid_app/packaging @@ -0,0 +1,27 @@ +#!/bin/bash + +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +# abort script on any command that exit with a non zero value +set -e + +cp -r templates ${BOSH_INSTALL_TARGET} + +cp usergrid_app/ROOT.war ${BOSH_INSTALL_TARGET} +cp usergrid_app/manifest.yml ${BOSH_INSTALL_TARGET} http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/packages/usergrid_app/spec ---------------------------------------------------------------------- diff --git a/deployment/pcf/packages/usergrid_app/spec b/deployment/pcf/packages/usergrid_app/spec new file mode 100644 index 0000000..176821a --- /dev/null +++ b/deployment/pcf/packages/usergrid_app/spec @@ -0,0 +1,27 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +--- +name: usergrid_app + +dependencies: [] + +files: +- templates/all_open.json +- usergrid_app/manifest.yml +- usergrid_app/ROOT.war http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/run.sh ---------------------------------------------------------------------- diff --git a/deployment/pcf/run.sh b/deployment/pcf/run.sh new file mode 100755 index 0000000..a4eb7c1 --- /dev/null +++ b/deployment/pcf/run.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +export RELEASE_VERSION=2.1.0 +export TILE_METADATA_VERSION=1.6 + +./createRelease.sh +./createTile.sh http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/src/common/utils.sh ---------------------------------------------------------------------- diff --git a/deployment/pcf/src/common/utils.sh b/deployment/pcf/src/common/utils.sh new file mode 100644 index 0000000..6325e7b --- /dev/null +++ b/deployment/pcf/src/common/utils.sh @@ -0,0 +1,107 @@ +#!/bin/bash + +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +mkdir -p /var/vcap/sys/log + +exec > >(tee -a >(logger -p user.info -t vcap.$(basename $0).stdout) | awk -W interactive '{lineWithDate="echo [`date +\"%Y-%m-%d %H:%M:%S%z\"`] \"" $0 "\""; system(lineWithDate) }' >>/var/vcap/sys/log/$(basename $0).log) +exec 2> >(tee -a >(logger -p user.error -t vcap.$(basename $0).stderr) | awk -W interactive '{lineWithDate="echo [`date +\"%Y-%m-%d %H:%M:%S%z\"`] \"" $0 "\""; system(lineWithDate) }' >>/var/vcap/sys/log/$(basename $0).err.log) + +pid_guard() { + echo "------------ STARTING `basename $0` at `date` --------------" | tee /dev/stderr + pidfile=$1 + name=$2 + + if [ -f "$pidfile" ]; then + pid=$(head -1 "$pidfile") + + if [ -n "$pid" ] && [ -e /proc/$pid ]; then + echo "$name is already running, please stop it first" + exit 1 + fi + + echo "Removing stale pidfile..." + rm $pidfile + fi +} + +wait_pidfile() { + pidfile=$1 + try_kill=$2 + timeout=${3:-0} + force=${4:-0} + countdown=$(( $timeout * 10 )) + + if [ -f "$pidfile" ]; then + pid=$(head -1 "$pidfile") + + if [ -z "$pid" ]; then + echo "Unable to get pid from $pidfile" + exit 1 + fi + + if [ -e /proc/$pid ]; then + if [ "$try_kill" = "1" ]; then + echo "Killing $pidfile: $pid " + kill $pid + fi + while [ -e /proc/$pid ]; do + sleep 0.1 + [ "$countdown" != '0' -a $(( $countdown % 10 )) = '0' ] && echo -n . + if [ $timeout -gt 0 ]; then + if [ $countdown -eq 0 ]; then + if [ "$force" = "1" ]; then + echo -ne "\nKill timed out, using kill -9 on $pid... " + kill -9 $pid + sleep 0.5 + fi + break + else + countdown=$(( $countdown - 1 )) + fi + fi + done + if [ -e /proc/$pid ]; then + echo "Timed Out" + else + echo "Stopped" + fi + else + echo "Process $pid is not running" + fi + + rm -f $pidfile + else + echo "Pidfile $pidfile doesn't exist" + fi +} + +kill_and_wait() { + pidfile=$1 + # Monit default timeout for start/stop is 30s + # Append 'with timeout {n} seconds' to monit start/stop program configs + timeout=${2:-25} + force=${3:-1} + + wait_pidfile $pidfile 1 $timeout $force +} + +running_in_container() { + grep -q '/instance' /proc/self/cgroup +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/src/templates/all_open.json ---------------------------------------------------------------------- diff --git a/deployment/pcf/src/templates/all_open.json b/deployment/pcf/src/templates/all_open.json new file mode 100644 index 0000000..ef60dec --- /dev/null +++ b/deployment/pcf/src/templates/all_open.json @@ -0,0 +1,6 @@ +[ + { + "destination": "0.0.0.0-255.255.255.255", + "protocol": "all" + } +] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c287b2/deployment/pcf/src/usergrid_app/manifest.yml ---------------------------------------------------------------------- diff --git a/deployment/pcf/src/usergrid_app/manifest.yml b/deployment/pcf/src/usergrid_app/manifest.yml new file mode 100644 index 0000000..0fe9295 --- /dev/null +++ b/deployment/pcf/src/usergrid_app/manifest.yml @@ -0,0 +1,22 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. The ASF licenses this file to You +# under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. For additional information regarding +# copyright in this work, please see the NOTICE file in the top level +# directory of this distribution. +# + +--- +path: ROOT.war +timeout: 180 +memory: 1024M
