From 3a11eef33ee4df6c03183ea7b152e7b87fa4df02 Mon Sep 17 00:00:00 2001 From: alex_jov Date: Wed, 20 Jan 2021 12:28:19 +0100 Subject: [PATCH] Validations - add controller connection check; --- modules/validations/controller.sh | 19 ++++++++++++++++++- start.sh | 7 ++++++- 2 files changed, 24 insertions(+), 2 deletions(-) mode change 100644 => 100755 modules/validations/controller.sh diff --git a/modules/validations/controller.sh b/modules/validations/controller.sh old mode 100644 new mode 100755 index 019d919..a6731dd --- a/modules/validations/controller.sh +++ b/modules/validations/controller.sh @@ -1,3 +1,20 @@ #!/bin/bash -#todo \ No newline at end of file +source ./modules/common/http_check.sh # func_check_http_status + +_controller_url=${1} # hostname + /controller +_user_credentials=${2} # ${username}:${password} + +_proxy_details=${3} + +# Check if you can connect to a controler +echo "VAL|Checking connection to controller '${_controller_url}'..." + +# timeout after 10s +controllerReponse=$(curl -s --user ${_user_credentials} ${_controller_url}/rest/applications ${_proxy_details} --connect-timeout 10) + +if [ "$controllerReponse" = "" ]; then + func_check_http_status 404 "Unable to connect to controller: '"$_controller_url"'. Aborting..." +fi + +echo "VAL||Succesfully reached '${_controller_url}'." \ No newline at end of file diff --git a/start.sh b/start.sh index ed1ac15..58811d8 100755 --- a/start.sh +++ b/start.sh @@ -872,7 +872,12 @@ case $ec in esac ## 2. contrtoller connection -#todo +./modules/validations/controller.sh "$_arg_controller_url" "$_arg_user_credentials" "$_arg_proxy_details" ; ec=$? + +case $ec in + 0) ;; + 1) printf '%s\n' "Command exited with non-zero code"; exit 1;; +esac ## 3. application