#!/bin/bash if test -z "${DEPLOYMENT}"; then echo Please provide DEPLOYMENT env var: 'test' or 'demo' exit 1 fi DOMAIN="taler.net" ## # Will stay as 'dummy' for 'demo' DEPLOYMENTs since we do # want to get this value ignored and the active deployment # to be checked. NONACTIVE_COLOR="notneeded" if test "test" = "${DEPLOYMENT}"; then NONACTIVE_COLOR="$(cat /home/test/nonactive)" fi error_stringify () { case $1 in 28) echo "connection timed out" ;; 7) echo "failed to connect to host" ;; 0) echo "successful" ;; *) echo "unknown, see curl man page" ;; esac } error_fmt="%s (http status code: %s)/(curl condition: %s - %s)\n" URL="https://exchange.${DEPLOYMENT}.${DOMAIN}/" http_status_code=$(curl \ -H "X-Taler-Deployment-Color: ${NONACTIVE_COLOR}" \ -s "$URL" -o /dev/null \ -w "%{http_code}") if ! test 200 = $http_status_code; then printf "'%s' failed\n" $URL printf "$error_fmt" \ "Exchange did not restart correctly" \ $http_status_code $? "$(error_stringify $?)" exit 1 fi URL="http://backend.${DEPLOYMENT}.${DOMAIN}/" http_status_code=$(curl \ -H "X-Taler-Deployment-Color: ${NONACTIVE_COLOR}" \ -s $URL \ --header "Authorization: ApiKey sandbox" \ -o /dev/null \ -w "%{http_code}") if ! test 200 = $http_status_code; then printf "'%s' failed\n" $URL printf "$error_fmt" \ "Merchant backend did not restart correctly" \ $http_status_code $? "$(error_stringify $?)" exit 1 fi URL="https://shop.${DEPLOYMENT}.${DOMAIN}/" http_status_code=$(curl \ -H "X-Taler-Deployment-Color: ${NONACTIVE_COLOR}" \ -s $URL -o /dev/null \ -w "%{http_code}") if ! test 200 = $http_status_code; then printf "%s failed\n" $URL printf "$error_fmt" \ "Blog did not restart correctly" \ $http_status_code $? "$(error_stringify $?)" exit 1 fi URL="https://survey.${DEPLOYMENT}.${DOMAIN}/" http_status_code=$(curl \ -H "X-Taler-Deployment-Color: ${NONACTIVE_COLOR}" \ -s $URL -o /dev/null \ -w "%{http_code}") if ! test 200 = $http_status_code; then printf "%s failed\n" $URL printf "$error_fmt" \ "Survey site did not restart correctly" \ $http_status_code $? "$(error_stringify $?)" exit 1 fi URL="https://donations.${DEPLOYMENT}.${DOMAIN}/" http_status_code=$(curl \ -H "X-Taler-Deployment-Color: ${NONACTIVE_COLOR}" \ -s $URL -o /dev/null \ -w "%{http_code}") if ! test 200 = $http_status_code; then printf "%s failed\n" $URL printf "$error_fmt" \ "Donations shop did not restart correctly" \ $http_status_code $? "$(error_stringify $?)" exit 1 fi URL="https://bank.${DEPLOYMENT}.${DOMAIN}/" http_status_code=$(curl \ -H "X-Taler-Deployment-Color: ${NONACTIVE_COLOR}" \ -s $URL -o /dev/null \ -w "%{http_code}") if ! test 302 = $http_status_code; then printf "%s failed\n" $URL printf "$error_fmt" \ "Bank did not restart correctly" \ $http_status_code $? "$(error_stringify $?)" exit 1 fi URL="https://${DEPLOYMENT}.${DOMAIN}/en/index.html" http_status_code=$(curl \ -H "X-Taler-Deployment-Color: ${NONACTIVE_COLOR}" \ -s $URL -o /dev/null \ -w "%{http_code}") if ! test 200 = $http_status_code; then printf "%s failed\n" $URL printf "$error_fmt" \ "Landing page not restart correctly" \ $http_status_code $? "$(error_stringify $?)" exit 1 fi if test "test" = ${DEPLOYMENT}; then URL="https://twister-backend.wild.gv.taler.net" http_status_code=$(curl \ -H "X-Taler-Deployment-Color: ${NONACTIVE_COLOR}" \ -s $URL -o /dev/null \ -w "%{http_code}") if ! test 200 = $http_status_code; then printf "%s failed\n" $URL printf "$error_fmt" \ "Twister did not restart correctly" $http_status_code $? "$(error_stringify $?)" exit 1 fi fi printf "All services correctly restarted!\n"