From 833c35390818f27a75591dbc40c274a7b233f50c Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Sun, 5 Jun 2022 07:23:50 +0200 Subject: [PATCH] Updated read_config () --- UpdateController.sh | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/UpdateController.sh b/UpdateController.sh index b81018e..da7eed0 100755 --- a/UpdateController.sh +++ b/UpdateController.sh @@ -1,7 +1,10 @@ #!/bin/bash set -x + fifo="" +customer_id="" +customer_repository="" source ./log_helpers.sh source ./git_helpers.sh @@ -25,17 +28,38 @@ init_fifo () { } read_config() { + local func="${FUNCNAME[0]}" + + # check fifo settings fifo_dir=$(cat "$1" | jq -r .fifo_dir) if [ -z "$fifo_dir" ]; then - return 1 + log_fatal "$func: fifo_dir not set in $1" fi fifo=$(cat "$1" | jq -r .fifo) if [ -z "$fifo" ]; then - return 1 + log_fatal "$func: fifo not set in $1" fi fifo="${fifo_dir}/$fifo" + log_debug "$func: fifo is $fifo" + + # check customer_id + customer_id="$(cat "$1" | jq -r .customer_id)" + if [ -z "$customer_id" ]; then + log_fatal "$func: customer_id not set in $1" + fi + customer_id="customer_$customer_id" + log_info "$func: customer-id is $customer_id" + + # check customer_repository + repository_path="$(cat "$1" | jq -r .repository_path)" + if [ -z "$repository_path" ]; then + log_fatal "$func: repository path not set in $1" + fi + repository_path="${repository_path}/${customer_id}.git" + log_info "$func: repository path is $repository_path" + return 0 } @@ -110,6 +134,9 @@ check_for_apism() { # check_for_updates() { # ismas_response=$(cat send_to_ismas.txt; sleep 1) | nc localhost 7778) + if ! pull_customer_repository customer_281; then + return 1 + fi return 0 } @@ -213,7 +240,7 @@ UpdateController() { done echo "$(date +'%Y-%m-%d %T') checking for updates..." - exit 1 + # exit 1 # Are there new updates available ? if ! check_for_updates; then