#!/bin/bash active=$(sudo -u test cat /home/test/active) nonactive="blue" echo "Active party: ${active}" if test $active = "test-blue"; then nonactive="green" fi error_stringify () { case $1 in 28) echo "connection timed out" ;; 7) echo "failed to connect to host" ;; 0) echo "not a error, curl went fine" ;; *) echo "unknown, see curl man page" ;; esac } error_fmt="%s (http status code: %s)/(curl exit code: %s - %s)\n" http_status_code=$(curl \ -H "X-Taler-Deployment-Color: $nonactive" \ -s https://exchange.test.taler.net/ -o /dev/null \ -w "%{http_code}") if ! test 200 = $http_status_code; then printf "$error_fmt" \ "Exchange did not restart correctly" \ $http_status_code $? "$(error_stringify $?)" exit 1 fi http_status_code=$(curl \ -H "X-Taler-Deployment-Color: $nonactive" \ -s http://backend.test.taler.net/ \ --header "Authorization: ApiKey sandbox" \ -o /dev/null \ -w "%{http_code}") if ! test 200 = $http_status_code; then printf "$error_fmt" \ "Merchant backend did not restart correctly" \ $http_status_code $? "$(error_stringify $?)" exit 1 fi http_status_code=$(curl \ -H "X-Taler-Deployment-Color: $nonactive" \ -s https://shop.test.taler.net/ -o /dev/null \ -w "%{http_code}") if ! test 200 = $http_status_code; then printf "$error_fmt" \ "Blog did not restart correctly" \ $http_status_code $? "$(error_stringify $?)" exit 1 fi http_status_code=$(curl \ -H "X-Taler-Deployment-Color: $nonactive" \ -s https://donations.test.taler.net/ -o /dev/null \ -w "%{http_code}") if ! test 200 = $http_status_code; then printf "$error_fmt" \ "Donations shop did not restart correctly" \ $http_status_code $? "$(error_stringify $?)" exit 1 fi http_status_code=$(curl \ -H "X-Taler-Deployment-Color: $nonactive" \ -s https://bank.test.taler.net/ -o /dev/null \ -w "%{http_code}") if ! test 302 = $http_status_code; then printf "$error_fmt" \ "Bank did not restart correctly" \ $http_status_code $? "$(error_stringify $?)" exit 1 fi http_status_code=$(curl \ -H "X-Taler-Deployment-Color: $nonactive" \ -s https://test.taler.net/en/index.html -o /dev/null \ -w "%{http_code}") if ! test 200 = $http_status_code; then printf "$error_fmt" \ "Landing page not restart correctly" \ $http_status_code $? "$(error_stringify $?)" exit 1 fi