Updated read_config ()

This commit is contained in:
Gerhard Hoffmann 2022-06-05 07:23:50 +02:00
parent 55752bf667
commit 833c353908

View File

@ -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