...
Code Block | ||
---|---|---|
| ||
#!/bin/bash GS3_BRANCH=${GS3_BRANCH:-"GEOD-GS0"} GS3_BUILD=${GS3_BUILD:-"latestSuccessful"} # Slack token for notifications SLACK_TOKEN=**Get from other script** SLACK_CHANNEL="isda-software" # change to folder where script is installed cd /home/clowder # fetch software if [[ ${GS3_BUILD} == latest* ]]; then BB="${GS3_BRANCH}/${GS3_BUILD}" else BB="${GS3_BRANCH}-${GS3_BUILD}" fi URL="https://opensource.ncsa.illinois.edu/bamboo/browse/${BB}/artifact/shared/dist/" /usr/bin/wget -q -e robots=off -A "geostreams-*.zip" -nd -r -N -l1 ${URL} LATEST=$( /bin/ls -1rt geostreams-*.zip | tail -1 ) if [ -s ${LATEST} ]; then if [ "$1" == "--force" -o ${LATEST} -nt geostreams ]; then exec 3>&1 exec &> "/tmp/$$.txt" echo "UPDATING GEOSTREAMING API v3 on ${HOSTNAME}" echo " bamboo branch = ${GS3_BRANCH}" echo " bamboo build = ${GS3_BUILD}" # stop geostreams /usr/sbin/service geostreams stop # Save local modifications if [ -d geo-temporal-api-v3/custom ]; then mv geo-temporal-api-v3/custom geo-temporal-api-v3.custom fi if [ -d geo-temporal-api-v3/logs ]; then mv geo-temporal-api-v3/logs geo-temporal-api-v3.logs fi # install new version /bin/rm -rf geo-temporal-api-v3 $( basename ${LATEST} .zip) /usr/bin/unzip -q ${LATEST} /bin/mv -v $( basename ${LATEST} .zip) geo-temporal-api-v3 /usr/bin/touch geo-temporal-api-v3 # restore local modifications if [ -d geo-temporal-api-v3.custom ]; then mv geo-temporal-api-v3.custom geo-temporal-api-v3/custom fi if [ -d geo-temporal-api-v3.logs ]; then mv geo-temporal-api-v3.logs geo-temporal-api-v3/logs fi if [ -f geo-temporal-api-v3/custom/messages.en ] &&[ -d geo-temporal-api-v3/conf ]; then /bin/cp -f geo-temporal-api-v3/custom/messages.en geo-temporal-api-v3/conf fi # change permissions /bin/chown -R clowder geo-temporal-api-v3 # start geostreams again /usr/sbin/service geostreams start # Send message to slack if [ "${SLACK_TOKEN}" != "" -a "${SLACK_CHANNEL}" != "" ]; then url="https://hooks.slack.com/services/${SLACK_TOKEN}" txt=$(cat /tmp/$$.txt | sed 's/"/\\"/g;s/$/\\/g' | tr '\n' 'n' ) payload="payload={\"channel\": \"${SLACK_CHANNEL}\", \"username\": \"geostreams\", \"text\": \"${txt}\", \"icon_url\": \"https://opensource.ncsa.illinois.edu/projects/artifacts/GEOD/logo.png\"}" result=$(curl -s -X POST --data-urlencode "${payload}" $url) fi if [ "${STDOUT}" != "" ]; then cat /tmp/$$.txt >&3 fi rm /tmp/$$.txt fi fi |
Note: You need to have inside /home/clowder/geo-temporal-api-v3 a custom folder with the application.conf file and the messages.en
There is a sample application.conf in seagrant-dev machine under Yan's username.