moved some code into read_config() to make sure proper initialization
This commit is contained in:
parent
326c6ea001
commit
8f07fbcf53
83
read_config
83
read_config
@ -25,7 +25,13 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||
readonly PROGRAM=`basename $0`
|
||||
readonly WORKSPACE_DIR=workspace
|
||||
|
||||
# TODO: entfernen indem man subtree benutzt
|
||||
EXITCODE=$RC_SUCCESS
|
||||
CLONE_CUSTOMER_REPOSITORY=false
|
||||
|
||||
# read config file (JSON syntax)
|
||||
read_config() {
|
||||
local func="${FUNCNAME[0]}"
|
||||
|
||||
WORKING_DIRECTORY=${WORKING_DIRECTORY:-$UPDATEPSAHOME}
|
||||
CONFIGFILENAME=${CONFIGFILENAME:-'update_psa.conf'}
|
||||
|
||||
@ -37,14 +43,6 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||
log_fatal "$func:${LINENO}: $WORKING_DIRECTORY not found"
|
||||
fi
|
||||
|
||||
EXITCODE=$RC_SUCCESS
|
||||
CLONE_CUSTOMER_REPOSITORY=false
|
||||
|
||||
|
||||
# read config file (JSON syntax)
|
||||
read_config() {
|
||||
local func="${FUNCNAME[0]}"
|
||||
|
||||
log_debug "$func:${LINENO}: CONFIGFILENAME=$CONFIGFILENAME"
|
||||
log_debug "$func:${LINENO}: WORKING_DIRECTORY=$WORKING_DIRECTORY"
|
||||
|
||||
@ -70,6 +68,9 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||
jq -r .cust_repository_path)"
|
||||
assert_s CUSTOMER_REPOSITORY_PATH
|
||||
|
||||
local __customer_id_base_dir="$WORKING_DIRECTORY/${WORKSPACE_DIR}"
|
||||
readonly CUSTOMER_ID_BASE_DIR="${__customer_id_base_dir}/${CUSTOMER_ID}"
|
||||
|
||||
local __number_of_zone_groups=$(cat "$cf" |
|
||||
jq -r .zg[0] |
|
||||
sed -E -e 's/[[:space:]]*//g')
|
||||
@ -94,50 +95,56 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||
########################## parsing with jq finished ###########################
|
||||
###############################################################################
|
||||
compute_hash () {
|
||||
# TODO: wie genau soll der hash-wert berechnet werden ?
|
||||
HASH="1234-abcd"
|
||||
# HASH_="67890def"
|
||||
echo $HASH
|
||||
if cd_customer_repository; then
|
||||
local hash=""
|
||||
if [[ -z $1 ]]; then
|
||||
hash=$(git log -n 1 --pretty=format:%H)
|
||||
else
|
||||
hash=$(git log -n 1 --pretty=format:%H -- $1)
|
||||
fi
|
||||
echo ${hash:0:10} # return the first 10 hex characters
|
||||
fi
|
||||
}
|
||||
|
||||
compute_version () {
|
||||
VERSION="$MAJOR.$MINOR.$PATCH+$CUSTOMER_LOCATION-$(compute_hash)"
|
||||
cd_home; return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
check_sanity_of_repository () {
|
||||
local func="${FUNCNAME[0]}"
|
||||
|
||||
local __customer_id_base_dir="$WORKING_DIRECTORY/${WORKSPACE_DIR}"
|
||||
readonly CUSTOMER_ID_BASE_DIR="${__customer_id_base_dir}/${CUSTOMER_ID}"
|
||||
assert_d CUSTOMER_ID_BASE_DIR
|
||||
|
||||
CUSTOMER_LOCATION_DIR="${CUSTOMER_ID_BASE_DIR}/${CUSTOMER_LOCATION}"
|
||||
CUST_LOC_DIR=$CUSTOMER_LOCATION_DIR
|
||||
CUSTOMER_LOCATION_DIR="$CUSTOMER_ID_BASE_DIR"
|
||||
#CUSTOMER_LOCATION_DIR="${CUSTOMER_ID_BASE_DIR}/${CUSTOMER_LOCATION}"
|
||||
#CUST_LOC_DIR=$CUSTOMER_LOCATION_DIR
|
||||
assert_d CUSTOMER_LOCATION_DIR
|
||||
|
||||
# readonly zone_groups=(${__zone_groups[@]})
|
||||
# by now (03.03.2023) there is only one zone group.
|
||||
readonly local __zgroup=1
|
||||
local __number_of_zone_groups=${ZONE_GROUPS[0]}
|
||||
local __zindex=1
|
||||
local __customer_base_dirs=("placeholder")
|
||||
for __zg in `seq 1 $__number_of_zone_groups`; do
|
||||
local __n_of_zones=${ZONE_GROUPS[$__zindex]}
|
||||
log_debug "$func:${LINENO}: zgroup $__zg has $__n_of_zones zones"
|
||||
for (( j=1; j<=$__n_of_zones; ++j)); do
|
||||
__customer_base_dirs+=("${CUSTOMER_LOCATION_DIR}/$__zgroup/$j")
|
||||
log_debug "$func:${LINENO}: zone $j"
|
||||
((++__zindex))
|
||||
done
|
||||
done
|
||||
#readonly local __zgroup=1
|
||||
#local __number_of_zone_groups=${ZONE_GROUPS[0]}
|
||||
#local __zindex=1
|
||||
#local __customer_base_dirs=("placeholder")
|
||||
#for __zg in `seq 1 $__number_of_zone_groups`; do
|
||||
# local __n_of_zones=${ZONE_GROUPS[$__zindex]}
|
||||
# log_debug "$func:${LINENO}: zgroup $__zg has $__n_of_zones zones"
|
||||
# for (( j=1; j<=$__n_of_zones; ++j)); do
|
||||
# __customer_base_dirs+=("${CUSTOMER_LOCATION_DIR}/$__zgroup/$j")
|
||||
# log_debug "$func:${LINENO}: zone $j"
|
||||
# ((++__zindex))
|
||||
# done
|
||||
#done
|
||||
|
||||
# for szeged:
|
||||
# placeholder
|
||||
# /home/root/szeged/UpdateController/workspace/customer_281/szeged/1/1
|
||||
# /home/root/szeged/UpdateController/workspace/customer_281/szeged/1/2
|
||||
# /home/root/szeged/UpdateController/workspace/customer_281/szeged/1/3
|
||||
readonly CUST_BASE_DIRS=(${__customer_base_dirs[@]})
|
||||
assert_a CUST_BASE_DIRS
|
||||
# readonly CUST_BASE_DIRS=(${__customer_base_dirs[@]})
|
||||
# assert_a CUST_BASE_DIRS
|
||||
|
||||
# TODO
|
||||
# TODO: falls mehrere gruppen/zonen auftauchen hier anpassen
|
||||
@ -146,8 +153,9 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||
#
|
||||
readonly ZONE_GROUP=1
|
||||
readonly ZONE=1
|
||||
readonly CUST_BASE_DIR="${CUST_BASE_DIRS[$ZONE]}"
|
||||
assert_d CUST_BASE_DIR
|
||||
readonly CUST_BASE_DIR="$CUSTOMER_ID_BASE_DIR"
|
||||
#readonly CUST_BASE_DIR="${CUST_BASE_DIRS[$ZONE]}"
|
||||
#assert_d CUST_BASE_DIR
|
||||
|
||||
readonly ETC_SYS_DIR="/etc"
|
||||
readonly ATB_SYS_DIR="/etc/atb"
|
||||
@ -224,7 +232,7 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||
readonly SYSCTRL_SCF_PSA_INI_FILE="${SYSCONFIG_PSA_DIR}/$SYSCTRL_INI"
|
||||
readonly OPKG_CMDS_PSA_FILE="${OPKG_PSA_DIR}/opkg_commands"
|
||||
readonly TC_PSA_TC_FILE="${ATBAPP_PSA_DIR}/$TARIFF_CURRENT"
|
||||
readonly PSA_UPDATE_CONF="${CUSTOMER_LOCATION_DIR}/update.conf"
|
||||
# readonly PSA_UPDATE_CONF="${CUSTOMER_LOCATION_DIR}/update.conf"
|
||||
readonly DC2C_PSA_SERIAL_JSON="${CONF_PSA_DIR}/DC2C_serial.json"
|
||||
readonly DC2C_PSA_CASH_JSON="${CONF_PSA_DIR}/DC2C_cash.json"
|
||||
readonly DC2C_PSA_CONF_JSON="${CONF_PSA_DIR}/DC2C_conf.json"
|
||||
@ -291,7 +299,7 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||
assert_f SYSCTRL_ATB_PSA_INI_FILE
|
||||
assert_f SYSCTRL_SCF_PSA_INI_FILE
|
||||
assert_f TC_PSA_TC_FILE
|
||||
assert_f PSA_UPDATE_CONF
|
||||
# assert_f PSA_UPDATE_CONF
|
||||
assert_f OPKG_CMDS_PSA_FILE
|
||||
assert_f DC2C_PSA_CONF_JSON
|
||||
assert_f DC2C_PSA_SERIAL_JSON
|
||||
@ -336,8 +344,7 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||
TARIFF_FILES_JSON+=($__f)
|
||||
done
|
||||
|
||||
readonly KNOWN_CONF_FILES=(${CUSTOMER_LOCATION}/update.conf \
|
||||
${DC2C_PRINT_JSON[@]##*${CUSTOMER_ID}/} \
|
||||
readonly KNOWN_CONF_FILES=(${DC2C_PRINT_JSON[@]##*${CUSTOMER_ID}/} \
|
||||
${DC2C_PSA_CONF_JSON##*${CUSTOMER_ID}/} \
|
||||
${DC2C_PSA_CASH_JSON##*${CUSTOMER_ID}/} \
|
||||
${DC2C_PSA_SERIAL_JSON##*${CUSTOMER_ID}/})
|
||||
|
Loading…
Reference in New Issue
Block a user