diff --git a/Workbench/scripts/gethealth2.py b/Workbench/scripts/gethealth2.py new file mode 100755 index 0000000..31dd6f2 --- /dev/null +++ b/Workbench/scripts/gethealth2.py @@ -0,0 +1,25 @@ +#!/bin/python + +containers = ["idp", "idp_ui", "idp_ui_data", "idp_ui_api", "grouper_ui", "grouper_ws", "grouper_daemon", "grouper_data", "comanage", "comanage_cron", "comanage_data", "midpoint_server", "midpoint_data", "webproxy", "wordpress_server", "wordpress_data", "mq", "directory", "sources"] + +print("") +for container in containers: + from subprocess import Popen, PIPE + dcmd = "docker ps -f name=workbench-" + container + "-1 --format '{{ .Status }} '" + pipe = Popen(dcmd, shell=True, stdout=PIPE) + healthstatus = 'unknown' + for line in pipe.stdout: + print(str(line)) + if (b'(' in line): + healthstatus=line.strip() + if (b"healthy" in healthstatus): + healthstatus='' + str(healthstatus) + '' + elif ("unhealthy" in healthstatus): + healthstatus='' + str(healthstatus) + '' + else: + healthstatus='' + str(healthstatus) + '' + else: + healthstatus='unspecified' + + print("") +print("
ContainerHealth Status
" + container + "" + healthstatus + "
") diff --git a/Workbench/scripts/refresh-this-instance.sh b/Workbench/scripts/refresh-this-instance.sh new file mode 100755 index 0000000..fb84485 --- /dev/null +++ b/Workbench/scripts/refresh-this-instance.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +. /etc/profile + +DELETE_VOLUMES="false" + +if [[ $1 == "-dv" ]]; then + echo "will delete volumes..." + DELETE_VOLUMES="true" +fi + +function DisplayUsage() { +echo "** This script will bring down the workbench containers, " +echo "grab the latest workbench code and config from the main repo, " +echo "then restart the containers." +echo "" + echo "Usage:" + echo "$0 [-dv]" + echo "" + echo "Pass the -dv flag to also delete data volumes when refreshing this instance." + echo "" + exit 1 +} + +if [[ $1 == "--?" ]] | [[ $1 == "--help" ]]; then + DisplayUsage +fi +if [[ $# -eq 1 ]]; then + if [[ $1 != "-dv" ]]; then DisplayUsage; fi +fi + +pushd /csp-tap/InCommonTAP-Examples/Workbench +docker-compose down +if [[ $DELETE_VOLUMES == "true" ]]; then + echo "deleting volumes..." + docker volume rm $(docker volume ls -q) +fi +git pull +docker-compose up --build -d +popd diff --git a/Workbench/scripts/setupcron.sh b/Workbench/scripts/setupcron.sh new file mode 100755 index 0000000..afd1f5c --- /dev/null +++ b/Workbench/scripts/setupcron.sh @@ -0,0 +1,10 @@ +#!/bin/bash +CRONFILE=/csp-tap/InCommonTAP-Examples/Workbench/scripts/csp-cron + +#build crontab file +echo "#update CSP container status" > ${CRONFILE} +echo "*/3 * * * * /csp-tap/InCommonTAP-Examples/Workbench/scripts/update-health-status.sh" >> ${CRONFILE} +chmod 644 ${CRONFILE} + +#install crontab +crontab ${CRONFILE} diff --git a/Workbench/scripts/update-health-status.sh b/Workbench/scripts/update-health-status.sh new file mode 100755 index 0000000..c981f42 --- /dev/null +++ b/Workbench/scripts/update-health-status.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +/csp-tap/InCommonTAP-Examples/Workbench/scripts/gethealth.py > /csp-tap/InCommonTAP-Examples/Workbench/scripts/gethealth-output.txt + +docker cp /csp-tap/InCommonTAP-Examples/Workbench/scripts/gethealth-output.txt workbench_webproxy_1:/var/www/html/status/index.html \ No newline at end of file