Skip to content

Commit

Permalink
add back refresh/status scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
root authored and root committed Apr 17, 2024
1 parent 88f48a8 commit 8a4e08c
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Workbench/scripts/gethealth2.py
Original file line number Diff line number Diff line change
@@ -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("<table><tr><th style='text-align:left;width:150px'>Container</th><th style='text-align:left'>Health Status</th></tr>")
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 = '<font color="grey">unknown</font>'
for line in pipe.stdout:
print(str(line))
if (b'(' in line):
healthstatus=line.strip()
if (b"healthy" in healthstatus):
healthstatus='<font color="green">' + str(healthstatus) + '</font>'
elif ("unhealthy" in healthstatus):
healthstatus='<font color="red">' + str(healthstatus) + '</font>'
else:
healthstatus='<font color="blue">' + str(healthstatus) + '</font>'
else:
healthstatus='<font color="orange">unspecified</font>'

print("<tr><td>" + container + "</td><td>" + healthstatus + "</td></tr>")
print("</table>")
40 changes: 40 additions & 0 deletions Workbench/scripts/refresh-this-instance.sh
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions Workbench/scripts/setupcron.sh
Original file line number Diff line number Diff line change
@@ -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}
5 changes: 5 additions & 0 deletions Workbench/scripts/update-health-status.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8a4e08c

Please sign in to comment.