2022-06-03 20:49:33 +02:00
|
|
|
#!/bin/bash
|
|
|
|
# set -x
|
|
|
|
|
2022-06-04 18:14:16 +02:00
|
|
|
source ./log_helpers
|
2022-06-03 20:49:33 +02:00
|
|
|
|
2022-06-04 18:14:16 +02:00
|
|
|
if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
|
|
|
readonly read_config_sourced=${BASH_SOURCE[0]}
|
2022-06-03 20:49:33 +02:00
|
|
|
|
2022-06-04 18:14:16 +02:00
|
|
|
# read config file (JSON syntax)
|
|
|
|
#
|
|
|
|
read_config() {
|
|
|
|
local func="${FUNCNAME[0]}"
|
|
|
|
|
2022-06-05 21:54:08 +02:00
|
|
|
readonly GIT_SSL_NO_VERIFY="$(cat "$1" | jq -r .GIT_SSL_NO_VERIFY)"
|
|
|
|
if [ -z "$GIT_SSL_NO_VERIFY" ]; then
|
|
|
|
log_fatal "$func:${LINENO} GIT_SSL_NO_VERIFY not set in $1"
|
2022-06-04 18:14:16 +02:00
|
|
|
fi
|
2022-06-05 21:54:08 +02:00
|
|
|
log_debug "$func:${LINENO}: GIT_SSL_NO_VERIFY=$GIT_SSL_NO_VERIFY"
|
2022-06-04 18:14:16 +02:00
|
|
|
|
2022-06-05 21:54:08 +02:00
|
|
|
readonly working_directory="$(cat "$1" | jq -r .working_directory)"
|
|
|
|
if [ -z "$working_directory" ]; then
|
|
|
|
log_fatal "$func:${LINENO}: working_directory not set in $1"
|
2022-06-04 18:14:16 +02:00
|
|
|
fi
|
2022-06-05 21:54:08 +02:00
|
|
|
log_debug "$func:${LINENO}: working_directory=$working_directory"
|
2022-06-04 18:14:16 +02:00
|
|
|
|
2022-06-05 21:54:08 +02:00
|
|
|
readonly workspace_dir="$(cat "$1" | jq -r .workspace_dir)"
|
|
|
|
if [ -z "$workspace_dir" ]; then
|
|
|
|
log_fatal "$func:${LINENO}: workspace_dir not set in $1"
|
2022-06-04 18:14:16 +02:00
|
|
|
fi
|
2022-06-03 19:24:13 +02:00
|
|
|
log_debug "$func:${LINENO}: workspace_dir=$workspace_dir"
|
2022-06-04 18:14:16 +02:00
|
|
|
|
2022-06-02 22:25:57 +02:00
|
|
|
readonly customer_location=$(cat "$1" | jq -r .customer_location)
|
2022-06-04 18:14:16 +02:00
|
|
|
if [ -z "$customer_location" ]; then
|
|
|
|
log_fatal "$func:${LINENO}: customer_location not set in $1"
|
|
|
|
fi
|
2022-06-05 21:54:08 +02:00
|
|
|
log_debug "$func:${LINENO}: customer-location=$customer_location"
|
|
|
|
|
|
|
|
readonly customer_id="customer_$(cat "$1" | jq -r .customer_id)"
|
|
|
|
if [ -z "$customer_id" ]; then
|
|
|
|
log_fatal "$func:${LINENO} customer_id not set in $1"
|
|
|
|
fi
|
|
|
|
log_debug "$func:${LINENO}: customer-id=$customer_id"
|
2022-06-04 18:14:16 +02:00
|
|
|
|
2022-06-05 21:54:08 +02:00
|
|
|
local __r_path="$(cat "$1" | jq -r .cust_repository_path)"
|
|
|
|
if [ -z "$__r_path" ]; then
|
|
|
|
log_fatal "$func:${LINENO}: customer repository path not set in $1"
|
|
|
|
fi
|
|
|
|
readonly customer_repository_path="${__r_path}/${customer_id}.git"
|
|
|
|
log_debug "$func:${LINENO}: customer r-path=$customer_repository_path"
|
|
|
|
|
|
|
|
readonly number_of_zone_groups="$(cat "$1" | jq -r .zone_group[0])"
|
|
|
|
log_debug "$func:${LINENO}: $number_of_zone_groups zone_group(s)"
|
|
|
|
|
|
|
|
local __zone_groups=(0)
|
|
|
|
for zg in `seq 1 $number_of_zone_groups`; do
|
|
|
|
local __n_zones="$(cat "$1" | jq -r .zone_group[$zg].zone[0])"
|
|
|
|
__zone_groups[$zg]=$__n_zones
|
|
|
|
done
|
|
|
|
|
2022-06-02 22:25:57 +02:00
|
|
|
log_debug "$func:${LINENO}: reading ${1} done"
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
2022-06-05 21:54:08 +02:00
|
|
|
###############################################################################
|
|
|
|
########################## parsing with jq finished ###########################
|
|
|
|
###############################################################################
|
2022-06-02 22:25:57 +02:00
|
|
|
check_sanity_of_repository () {
|
|
|
|
local func="${FUNCNAME[0]}"
|
2022-06-03 20:49:33 +02:00
|
|
|
|
2022-06-04 18:14:16 +02:00
|
|
|
local __customer_base_dir="$working_directory/${workspace_dir}"
|
|
|
|
__customer_base_dir="${__customer_base_dir}/${customer_id}"
|
2022-06-03 19:24:13 +02:00
|
|
|
|
|
|
|
readonly customer_id_base_dir=${__customer_base_dir}
|
|
|
|
log_debug "$func:${LINENO}: customer_id_base_dir="
|
|
|
|
log_debug "$func:${LINENO}: $customer_id_base_dir"
|
|
|
|
|
2022-06-04 18:14:16 +02:00
|
|
|
__customer_base_dir="${__customer_base_dir}/${customer_location}"
|
2022-06-03 20:49:33 +02:00
|
|
|
|
2022-06-04 18:14:16 +02:00
|
|
|
readonly customer_location_dir="$__customer_base_dir"
|
2022-06-05 21:54:08 +02:00
|
|
|
log_debug "$func:${LINENO}: customer_location_dir="
|
|
|
|
log_debug "$func:${LINENO}: $customer_location_dir"
|
2022-06-04 21:29:23 +02:00
|
|
|
|
|
|
|
readonly update_conf="${customer_location_dir}/update.conf"
|
2022-06-05 21:54:08 +02:00
|
|
|
log_debug "$func:${LINENO}: update.conf="
|
|
|
|
log_debug "$func:${LINENO}: $update_conf"
|
2022-06-04 18:14:16 +02:00
|
|
|
|
2022-06-04 21:29:23 +02:00
|
|
|
readonly current_conf="${customer_location_dir}/current.conf"
|
2022-06-05 21:54:08 +02:00
|
|
|
log_debug "$func:${LINENO}: current.conf="
|
|
|
|
log_debug "$func:${LINENO}: $current_conf"
|
|
|
|
|
|
|
|
# readonly zone_groups=(${__zone_groups[@]})
|
|
|
|
# for (( j=0; j<${#zone_groups[@]}; ++j)); do
|
|
|
|
# log_debug "$func:${LINENO}: zgroup[$j]: ${zone_groups[$j]} zones"
|
|
|
|
# done
|
|
|
|
|
|
|
|
# TODO: falls mehrere gruppen/zonen auftauchen hier anpassen
|
|
|
|
readonly zgroup=1
|
|
|
|
readonly zone=1
|
|
|
|
readonly customer_base_dir="${__customer_base_dir}/${zgroup}/${zone}"
|
2022-06-02 22:25:57 +02:00
|
|
|
if [ -d "$customer_base_dir" ]; then
|
|
|
|
log_debug "$func:${LINENO}: customer-base-dir="
|
|
|
|
log_debug "$func:${LINENO}: $customer_base_dir"
|
|
|
|
else
|
|
|
|
log_fatal "$func:${LINENO}: $customer_base_dir does not exist"
|
|
|
|
fi
|
2022-06-05 21:54:08 +02:00
|
|
|
|
|
|
|
readonly psa_config_dir="${customer_base_dir}/etc/psa_config"
|
2022-06-02 22:25:57 +02:00
|
|
|
if [ -d "$psa_config_dir" ]; then
|
|
|
|
log_debug "$func:${LINENO}: psa_config_dir="
|
|
|
|
log_debug "$func:${LINENO}: $psa_config_dir"
|
|
|
|
else
|
|
|
|
log_fatal "$func:${LINENO}: $psa_config_dir does not exist"
|
|
|
|
fi
|
|
|
|
|
2022-06-05 21:54:08 +02:00
|
|
|
readonly psa_update_dir="${customer_base_dir}/etc/psa_update"
|
2022-06-02 22:25:57 +02:00
|
|
|
if [ -d "$psa_update_dir" ]; then
|
|
|
|
log_debug "$func:${LINENO}: psa_update_dir="
|
|
|
|
log_debug "$func:${LINENO}: $psa_update_dir"
|
|
|
|
else
|
|
|
|
log_fatal "$func:${LINENO}: $psa_update_dir does not exist"
|
|
|
|
fi
|
|
|
|
|
2022-06-05 21:54:08 +02:00
|
|
|
readonly psa_base_ini_dir="${customer_base_dir}/opt/app"
|
2022-06-02 22:25:57 +02:00
|
|
|
if [ -d "$psa_base_ini_dir" ]; then
|
|
|
|
log_debug "$func:${LINENO}: psa_base_ini_dir="
|
|
|
|
log_debug "$func:${LINENO}: $psa_base_ini_dir"
|
|
|
|
else
|
|
|
|
log_fatal "$func:${LINENO}: $psa_base_ini_dir does not exist"
|
|
|
|
fi
|
|
|
|
|
|
|
|
readonly psa_sysconfig_dir="${psa_base_ini_dir}/sysconfig"
|
|
|
|
# if [ -d "$psa_syconfig_dir" ]; DOES NOT WORK !!!
|
|
|
|
if ls -al $psa_sysconfig_dir > /dev/null; then
|
|
|
|
log_debug "$func:${LINENO}: psa_sysconfig_dir="
|
|
|
|
log_debug "$func:${LINENO}: $psa_sysconfig_dir"
|
|
|
|
else
|
|
|
|
log_error "$func:${LINENO}: $psa_sysconfig_dir does not exist"
|
|
|
|
fi
|
2022-06-03 20:49:33 +02:00
|
|
|
|
2022-06-02 22:25:57 +02:00
|
|
|
readonly psa_ismasmgr_dir="${psa_base_ini_dir}/ISMASMgr"
|
|
|
|
if [ -d "$psa_ismasmgr_dir" ]; then
|
|
|
|
log_debug "$func:${LINENO}: psa_ismasmgr_dir="
|
|
|
|
log_debug "$func:${LINENO}: $psa_ismasmgr_dir"
|
|
|
|
else
|
|
|
|
log_fatal "$func:${LINENO}: $psa_ismasmgr_dir does not exist"
|
|
|
|
fi
|
2022-06-04 18:14:16 +02:00
|
|
|
|
2022-06-03 19:03:08 +02:00
|
|
|
readonly psa_atbqt_dir="${psa_base_ini_dir}/ATBAPP"
|
2022-06-02 22:25:57 +02:00
|
|
|
if [ -d "$psa_atbqt_dir" ]; then
|
|
|
|
log_debug "$func:${LINENO}: psa_atbqt_dir="
|
|
|
|
log_debug "$func:${LINENO}: $psa_atbqt_dir"
|
|
|
|
else
|
|
|
|
log_fatal "$func:${LINENO}: $psa_atbqt_dir does not exist"
|
|
|
|
fi
|
|
|
|
|
|
|
|
readonly atbqt_ini="${psa_atbqt_dir}/ATBQT.ini"
|
|
|
|
if [ -f "$atbqt_ini" ]; then
|
|
|
|
log_debug "$func:${LINENO}: ATBTQT.ini="
|
|
|
|
log_debug "$func:${LINENO}: $atbqt_ini"
|
|
|
|
else
|
|
|
|
log_fatal "$func:${LINENO}: $atbqt_ini does not exist"
|
|
|
|
fi
|
|
|
|
|
|
|
|
readonly ismasmgr_ismasmgr_ini="${psa_ismasmgr_dir}/ISMASMgr.ini"
|
|
|
|
if [ -f "$ismasmgr_ismasmgr_ini" ]; then
|
|
|
|
log_debug "$func:${LINENO}: ismasmgr_ismasmgr.ini="
|
|
|
|
log_debug "$func:${LINENO}: $ismasmgr_ismasmgr_ini"
|
|
|
|
else
|
|
|
|
log_fatal "$func:${LINENO}: $ismasmgr_ismasmgr_ini does not exist"
|
|
|
|
fi
|
|
|
|
|
|
|
|
readonly sysconfig_ismasmgr_ini="${psa_sysconfig_dir}/ISMASMgr.ini"
|
|
|
|
if [ -f "$sysconfig_ismasmgr_ini" ]; then
|
|
|
|
log_debug "$func:${LINENO}: sysconfig_ismasmgr.ini="
|
|
|
|
log_debug "$func:${LINENO}: $sysconfig_ismasmgr_ini"
|
|
|
|
else
|
|
|
|
log_fatal "$func:${LINENO}: $sysconfig_ismasmgr_ini does not exist"
|
|
|
|
fi
|
|
|
|
|
|
|
|
readonly sysconfig_sysconfig_ini="${psa_sysconfig_dir}/sysconfig.ini"
|
|
|
|
if [ -f "$sysconfig_sysconfig_ini" ]; then
|
|
|
|
log_debug "$func:${LINENO}: sysconfig_sysconfig.ini="
|
|
|
|
log_debug "$func:${LINENO}: $sysconfig_sysconfig_ini"
|
|
|
|
else
|
|
|
|
log_fatal "$func:${LINENO}: $sysconfig_sysconfig_ini does not exist"
|
|
|
|
fi
|
|
|
|
|
|
|
|
readonly sysconfig_sysctrl_ini="${psa_sysconfig_dir}/SystemControl.ini"
|
|
|
|
if [ -f "$sysconfig_sysctrl_ini" ]; then
|
|
|
|
log_debug "$func:${LINENO}: sysconfig_systemcontrol.ini="
|
|
|
|
log_debug "$func:${LINENO}: $sysconfig_sysctrl_ini"
|
|
|
|
else
|
|
|
|
log_fatal "$func:${LINENO}: $sysconfig_sysctrl_ini does not exist"
|
|
|
|
fi
|
|
|
|
|
|
|
|
readonly emp_conf="${psa_config_dir}/emp.conf"
|
|
|
|
if [ -f "$emp_conf" ]; then
|
|
|
|
log_debug "$func:${LINENO}: emp.conf="
|
|
|
|
log_debug "$func:${LINENO}: $emp_conf"
|
|
|
|
else
|
|
|
|
log_fatal "$func:${LINENO}: $emp_conf does not exist"
|
|
|
|
fi
|
|
|
|
|
2022-06-05 21:54:08 +02:00
|
|
|
readonly device_conf="${psa_config_dir}/device.conf"
|
2022-06-02 22:25:57 +02:00
|
|
|
if [ -f "$device_conf" ]; then
|
|
|
|
log_debug "$func:${LINENO}: device.conf="
|
|
|
|
log_debug "$func:${LINENO}: $device_conf"
|
|
|
|
else
|
|
|
|
log_debug "$func:${LINENO}: $device_conf does not exist"
|
|
|
|
fi
|
2022-06-04 21:29:23 +02:00
|
|
|
|
2022-06-05 21:54:08 +02:00
|
|
|
readonly printer_conf="${psa_config_dir}/printer.conf"
|
2022-06-02 22:25:57 +02:00
|
|
|
if [ -f "$printer_conf" ]; then
|
|
|
|
log_debug "$func:${LINENO}: printer.conf="
|
|
|
|
log_debug "$func:${LINENO}: $printer_conf"
|
|
|
|
else
|
|
|
|
log_fatal "$func:${LINENO}: $printer_conf does not exist"
|
|
|
|
fi
|
2022-06-04 21:29:23 +02:00
|
|
|
|
2022-06-05 21:54:08 +02:00
|
|
|
readonly opkg_cmds_file="${psa_update_dir}/opkg_commands"
|
2022-06-02 22:25:57 +02:00
|
|
|
if [ -f "$opkg_cmds_file" ]; then
|
|
|
|
log_debug "$func:${LINENO}: opkg_commands="
|
|
|
|
log_debug "$func:${LINENO}: $opkg_cmds_file"
|
|
|
|
else
|
|
|
|
log_fatal "$func:${LINENO}: $opkg_cmds_file does not exist"
|
|
|
|
fi
|
|
|
|
|
2022-06-03 19:03:08 +02:00
|
|
|
readonly known_files=(${customer_location}/update.conf \
|
|
|
|
${customer_location}/current.conf \
|
|
|
|
${device_conf##*${customer_id}/} \
|
|
|
|
${emp_conf##*${customer_id}/} \
|
|
|
|
${printer_conf##*${customer_id}/} \
|
|
|
|
${opkg_cmds_file##*${customer_id}/} \
|
|
|
|
${atbqt_ini##*${customer_id}/} \
|
|
|
|
${ismasmgr_ismasmgr_ini##*${customer_id}/} \
|
|
|
|
${sysconfig_ismasmgr_ini##*${customer_id}/} \
|
|
|
|
${sysconfig_sysconfig_ini##*${customer_id}/} \
|
|
|
|
${sysconfig_sysctrl_ini##*${customer_id}/})
|
|
|
|
|
|
|
|
log_debug "$func:${LINENO}: conf/ini_files=$(echo ${known_files[@]})"
|
2022-06-02 22:25:57 +02:00
|
|
|
log_debug "$func:${LINENO}: sanity of ${customer_repository_path} OK"
|
2022-06-04 21:29:23 +02:00
|
|
|
|
2022-06-04 18:14:16 +02:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
# read_config UpdateController.conf
|
|
|
|
fi
|
2022-06-03 20:49:33 +02:00
|
|
|
|