read_conf(). Added more debug-output for several functions. Testing extract_changes files. to be continued.

This commit is contained in:
Gerhard Hoffmann 2022-06-05 12:31:06 +02:00
parent 38e0c402df
commit a05289ffb1

View File

@ -5,11 +5,13 @@ set -x
fifo="" fifo=""
customer_id="" customer_id=""
customer_repository="" customer_repository=""
customer_location=""
customer_base_dir=""
source ./log_helpers.sh source ./log_helpers.sh
source ./update_helpers.sh
source ./git_helpers.sh source ./git_helpers.sh
source ./opkg_helpers.sh source ./opkg_helpers.sh
source ./update_helpers.sh
init_fifo () { init_fifo () {
trap "rm -f $fifo" EXIT trap "rm -f $fifo" EXIT
@ -42,38 +44,64 @@ read_config() {
fi fi
fifo="${fifo_dir}/$fifo" fifo="${fifo_dir}/$fifo"
log_debug "$func: fifo is $fifo" log_debug "$func:${LINENO}: fifo is $fifo"
# check customer_id # check customer_id
customer_id="$(cat "$1" | jq -r .customer_id)" customer_id="$(cat "$1" | jq -r .customer_id)"
if [ -z "$customer_id" ]; then if [ -z "$customer_id" ]; then
log_fatal "$func: customer_id not set in $1" log_fatal "$func:${LINENO} customer_id not set in $1"
fi fi
customer_id="customer_$customer_id" customer_id="customer_$customer_id"
log_info "$func: customer-id is $customer_id" log_info "$func:${LINENO}: customer-id is $customer_id"
# check customer_repository # check customer_repository
repository_path="$(cat "$1" | jq -r .repository_path)" repository_path="$(cat "$1" | jq -r .repository_path)"
if [ -z "$repository_path" ]; then if [ -z "$repository_path" ]; then
log_fatal "$func: repository path not set in $1" log_fatal "$func:${LINENO}: repository path not set in $1"
fi fi
repository_path="${repository_path}/${customer_id}.git" repository_path="${repository_path}/${customer_id}.git"
log_info "$func: repository path is $repository_path" log_info "$func:${LINENO}: repository path is $repository_path"
# check zone_group
local zone_group="$(cat "$1" | jq -r .zone_group)"
if [ -z "$zone_group" ]; then
log_fatal "$func:${LINENO}: zone_group not set in $1"
fi
# check zone
local zone="$(cat "$1" | jq -r .zone)"
if [ -z "$zone" ]; then
log_fatal "$func:${LINENO}: zone not set in $1"
fi
# check customer_location
local customer_location="$(cat "$1" | jq -r .customer_location)"
if [ -z "$customer_location" ]; then
log_fatal "$func:${LINENO}: customer_location not set in $1"
fi
customer_base_dir="$PWD/workspace/${customer_id}/${customer_location}"
customer_base_dir="${customer_base_dir}/${zone_group}/${zone}"
log_info "$func:${LINENO}: customer-base-dir is $customer_base_dir"
return 0 return 0
} }
wait_for_trigger() { wait_for_trigger() {
local func="${FUNCNAME[0]}"
if [[ "$1" -eq -1 ]]; then if [[ "$1" -eq -1 ]]; then
# wait for external impulse # wait for external impulse
log_debug "$func:${LINENO}: waiting on $fifo"
if read line <$fifo; then if read line <$fifo; then
if [ "$line" = "quit" ] || [ "$line" = "update" ]; then if [ "$line" = "quit" ] || [ "$line" = "update" ]; then
echo "$line" log_debug "$func:${LINENO}: received=$line"
printf "%s\n" $line
fi fi
fi fi
else else
sleep $1 sleep $1
echo "sleep" log_debug "$func:${LINENO}: sleep"
fi fi
} }
@ -196,6 +224,7 @@ UpdateController() {
local try_lock_count=0 local try_lock_count=0
local try_unlock_count=0 local try_unlock_count=0
local trigger_timeout=-1 local trigger_timeout=-1
local func="${FUNCNAME[0]}"
# read config parameters # read config parameters
# read_config # read_config
@ -213,7 +242,7 @@ UpdateController() {
fi fi
if $trigger_reboot; then if $trigger_reboot; then
echo "CRITICAL send message to reboot the PSA" log_crit "$func:${LINENO}: send message to reboot the PSA"
send_reboot_message_to_system_controller send_reboot_message_to_system_controller
continue continue
fi fi
@ -227,10 +256,10 @@ UpdateController() {
if [[ "$check_apism_count" -eq 5 ]]; then if [[ "$check_apism_count" -eq 5 ]]; then
trigger_reboot=true trigger_reboot=true
check_apism_count=0 check_apism_count=0
echo "ERROR APISM not working" log_crit "$func:${LINENO}: ERROR APISM not working"
continue 2 continue 2
fi fi
echo "[$check_apism_count]: $(date +'%Y-%m-%d %T') check APISM" log_debug "$func:${LINENO}: [$check_apism_count]: check APISM"
sleep 60s sleep 60s
else else
# APISM up and working # APISM up and working
@ -239,16 +268,17 @@ UpdateController() {
fi fi
done done
echo "$(date +'%Y-%m-%d %T') checking for updates..." log_debug "$func:${LINENO}: checking for updates..."
# exit 1 # exit 1
# Are there new updates available ? # Are there new updates available ?
if ! check_for_updates; then if ! check_for_updates; then
echo "DEBUG no updates available" log_info "$func:${LINENO}: DEBUG no updates available"
extract_changed_files
continue continue
fi fi
echo "$(date +'%Y-%m-%d %T') fetching updates..." log_debug "$func:${LINENO}: fetching updates..."
exit 1 exit 1
# Fetch new updates (using git) # Fetch new updates (using git)