Created
January 11, 2013 00:21
-
-
Save gourneau/4506949 to your computer and use it in GitHub Desktop.
Plugin to create PDF at the end of a run for Ion Torrent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| VERSION="0.1" | |
| #Set the URL for the API requests | |
| plugin_url=http://127.0.0.1/rundb/api/v1/results/${RUNINFO__PK}/plugin/ | |
| page_url=http://127.0.0.1/${RUNINFO__URL_ROOT}/ | |
| #Set the HTTP Headers | |
| api_header="Content-Type: application/json;Accept: application/json" | |
| #Count the number of plugins with status of "Started" | |
| running=`curl --silent \ | |
| --header ${api_header} \ | |
| --location ${plugin_url} | | |
| jsonpipe | | |
| grep pluginState/ | | |
| grep -v ${RUNINFO__PLUGIN_NAME} | | |
| awk '{print $2}'| | |
| grep "Started" | | |
| wc -l` | |
| #write out the json to rerun the plugin | |
| echo {\"plugin\":[\"${RUNINFO__PLUGIN_NAME}\"]} > post.json | |
| if [ "$running" -ne "0" ] | |
| then | |
| #if there are plugins still "started" then call this plugin again | |
| echo "There are still plugins running, calling this plugin again." | |
| #wait a few seconds first | |
| sleep 10 | |
| curl --silent --header ${api_header} \ | |
| --location ${plugin_url} \ | |
| --request POST \ | |
| --data "@post.json" | |
| else | |
| #All of the other plugins have finished -- do your final step here | |
| /opt/ion/iondb/bin/wkhtmltopdf-amd64 -q --javascript-delay 1000 --margin-top 15 --header-spacing 5 --header-right "Page [page] of [toPage]" --header-font-size 9 --disable-internal-links --disable-external-links ${page_url}?no_header=True report.pdf | |
| #now you have to do something with report.pdf, maybe scp it? Maybe email? | |
| echo "Done!" | |
| fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment