summaryrefslogtreecommitdiff
path: root/templates/ci
diff options
context:
space:
mode:
authorCarlos Konstanski <ckonstanski@pippiandcarlos.com>2017-11-13 16:50:55 -0700
committerCarlos Konstanski <ckonstanski@pippiandcarlos.com>2017-11-13 16:50:55 -0700
commitffa2a169ea98fb54a29d90ca158059e79e2816ba (patch)
tree018461d031b71178fa48b9672d8e39bac4de1270 /templates/ci
initial commit
Diffstat (limited to 'templates/ci')
-rwxr-xr-xtemplates/ci/openbook.gentoo25
-rwxr-xr-xtemplates/ci/openbook.redhat29
-rwxr-xr-xtemplates/ci/openbook.ubuntu25
-rwxr-xr-xtemplates/ci/openbookctl114
4 files changed, 193 insertions, 0 deletions
diff --git a/templates/ci/openbook.gentoo b/templates/ci/openbook.gentoo
new file mode 100755
index 0000000..430d70d
--- /dev/null
+++ b/templates/ci/openbook.gentoo
@@ -0,0 +1,25 @@
+#!/sbin/openrc-run
+
+extra_commands=test_database
+
+depend() {
+ need docker
+}
+
+start() {
+ ebegin "Starting Openbook"
+ /opt/openbook/openbookctl start
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping Openbook"
+ /opt/openbook/openbookctl stop
+ eend $?
+}
+
+test_database() {
+ ebegin "Testing database"
+ /opt/openbook/openbookctl test_database
+ eend $?
+}
diff --git a/templates/ci/openbook.redhat b/templates/ci/openbook.redhat
new file mode 100755
index 0000000..c4d3040
--- /dev/null
+++ b/templates/ci/openbook.redhat
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+# openbook
+#
+# chkconfig: 2345 10 90
+# description: Manage the Openbook application
+#
+### BEGIN INIT INFO
+# Provides: openbook
+# Required-Start: docker
+# Required-Stop: docker
+# Short-Description: Bring up/down networking
+# Description: Manage the Openbook application
+### END INIT INFO
+
+case $1 in
+ start*)
+ /opt/openbook/openbookctl start
+ ;;
+ stop*)
+ /opt/openbook/openbookctl stop
+ ;;
+ test_database*)
+ /opt/openbook/openbookctl test_database
+ ;;
+ *)
+ /opt/openbook/openbookctl help
+ ;;
+esac
diff --git a/templates/ci/openbook.ubuntu b/templates/ci/openbook.ubuntu
new file mode 100755
index 0000000..02900fa
--- /dev/null
+++ b/templates/ci/openbook.ubuntu
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+### BEGIN INIT INFO
+# Provides: openbook
+# Required-Start: docker
+# Required-Stop: docker
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Manage the Openbook application
+### END INIT INFO
+
+case $1 in
+ start*)
+ /opt/openbook/openbookctl start
+ ;;
+ stop*)
+ /opt/openbook/openbookctl stop
+ ;;
+ test_database*)
+ /opt/openbook/openbookctl test_database
+ ;;
+ *)
+ /opt/openbook/openbookctl help
+ ;;
+esac
diff --git a/templates/ci/openbookctl b/templates/ci/openbookctl
new file mode 100755
index 0000000..0563a16
--- /dev/null
+++ b/templates/ci/openbookctl
@@ -0,0 +1,114 @@
+#!/bin/bash
+
+echo 'mysql root password: {{ openbook_database_password }}'
+echo 'wsrep_node_address: {{ ansible_default_ipv4.address }}'
+echo 'wsrep_cluster_address: gcomm://{{ openbook_gcomm_addresses }}'
+
+{% if "True" == openbook_install_database|string() %}
+wait_for_database() {
+ echo "Waiting for database to start..."
+ started=1
+ for i in {120..0}; do
+ if echo 'SELECT 1' | mysql -h 127.0.0.1 -u root --password='{{ openbook_database_password }}' &>/dev/null; then
+ started=0
+ break
+ fi
+ sleep 1
+ done
+ if [ $started -eq 1 ]; then
+ echo "Error: database did not start."
+ exit 1
+ fi
+}
+
+ensure_openbook_databases_created() {
+ if ! echo "SHOW DATABASES;" | mysql -h 127.0.0.1 -u root --password='{{ openbook_database_password }}' 2>/dev/null | fgrep 'openbook'; then
+ echo "Creating Openbook schema..."
+ mysql -h 127.0.0.1 -u root --password='{{ openbook_database_password }}' &>/dev/null < /etc/openbook/database/create_openbook_schemas.sql
+ fi
+}
+{% endif %}
+
+do_start() {
+{% if "True" == openbook_install_database|string() %}
+ chmod 777 /var/lib/mysql
+ chmod 777 /var/log/mysql
+ /opt/openbook/database/run.sh
+ wait_for_database
+ ensure_openbook_databases_created
+{% endif %}
+{% if "True" == openbook_install_job_scheduler_server|string() %}
+ /opt/openbook/job_scheduler_server/run.sh
+{% endif %}
+{% if "True" == openbook_install_workflow_server|string() %}
+ /opt/openbook/workflow_server/run.sh
+{% endif %}
+{% if "True" == openbook_install_admin_api_server|string() %}
+ /opt/openbook/admin_api_server/run.sh
+{% endif %}
+{% if "True" == openbook_install_customer_api_server|string() %}
+ /opt/openbook/customer_api_server/run.sh
+{% endif %}
+{% if "True" == openbook_install_admin_web_ui|string() %}
+ /opt/openbook/admin_web_ui/run.sh
+{% endif %}
+{% if "True" == openbook_install_customer_web_ui|string() %}
+ /opt/openbook/customer_web_ui/run.sh
+{% endif %}
+ echo
+ echo "Openbook started. All components may not be fully initialized and available."
+}
+
+do_stop() {
+{% if "True" == openbook_install_customer_web_ui|string() %}
+ docker stop customer_web_ui_unstable
+{% endif %}
+{% if "True" == openbook_install_admin_web_ui|string() %}
+ docker stop admin_web_ui_unstable
+{% endif %}
+{% if "True" == openbook_install_customer_api_server|string() %}
+ docker stop customer_api_server_unstable
+{% endif %}
+{% if "True" == openbook_install_admin_api_server|string() %}
+ docker stop admin_api_server_unstable
+{% endif %}
+{% if "True" == openbook_install_workflow_server|string() %}
+ docker stop workflow_server_unstable
+{% endif %}
+{% if "True" == openbook_install_job_scheduler_server|string() %}
+ docker stop job_scheduler_server_unstable
+{% endif %}
+{% if "True" == openbook_install_database|string() %}
+ docker stop database
+{% endif %}
+ docker container prune -f
+}
+
+do_help() {
+ echo "Usage:"
+ echo " $0 start"
+ echo " $0 stop"
+{% if "True" == openbook_install_database|string() %}
+ echo " $0 test_database"
+{% endif %}
+}
+
+case $1 in
+ start*)
+ do_start
+ ;;
+ stop*)
+ do_stop
+ ;;
+{% if "True" == openbook_install_database|string() %}
+ test_database*)
+ wait_for_database
+ echo "Database is up."
+ ;;
+{% endif %}
+ *)
+ do_help
+ ;;
+esac
+
+exit 0