Compare commits
9 Commits
0ee446dcc0
...
0571498503
Author | SHA1 | Date | |
---|---|---|---|
0571498503 | |||
d8f36deca0 | |||
2158f65c65 | |||
1ee72f26af | |||
e2fc368371 | |||
d6131e04e9 | |||
98a2e09bd5 | |||
1939779f67 | |||
b9caeb2e3c |
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#! /bin/bash -
|
||||
# set -x
|
||||
|
||||
source ./log_helpers
|
||||
@ -34,12 +34,13 @@ if [ "${general_utils_sourced:-1}" = "1" ]; then # include only once
|
||||
local ps_pid=$! # remember pid of process substitution
|
||||
|
||||
local __result=""
|
||||
|
||||
while read __tmp <&$fd; do
|
||||
if ! [ -z "$__tmp" ]; then
|
||||
__result="${__result}$__tmp"
|
||||
__result+=" $__tmp"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
exec {fd}>&- # close fd (i.e. process substitution)
|
||||
wait $ps_pid # wait for the subshell to finish
|
||||
|
||||
@ -49,6 +50,7 @@ if [ "${general_utils_sourced:-1}" = "1" ]; then # include only once
|
||||
printf '%s' "$__result"
|
||||
return $__result_code
|
||||
}
|
||||
# exec_process_substitution 'opkg --noaction list'
|
||||
|
||||
usage () {
|
||||
echo "Usage: $PROGRAM [--file config] [--?] [--help] [--version] [--dbg]"
|
||||
|
@ -139,16 +139,17 @@ cd_home () {
|
||||
pull_customer_repository () {
|
||||
local func="${FUNCNAME[0]}"
|
||||
|
||||
if ! cd_customer_repository ; then
|
||||
if ! cd_customer_repository; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
local commit_before_pull=$(latest_commit)
|
||||
if [ -z $commit_before_pull ]; then
|
||||
log_warn "$func:${LINENO}: commit_before_pull empty"
|
||||
cd_home ; return 1
|
||||
fi
|
||||
|
||||
log_debug "$func:${LINENO}: commit_before_pull=$commit_before_pull"
|
||||
log_debug "$func:${LINENO}: executing 'git pull'..."
|
||||
|
||||
local git_result=$(exec_git_command 'git pull')
|
||||
|
||||
@ -256,12 +257,13 @@ changed_file_names () {
|
||||
log_debug "$func:${LINENO}: git_res=$git_res"
|
||||
local file_names=""
|
||||
for f in ${KNOWN_FILES[@]} ; do
|
||||
if grep -qE ".*\s+${f}\s+.*" <<< $git_res; then
|
||||
if grep -qE "${f}" <<< "$git_res"; then
|
||||
if ! [ -z $file_names ]; then
|
||||
file_names="$f $file_names"
|
||||
else
|
||||
file_names="$f"
|
||||
fi
|
||||
log_debug "$func:${LINENO}: $f found in $git_res"
|
||||
fi
|
||||
done
|
||||
|
||||
|
230
read_config
230
read_config
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#! /bin/bash -
|
||||
# set -x
|
||||
|
||||
source ./log_helpers
|
||||
@ -7,7 +7,8 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||
readonly read_config_sourced=${BASH_SOURCE[0]}
|
||||
|
||||
readonly DATEFLAGS="+%Y.%m.%dT%H.%M.%S"
|
||||
readonly STRIPCOMMENTS='sed -e s/#.*$//'
|
||||
readonly STRIPCOMMENTS='sed -e s/#.*$//g'
|
||||
readonly STRIPWHITESPACE='sed -E -e s/^[[:space:]]*$//g'
|
||||
readonly INDENT="awk '{ print \"\t\t\t\" \$0 }'"
|
||||
readonly JOINLINES="tr '\n' '\040'"
|
||||
|
||||
@ -21,22 +22,21 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||
|
||||
readonly WORKSPACE_DIR=workspace
|
||||
|
||||
${WORKING_DIRECTORY:=$UPDATEPSAHOME}
|
||||
${CONFIGFILENAME:=update_psa.conf}
|
||||
WORKING_DIRECTORY=${WORKING_DIRECTORY:-$UPDATEPSAHOME}
|
||||
CONFIGFILENAME=${CONFIGFILENAME:-'update_psa.conf'}
|
||||
|
||||
if ! [ -f "$CONFIGFILENAME" ]; then
|
||||
log_fatal "$func:${LINENO}: $CONFIGFILENAME not found"
|
||||
fi
|
||||
|
||||
if [ -z "$WORKING_DIRECTORY" ]; then
|
||||
log_fatal "$func:${LINENO}: WORKING_DIRECTORY not set in $cf"
|
||||
if ! [ -d "$WORKING_DIRECTORY" ]; then
|
||||
log_fatal "$func:${LINENO}: $WORKING_DIRECTORY not found"
|
||||
fi
|
||||
|
||||
EXITCODE=0
|
||||
CLONE_CUSTOMER_REPOSITORY=false
|
||||
|
||||
# read config file (JSON syntax)
|
||||
#
|
||||
read_config() {
|
||||
local func="${FUNCNAME[0]}"
|
||||
|
||||
@ -78,15 +78,24 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||
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 "$cf" | jq -r .zone_group[0])"
|
||||
log_debug "$func:${LINENO}: $number_of_zone_groups zone_group(s)"
|
||||
local __number_of_zone_groups=$(cat "$cf" |
|
||||
jq -r .zg[0] |
|
||||
sed -E -e 's/[[:space:]]*//g')
|
||||
# TODO: was ist hier falsch
|
||||
# __n_of_zgroups=$(echo "$__n_of_zgrps" | ${STRIPWHITESPACE} )
|
||||
log_debug "$func:${LINENO}: #n of zone_groups: $__number_of_zone_groups"
|
||||
|
||||
local __zone_groups=(0)
|
||||
for zg in `seq 1 $number_of_zone_groups`; do
|
||||
local __n_zones="$(cat "$cf" | jq -r .zone_group[$zg].zone[0])"
|
||||
local __zone_groups=($__number_of_zone_groups)
|
||||
for zg in `seq 1 $__number_of_zone_groups`; do
|
||||
local __n_zones=$(cat "$cf" |
|
||||
jq -r .zg[$zg].z |
|
||||
sed -E -e 's/[][,[:space:]]*//g') # rm ][ as well
|
||||
__zone_groups[$zg]=$__n_zones
|
||||
done
|
||||
|
||||
readonly ZONE_GROUPS=(${__zone_groups[@]})
|
||||
log_debug "$func:${LINENO}: ZONE_GROUPS=${ZONE_GROUPS[@]}"
|
||||
|
||||
log_debug "$func:${LINENO}: reading ${wd} done"
|
||||
|
||||
return 0
|
||||
@ -97,16 +106,14 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||
check_sanity_of_repository () {
|
||||
local func="${FUNCNAME[0]}"
|
||||
|
||||
local __customer_base_dir="$WORKING_DIRECTORY/${WORKSPACE_DIR}"
|
||||
__customer_base_dir="${__customer_base_dir}/${CUSTOMER_ID}"
|
||||
local __customer_id_base_dir="$WORKING_DIRECTORY/${WORKSPACE_DIR}"
|
||||
readonly CUSTOMER_ID_BASE_DIR="${__customer_id_base_dir}/${CUSTOMER_ID}"
|
||||
|
||||
readonly CUSTOMER_ID_BASE_DIR=${__customer_base_dir}
|
||||
log_debug "$func:${LINENO}: CUSTOMER_ID_BASE_DIR="
|
||||
log_debug "$func:${LINENO}: $CUSTOMER_ID_BASE_DIR"
|
||||
|
||||
__customer_base_dir="${__customer_base_dir}/${CUSTOMER_LOCATION}"
|
||||
CUSTOMER_LOCATION_DIR="${CUSTOMER_ID_BASE_DIR}/${CUSTOMER_LOCATION}"
|
||||
|
||||
readonly CUSTOMER_LOCATION_DIR="$__customer_base_dir"
|
||||
log_debug "$func:${LINENO}: CUSTOMER_LOCATION_DIR="
|
||||
log_debug "$func:${LINENO}: $CUSTOMER_LOCATION_DIR"
|
||||
|
||||
@ -114,27 +121,41 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||
log_debug "$func:${LINENO}: UPDATE.CONF="
|
||||
log_debug "$func:${LINENO}: $UPDATE_CONF"
|
||||
|
||||
readonly current_conf="${CUSTOMER_LOCATION_DIR}/current.conf"
|
||||
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
|
||||
# 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
|
||||
|
||||
# TODO: falls mehrere gruppen/zonen auftauchen hier anpassen
|
||||
readonly zgroup=1
|
||||
readonly zone=1
|
||||
readonly customer_base_dir="${__customer_base_dir}/${zgroup}/${zone}"
|
||||
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"
|
||||
readonly CUSTOMER_BASE_DIRS=(${__customer_base_dirs[@]})
|
||||
|
||||
if [ ${#CUSTOMER_BASE_DIRS[@]} -eq 0 ]; then
|
||||
log_fatal "$func:${LINENO}: CUSTOMER_BASE_DIRS empty"
|
||||
fi
|
||||
|
||||
readonly psa_config_dir="${customer_base_dir}/etc/psa_config"
|
||||
# TODO
|
||||
# TODO: falls mehrere gruppen/zonen auftauchen hier anpassen
|
||||
# TODO
|
||||
readonly local __zone=1
|
||||
readonly CUSTOMER_BASE_DIR="${CUSTOMER_BASE_DIRS[$__zone]}"
|
||||
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
|
||||
|
||||
readonly psa_config_dir="${CUSTOMER_BASE_DIR}/etc/psa_config"
|
||||
if [ -d "$psa_config_dir" ]; then
|
||||
log_debug "$func:${LINENO}: psa_config_dir="
|
||||
log_debug "$func:${LINENO}: $psa_config_dir"
|
||||
@ -142,7 +163,7 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||
log_fatal "$func:${LINENO}: $psa_config_dir does not exist"
|
||||
fi
|
||||
|
||||
readonly psa_update_dir="${customer_base_dir}/etc/psa_update"
|
||||
readonly psa_update_dir="${CUSTOMER_BASE_DIR}/etc/psa_update"
|
||||
if [ -d "$psa_update_dir" ]; then
|
||||
log_debug "$func:${LINENO}: psa_update_dir="
|
||||
log_debug "$func:${LINENO}: $psa_update_dir"
|
||||
@ -150,7 +171,7 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||
log_fatal "$func:${LINENO}: $psa_update_dir does not exist"
|
||||
fi
|
||||
|
||||
readonly psa_base_ini_dir="${customer_base_dir}/opt/app"
|
||||
readonly psa_base_ini_dir="${CUSTOMER_BASE_DIR}/opt/app"
|
||||
if [ -d "$psa_base_ini_dir" ]; then
|
||||
log_debug "$func:${LINENO}: psa_base_ini_dir="
|
||||
log_debug "$func:${LINENO}: $psa_base_ini_dir"
|
||||
@ -158,13 +179,14 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||
log_fatal "$func:${LINENO}: $psa_base_ini_dir does not exist"
|
||||
fi
|
||||
|
||||
readonly psa_sysconfig_dir="${psa_base_ini_dir}/sysconfig"
|
||||
readonly SYSCONFIG_SYS_DIR="/opt/app/sysconfig"
|
||||
readonly PSA_SYSCONFIG_DIR="$CUSTOMER_BASE_DIR$SYSCONFIG_SYS_DIR"
|
||||
# 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"
|
||||
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"
|
||||
log_error "$func:${LINENO}: $PSA_SYSCONFIG_DIR does not exist"
|
||||
fi
|
||||
|
||||
readonly psa_ismasmgr_dir="${psa_base_ini_dir}/ISMASMgr"
|
||||
@ -174,8 +196,12 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||
else
|
||||
log_fatal "$func:${LINENO}: $psa_ismasmgr_dir does not exist"
|
||||
fi
|
||||
|
||||
readonly CONF_SYS_DIR="/etc/psa_config"
|
||||
readonly OPKG_SYS_DIR="/etc/psa_update"
|
||||
readonly ATBAPP_SYS_DIR="/opt/app/ATBAPP"
|
||||
|
||||
readonly psa_atbqt_dir="${psa_base_ini_dir}/ATBAPP"
|
||||
readonly psa_atbqt_dir="$CUSTOMER_BASE_DIR$ATBAPP_SYS_DIR"
|
||||
if [ -d "$psa_atbqt_dir" ]; then
|
||||
log_debug "$func:${LINENO}: psa_atbqt_dir="
|
||||
log_debug "$func:${LINENO}: $psa_atbqt_dir"
|
||||
@ -183,70 +209,95 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||
log_fatal "$func:${LINENO}: $psa_atbqt_dir does not exist"
|
||||
fi
|
||||
|
||||
readonly atbqt_ini="${psa_atbqt_dir}/ATBQT.ini"
|
||||
if [ -f "$atbqt_ini" ]; then
|
||||
readonly ATBQT_INI="ATBQT.ini"
|
||||
readonly ATBQT_INI_FULL="${psa_atbqt_dir}/$ATBQT_INI"
|
||||
if [ -f "$ATBQT_INI_FULL" ]; then
|
||||
log_debug "$func:${LINENO}: ATBTQT.ini="
|
||||
log_debug "$func:${LINENO}: $atbqt_ini"
|
||||
log_debug "$func:${LINENO}: $ATBQT_INI_FULL"
|
||||
else
|
||||
log_fatal "$func:${LINENO}: $atbqt_ini does not exist"
|
||||
log_fatal "$func:${LINENO}: $ATBQT_INI_FULL does not exist"
|
||||
fi
|
||||
|
||||
readonly ISMASMGR_INI="ISMASMgr.ini"
|
||||
readonly ISMASMGR_SYS_DIR="/opt/app/ISMASMgr"
|
||||
|
||||
readonly ismasmgr_ismasmgr_ini="${psa_ismasmgr_dir}/ISMASMgr.ini"
|
||||
if [ -f "$ismasmgr_ismasmgr_ini" ]; then
|
||||
readonly ISMASMGR_ISMASMGR_INI_FULL="${psa_ismasmgr_dir}/$ISMASMGR_INI"
|
||||
if [ -f "$ISMASMGR_ISMASMGR_INI_FULL" ]; then
|
||||
log_debug "$func:${LINENO}: ismasmgr_ismasmgr.ini="
|
||||
log_debug "$func:${LINENO}: $ismasmgr_ismasmgr_ini"
|
||||
log_debug "$func:${LINENO}: $ISMASMGR_ISMASMGR_INI_FULL"
|
||||
else
|
||||
log_fatal "$func:${LINENO}: $ismasmgr_ismasmgr_ini does not exist"
|
||||
log_fatal "$func:${LINENO}: $ISMASMGR_ISMASMGR_INI_FULL "\
|
||||
"does not exist"
|
||||
fi
|
||||
|
||||
readonly sysconfig_ismasmgr_ini="${psa_sysconfig_dir}/ISMASMgr.ini"
|
||||
if [ -f "$sysconfig_ismasmgr_ini" ]; then
|
||||
readonly SYSCONFIG_ISMASMGR_INI_FULL="${PSA_SYSCONFIG_DIR}/ISMASMgr.ini"
|
||||
if [ -f "$SYSCONFIG_ISMASMGR_INI_FULL" ]; then
|
||||
log_debug "$func:${LINENO}: sysconfig_ismasmgr.ini="
|
||||
log_debug "$func:${LINENO}: $sysconfig_ismasmgr_ini"
|
||||
log_debug "$func:${LINENO}: $SYSCONFIG_ISMASMGR_INI_FULL"
|
||||
else
|
||||
log_fatal "$func:${LINENO}: $sysconfig_ismasmgr_ini does not exist"
|
||||
log_fatal "$func:${LINENO}: $SYSCONFIG_ISMASMGR_INI_FULL "\
|
||||
"does not exist"
|
||||
fi
|
||||
|
||||
readonly sysconfig_sysconfig_ini="${psa_sysconfig_dir}/sysconfig.ini"
|
||||
if [ -f "$sysconfig_sysconfig_ini" ]; then
|
||||
readonly SYS_CONFIG_INI="sysconfig.ini"
|
||||
readonly __sysc_sysc_full="${PSA_SYSCONFIG_DIR}/$SYS_CONFIG_INI"
|
||||
readonly SYSCONFIG_SYSCONFIG_INI_FULL="$__sysc_sysc_full"
|
||||
if [ -f "$SYSCONFIG_SYSCONFIG_INI_FULL" ]; then
|
||||
log_debug "$func:${LINENO}: sysconfig_sysconfig.ini="
|
||||
log_debug "$func:${LINENO}: $sysconfig_sysconfig_ini"
|
||||
log_debug "$func:${LINENO}: $SYSCONFIG_SYSCONFIG_INI_FULL"
|
||||
else
|
||||
log_fatal "$func:${LINENO}: $sysconfig_sysconfig_ini does not exist"
|
||||
log_fatal "$func:${LINENO}: "\
|
||||
"$SYSCONFIG_SYSCONFIG_INI_FULL does not exist"
|
||||
fi
|
||||
|
||||
readonly sysconfig_sysctrl_ini="${psa_sysconfig_dir}/SystemControl.ini"
|
||||
if [ -f "$sysconfig_sysctrl_ini" ]; then
|
||||
readonly "SYSTEM_CONTROL_INI"="SystemControl.ini"
|
||||
local __sysctrl_ini_full="${PSA_SYSCONFIG_DIR}/$SYSTEM_CONTROL_INI"
|
||||
readonly SYSCONFIG_SYSCTRL_INI_FULL="$__sysctrl_ini_full"
|
||||
if [ -f "$SYSCONFIG_SYSCTRL_INI_FULL" ]; then
|
||||
log_debug "$func:${LINENO}: sysconfig_systemcontrol.ini="
|
||||
log_debug "$func:${LINENO}: $sysconfig_sysctrl_ini"
|
||||
log_debug "$func:${LINENO}: $SYSCONFIG_SYSCTRL_INI_FULL"
|
||||
else
|
||||
log_fatal "$func:${LINENO}: $sysconfig_sysctrl_ini does not exist"
|
||||
log_fatal "$func:${LINENO}: $SYSCONFIG_SYSCTRL_INI_FULL 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"
|
||||
readonly DC2C_SERIAL_JSON="${psa_config_dir}/DC2C_serial.json"
|
||||
if [ -f "$DC2C_SERIAL_JSON" ]; then
|
||||
log_debug "$func:${LINENO}: DC2C_SERIAL_JSON="
|
||||
log_debug "$func:${LINENO}: $DC2C_SERIAL_JSON"
|
||||
else
|
||||
log_fatal "$func:${LINENO}: $emp_conf does not exist"
|
||||
log_fatal "$func:${LINENO}: $DC2C_SERIAL_JSON does not exist"
|
||||
fi
|
||||
|
||||
readonly device_conf="${psa_config_dir}/device.conf"
|
||||
if [ -f "$device_conf" ]; then
|
||||
log_debug "$func:${LINENO}: device.conf="
|
||||
log_debug "$func:${LINENO}: $device_conf"
|
||||
readonly DC2C_CASH_JSON="${psa_config_dir}/DC2C_cash.json"
|
||||
if [ -f "$DC2C_CASH_JSON" ]; then
|
||||
log_debug "$func:${LINENO}: DC2C_CASH_JSON="
|
||||
log_debug "$func:${LINENO}: $DC2C_CASH_JSON"
|
||||
else
|
||||
log_debug "$func:${LINENO}: $device_conf does not exist"
|
||||
log_debug "$func:${LINENO}: $DC2C_CASH_JSON does not exist"
|
||||
fi
|
||||
|
||||
readonly printer_conf="${psa_config_dir}/printer.conf"
|
||||
if [ -f "$printer_conf" ]; then
|
||||
log_debug "$func:${LINENO}: printer.conf="
|
||||
log_debug "$func:${LINENO}: $printer_conf"
|
||||
readonly DC2C_CONF_JSON="${psa_config_dir}/DC2C_conf.json"
|
||||
if [ -f "$DC2C_CONF_JSON" ]; then
|
||||
log_debug "$func:${LINENO}: DC2C_CONF_JSON="
|
||||
log_debug "$func:${LINENO}: $DC2C_CONF_JSON"
|
||||
else
|
||||
log_fatal "$func:${LINENO}: $printer_conf does not exist"
|
||||
log_fatal "$func:${LINENO}: $DC2C_CONF_JSON does not exist"
|
||||
fi
|
||||
|
||||
local DC2C_PRINT_JSON=()
|
||||
for i in {1..32}; do # up to 32 print-json-files
|
||||
local __f=${psa_config_dir}/DC2C_print$(printf "%02d" $i).json
|
||||
readonly DC2C_PRINT$(printf "%02d" $i)_JSON=$__f
|
||||
# local __g=$(eval echo '$'DC2C_PRINT$(printf "%02d" $i)_JSON)
|
||||
if [ -f $__f ]; then
|
||||
log_debug "$func:${LINENO}: DC2C_PRINT$(printf "%02d" $i)_JSON="
|
||||
log_debug "$func:${LINENO}: $__f"
|
||||
else
|
||||
log_fatal "$func:${LINENO}: $__f does not exist"
|
||||
fi
|
||||
DC2C_PRINT_JSON+=($__f)
|
||||
done
|
||||
|
||||
readonly opkg_cmds_file="${psa_update_dir}/opkg_commands"
|
||||
if [ -f "$opkg_cmds_file" ]; then
|
||||
log_debug "$func:${LINENO}: opkg_commands="
|
||||
@ -255,17 +306,18 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||
log_fatal "$func:${LINENO}: $opkg_cmds_file does not exist"
|
||||
fi
|
||||
|
||||
readonly KNOWN_CONF_FILES=(${CUSTOMER_LOCATION}/update.conf \
|
||||
${CUSTOMER_LOCATION}/current.conf \
|
||||
${device_conf##*${CUSTOMER_ID}/} \
|
||||
${emp_conf##*${CUSTOMER_ID}/} \
|
||||
${printer_conf##*${CUSTOMER_ID}/})
|
||||
# TODO: anpassen, da z.B. fuer szeged mehrere zonen vorhanden sind
|
||||
readonly KNOWN_CONF_FILES=(${CUSTOMER_LOCATION}/update.conf \
|
||||
${DC2C_PRINT_JSON[@]##*${CUSTOMER_ID}/} \
|
||||
${DC2C_CONF_JSON##*${CUSTOMER_ID}/} \
|
||||
${DC2C_CASH_JSON##*${CUSTOMER_ID}/} \
|
||||
${DC2C_SERIAL_JSON##*${CUSTOMER_ID}/})
|
||||
|
||||
readonly KNOWN_INI_FILES=(${atbqt_ini##*${CUSTOMER_ID}/} \
|
||||
${ismasmgr_ismasmgr_ini##*${CUSTOMER_ID}/} \
|
||||
${sysconfig_ismasmgr_ini##*${CUSTOMER_ID}/} \
|
||||
${sysconfig_sysconfig_ini##*${CUSTOMER_ID}/}\
|
||||
${sysconfig_sysctrl_ini##*${CUSTOMER_ID}/})
|
||||
readonly KNOWN_INI_FILES=(${ATBQT_INI_FULL##*${CUSTOMER_ID}/} \
|
||||
${ISMASMGR_ISMASMGR_INI_FULL##*${CUSTOMER_ID}/} \
|
||||
${SYSCONFIG_ISMASMGR_INI_FULL##*${CUSTOMER_ID}/} \
|
||||
${SYSCONFIG_SYSCONFIG_INI_FULL##*${CUSTOMER_ID}/} \
|
||||
${SYSCONFIG_SYSCTRL_INI_FULL##*${CUSTOMER_ID}/})
|
||||
|
||||
readonly KNOWN_FILES=(${KNOWN_CONF_FILES[@]} \
|
||||
${KNOWN_INI_FILES[@]} \
|
||||
@ -273,7 +325,8 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||
|
||||
log_debug "$func:${LINENO}: known conf/ini_files ->"
|
||||
for (( i=0; i < ${#KNOWN_FILES[@]}; ++i )); do
|
||||
log_debug "$func:${LINENO}: \t\t ${KNOWN_FILES[$i]}"
|
||||
tab=$'\t'
|
||||
log_debug "$func:${LINENO}: $tab$tab ${KNOWN_FILES[$i]}"
|
||||
done
|
||||
log_debug "$func:${LINENO}: sanity of ${CUSTOMER_REPOSITORY_PATH} OK"
|
||||
|
||||
@ -281,3 +334,4 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||
}
|
||||
fi
|
||||
|
||||
|
||||
|
10
update_psa
10
update_psa
@ -62,13 +62,13 @@ then
|
||||
if clone_customer_repository $CUSTOMER_REPOSITORY_PATH
|
||||
then
|
||||
check_sanity_of_repository
|
||||
|
||||
# set_updates_available
|
||||
# while :
|
||||
# do
|
||||
|
||||
#set_updates_available
|
||||
#while :
|
||||
#do
|
||||
# sleep 5
|
||||
# updates_available && break
|
||||
# done
|
||||
#done
|
||||
|
||||
update_psa
|
||||
fi
|
||||
|
@ -1,20 +1,20 @@
|
||||
{
|
||||
"c1" : "use git without certificates",
|
||||
"" : "use git without certificates",
|
||||
"GIT_SSL_NO_VERIFY" : 1,
|
||||
|
||||
"c4" : "explicit location of customer-project",
|
||||
"" : "explicit location of customer-project",
|
||||
"customer_location" : "szeged",
|
||||
|
||||
"c5" : "unique customer identifier",
|
||||
"" : "unique customer identifier",
|
||||
"customer_id" : "281",
|
||||
|
||||
"c6" : "each location can have multiple",
|
||||
"c7" : "zone-groups and/or zones",
|
||||
"c8" : "0-index used as size of following array",
|
||||
"c9" : ".zone_group[0]: #n of zones_groups",
|
||||
"c10" : ".zone_group[1].zone[0]: #n of zones in zg[1]",
|
||||
"zone_group" : [ 1, { "zone" : [ 1, "1"] } ],
|
||||
"" : "each location can have multiple",
|
||||
"" : "zone-groups and/or zones",
|
||||
"" : "0-index used as size of following array",
|
||||
"" : ".zg[0]: #n of zones_groups",
|
||||
"" : ".zg[1].z[0]: #n of zones in zg[1]",
|
||||
"zg" : [ 1, { "z" : [ 3, 1, 2, 3] } ],
|
||||
|
||||
"c11" : "url of customer repository",
|
||||
"" : "url of customer repository",
|
||||
"cust_repository_path" : "https://git.mimbach49.de/GerhardHoffmann"
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ exec_opkg_command () {
|
||||
# Fetch/merge updates from predefined repository using git.
|
||||
#
|
||||
fetch_customer_updates() {
|
||||
local func="${FUNCNAME[0]}"
|
||||
if ! pull_customer_repository $1; then
|
||||
return 1
|
||||
fi
|
||||
@ -37,8 +36,9 @@ copy () {
|
||||
|
||||
readarray -td' ' files <<< "$1"
|
||||
for f in ${files[@]}; do
|
||||
if [[ "$f" =~ .*update[.]conf.* ]] || [[ "$f" =~ .*current[.]conf.* ]]
|
||||
then
|
||||
log_debug "$func:${LINENO}: $f"
|
||||
# $f is determined by git
|
||||
if [[ "$f" =~ .*update[.]conf.* ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
@ -47,55 +47,72 @@ copy () {
|
||||
PERCENT=$((PERCENT+1))
|
||||
test $PERCENT -gt 100 && PERCENT=100
|
||||
|
||||
if grep -qE "^.*[.]conf\s*$" <<< ${f}; then
|
||||
local __f=${f#*etc/}
|
||||
local __msg="cp ${CUSTOMER_ID_BASE_DIR}/${f} to /etc/${__f}"
|
||||
if ! cp "${CUSTOMER_ID_BASE_DIR}/${f}" "/etc/${__f}"; then
|
||||
log_error "$func:${LINENO}: cannot $__msg"
|
||||
update_psa_copy_conf_ini_files $UPDATE_ISMAS_ERROR \
|
||||
$RC_COPY_ERROR "$__msg failed"
|
||||
return $?
|
||||
fi
|
||||
log_info "$func:${LINENO}: copied $f to /etc/${__f}"
|
||||
update_psa_copy_conf_ini $UPDATE_ISMAS_PROGRESS \
|
||||
$RC_SUCCESS "$__msg ok"
|
||||
|
||||
local __f=${f##*/}
|
||||
local __m=""
|
||||
local __copy_error=0
|
||||
|
||||
if grep -qE "^.*[.]json\s*$" <<< ${f}; then
|
||||
__m="cp ${CUSTOMER_ID_BASE_DIR}/${f} to ${CONF_SYS_DIR}/${__f}"
|
||||
cp "${CUSTOMER_ID_BASE_DIR}/${f}" "${CONF_SYS_DIR}/${__f}"
|
||||
__copy_error=$?
|
||||
elif grep -qE "^.*[.]ini\s*$" <<< ${f}; then
|
||||
# TODO: die anderen system-verzeichnisse werden gebraucht
|
||||
local __f=${f#*opt/app/ATBAPP/}
|
||||
local __msg="cp ${CUSTOMER_ID_BASE_DIR}/${f} /opt/app/ATBAPP/${__f}"
|
||||
if [ "$__f" = "ATBQT.ini" ]; then
|
||||
if ! cp "${CUSTOMER_ID_BASE_DIR}/${f}" /opt/app/ATBAPP/${__f}
|
||||
then
|
||||
log_error "$func:${LINENO}: cannot $__msg"
|
||||
update_psa_copy_conf_ini_files \
|
||||
$UPDATE_ISMAS_ERROR $RC_COPY_ERROR "$__msg failed"
|
||||
return $?
|
||||
if [ "$__f" = "$ATBQT_INI" ]; then
|
||||
__m="cp ${CUSTOMER_ID_BASE_DIR}/${f} $ATBAPP_SYS_DIR/${__f}"
|
||||
cp "${CUSTOMER_ID_BASE_DIR}/${f}" $ATBAPP_SYS_DIR/${__f}
|
||||
__copy_error=$?
|
||||
elif [ "$__f" = "$SYSTEM_CONTROL_INI" ]; then
|
||||
__m="cp ${CUSTOMER_ID_BASE_DIR}/${f} $SYSCONFIG_SYS_DIR/${__f}"
|
||||
cp "${CUSTOMER_ID_BASE_DIR}/${f}" $SYSCONFIG_SYS_DIR/${__f}
|
||||
__copy_error=$?
|
||||
elif [ "$__f" = "$SYS_CONFIG_INI" ]; then
|
||||
__m="cp ${CUSTOMER_ID_BASE_DIR}/${f} $SYSCONFIG_SYS_DIR/${__f}"
|
||||
cp "${CUSTOMER_ID_BASE_DIR}/${f}" $SYSCONFIG_SYS_DIR/${__f}
|
||||
__copy_error=$?
|
||||
elif [ "$__f" = "$ISMASMGR_INI" ]; then
|
||||
if grep -qE "$ISMASMGR_SYS_DIR" <<< "${f%/*}"; then
|
||||
__m="cp ${CUSTOMER_ID_BASE_DIR}/${f}"
|
||||
__m="$__m $ISMASMGR_SYS_DIR/${__f}"
|
||||
cp "${CUSTOMER_ID_BASE_DIR}/${f}" $ISMASMGR_SYS_DIR/${__f}
|
||||
__copy_error=$?
|
||||
else
|
||||
__m="cp ${CUSTOMER_ID_BASE_DIR}/${f}"
|
||||
__m="$__m $SYSCONFIG_SYS_DIR/${__f}"
|
||||
cp "${CUSTOMER_ID_BASE_DIR}/${f}" $SYSCONFIG_SYS_DIR/${__f}
|
||||
__copy_error=$?
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
log_info "$func:${LINENO}: $__msg"
|
||||
update_psa_copy_conf_ini $UPDATE_ISMAS_PROGRESS \
|
||||
$RC_SUCCESS "$__msg ok"
|
||||
if [ $__copy_error -ne 0 ]; then
|
||||
log_error "$func:${LINENO}: $__m failed"
|
||||
update_psa_copy_conf_and_ini_files \
|
||||
$UPDATE_ISMAS_ERROR $RC_COPY_ERROR "$__m failed"
|
||||
return $?
|
||||
else
|
||||
log_info "$func:${LINENO}: $__m ok"
|
||||
update_psa_copy_conf_and_ini_files $UPDATE_ISMAS_PROGRESS \
|
||||
$RC_SUCCESS "$__m ok"
|
||||
fi
|
||||
done
|
||||
|
||||
log_debug "$func:${LINENO}: copied *conf/*ini-files to system-dirs"
|
||||
|
||||
test $copy_necessary -eq 0 && \
|
||||
update_psa_copy_conf_ini $UPDATE_ISMAS_PROGRESS $RC_SUCCESS \
|
||||
"no copy of conf/ini-files necessary"
|
||||
|
||||
return 0;
|
||||
if [ $copy_necessary -eq 0 ]; then
|
||||
update_psa_copy_conf_and_ini_files $UPDATE_ISMAS_PROGRESS $RC_SUCCESS \
|
||||
"no copy of json/ini-files necessary"
|
||||
log_debug "$func:${LINENO}: no copy of conf/ini-files necessary"
|
||||
else
|
||||
log_debug "$func:${LINENO}: copied *conf/*ini-files to system-dirs"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
filter_conf_ini_files () {
|
||||
filter_json_ini_files () {
|
||||
local func="${FUNCNAME[0]}"
|
||||
log_debug "$func:${LINENO} $1"
|
||||
readarray -td' ' files <<< "$1"
|
||||
local __system_files=""
|
||||
for f in ${files[@]}; do
|
||||
if grep -qE "^.*[.](conf|ini)\s*$" <<< $f; then
|
||||
log_debug "$func:${LINENO} $f"
|
||||
if grep -qE "^.*[.](json|ini)\s*$" <<< $f; then
|
||||
if [ -z $__system_files ]; then
|
||||
__system_files="${f}"
|
||||
else
|
||||
@ -116,7 +133,7 @@ md5_of () {
|
||||
# Check if the fetched/merged files have the correct md5 and are
|
||||
# valid for the PSA.
|
||||
#
|
||||
check_md5_for_changed_conf_and_ini_files () {
|
||||
check_md5_for_changed_json_and_ini_files () {
|
||||
local func="${FUNCNAME[0]}"
|
||||
local js_key="" # used by json-parser 'jq'
|
||||
local md5sum_update_conf=""
|
||||
@ -127,38 +144,47 @@ check_md5_for_changed_conf_and_ini_files () {
|
||||
readarray -td' ' files <<< "$1"
|
||||
for file in ${files[@]}; do
|
||||
log_debug "$func:${LINENO} checking file=${file}..."
|
||||
if [[ "$file" =~ .*emp[.]conf.* ]]; then
|
||||
js_key=".conf.szeged.zg[1].z[1].etc.psa_config.emp"
|
||||
local __fsuffix=${file##*.}
|
||||
local __bn=$(basename $file .$__fsuffix)
|
||||
if [[ "$file" =~ .*cash[.]json.* ]]; then
|
||||
js_key=".conf.szeged.zg[1].z[1].etc.psa_config.$__bn"
|
||||
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
|
||||
md5sum_repository="$(md5_of $emp_conf)"
|
||||
elif [[ "$file" =~ .*printer[.]conf.* ]]; then
|
||||
js_key=".conf.szeged.zg[1].z[1].etc.psa_config.printer"
|
||||
md5sum_repository="$(md5_of $CUSTOMER_ID_BASE_DIR/$file)"
|
||||
elif [[ "$file" =~ .*print[0-9][0-9][.]json.* ]]; then
|
||||
js_key=".conf.szeged.zg[1].z[1].etc.psa_config.$__bn"
|
||||
|
||||
echo "$js_key"
|
||||
|
||||
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
|
||||
md5sum_repository="$(md5_of $printer_conf)"
|
||||
elif [[ "$file" =~ .*device[.]conf.* ]]; then
|
||||
js_key=".conf.szeged.zg[1].z[1].etc.psa_config.device"
|
||||
md5sum_repository="$(md5_of $CUSTOMER_ID_BASE_DIR/$file)"
|
||||
elif [[ "$file" =~ .*conf[.]json.* ]]; then
|
||||
js_key=".conf.szeged.zg[1].z[1].etc.psa_config.DC2C_conf"
|
||||
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
|
||||
md5sum_repository="$(md5_of $device_conf)"
|
||||
md5sum_repository="$(md5_of $CUSTOMER_ID_BASE_DIR/$file)"
|
||||
elif [[ "$file" =~ .*serial[.]json.* ]]; then
|
||||
js_key=".conf.szeged.zg[1].z[1].etc.psa_config.DC2C_serial"
|
||||
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
|
||||
md5sum_repository="$(md5_of $CUSTOMER_ID_BASE_DIR/$file)"
|
||||
elif [[ "$file" =~ .*ATBQT[.]ini.* ]]; then
|
||||
js_key=".ini.szeged.zg[1].z[1].opt.app.ATBAPP.ATBQT"
|
||||
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
|
||||
md5sum_repository="$(md5_of $atbqt_ini)"
|
||||
md5sum_repository="$(md5_of $ATBQT_INI_FULL)"
|
||||
elif [[ "$file" =~ .*sysconfig[.]ini.* ]]; then
|
||||
js_key=".ini.szeged.zg[1].z[1].opt.app.sysconfig.sysconfig"
|
||||
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
|
||||
md5sum_repository=$(md5_of $sysconfig_sysconfig_ini)
|
||||
md5sum_repository=$(md5_of $SYSCONFIG_SYSCONFIG_INI_FULL)
|
||||
elif [[ "$file" =~ .*SystemControl[.]ini.* ]]; then
|
||||
js_key=".ini.szeged.zg[1].z[1].opt.app.sysconfig.SystemControl"
|
||||
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
|
||||
md5sum_repository=$(md5_of $sysconfig_sysctrl_ini)
|
||||
md5sum_repository=$(md5_of $SYSCONFIG_SYSCTRL_INI_FULL)
|
||||
elif [[ "$file" =~ .*ISMASMgr/ISMASMgr[.]ini.* ]]; then
|
||||
js_key=".ini.szeged.zg[1].z[1].opt.app.ISMASMgr.ISMASMgr"
|
||||
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
|
||||
md5sum_repository=$(md5_of $ismasmgr_ismasmgr_ini)
|
||||
md5sum_repository=$(md5_of $ISMASMGR_ISMASMGR_INI_FULL)
|
||||
elif [[ "$file" =~ .*sysconfig/ISMASMgr[.]ini.* ]]; then
|
||||
js_key=".ini.szeged.zg[1].z[1].opt.app.sysconfig.ISMASMgr"
|
||||
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
|
||||
md5sum_repository=$(md5_of $sysconfig_ismasmgr_ini)
|
||||
md5sum_repository=$(md5_of $SYSCONFIG_ISMASMGR_INI_FULL)
|
||||
else
|
||||
continue
|
||||
fi
|
||||
@ -233,6 +259,7 @@ check_md5_for_opkg_packages () {
|
||||
#
|
||||
revert_customer_repository () {
|
||||
local func="${FUNCNAME[0]}"
|
||||
# TODO
|
||||
return 0
|
||||
}
|
||||
|
||||
@ -240,6 +267,7 @@ revert_customer_repository () {
|
||||
#
|
||||
backup_previous_version () {
|
||||
local func="${FUNCNAME[0]}"
|
||||
# TODO
|
||||
return 0
|
||||
}
|
||||
|
||||
@ -322,6 +350,7 @@ exec_opkg () {
|
||||
#
|
||||
fallback_to_previous_version() {
|
||||
local func="${FUNCNAME[0]}"
|
||||
# TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -329,15 +358,11 @@ fallback_to_previous_version() {
|
||||
#
|
||||
cleanup_previous_version() {
|
||||
local func="${FUNCNAME[0]}"
|
||||
# TODO
|
||||
return 0
|
||||
}
|
||||
|
||||
check_for_apism () {
|
||||
nc localhost 7778
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,26 @@ source ./read_config
|
||||
source ./news_to_ismas
|
||||
source ./news_from_ismas
|
||||
|
||||
trap collect_current_configuration EXIT
|
||||
|
||||
collect_current_configuration () {
|
||||
local func="${FUNCNAME[0]}"
|
||||
echo $func
|
||||
|
||||
return 0
|
||||
|
||||
for line in $(cat $UPDATE_CONF |\
|
||||
jq -r .conf.szeged.zg[1].z[1].etc.psa_config)
|
||||
do
|
||||
conf_file="$(echo $line |
|
||||
sed -E -ne 's/^[^{}]\s+\"(DC2C_[[:alnum:]]+)\".*$/\1/gp')"
|
||||
if ! [ -z $conf_file ]; then
|
||||
local v=$(cat "$psa_config_dir/${conf_file}.json" | jq -r .version)
|
||||
echo "$conf_file.json version=$v"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
update_psa() {
|
||||
|
||||
if ! updates_available; then # check for false alarm
|
||||
@ -67,28 +87,28 @@ update_psa() {
|
||||
# dateinen zu ueberpruefen
|
||||
|
||||
local changed_files=$(changed_file_names)
|
||||
local conf_ini_files=$(filter_conf_ini_files "$changed_files")
|
||||
local json_ini_files=$(filter_json_ini_files "$changed_files")
|
||||
|
||||
update_psa_report_changed_file_names $changed_files # message to ISMAS
|
||||
|
||||
# check if *.conf and/or *.ini-files have to md5-sum as denoted
|
||||
# in update.conf
|
||||
if ! check_md5_for_changed_conf_and_ini_files "$conf_ini_files" ; then
|
||||
if ! check_md5_for_changed_json_and_ini_files "$json_ini_files" ; then
|
||||
local __r=$?
|
||||
log_error "$func:${LINENO}: new customer files wrong"
|
||||
revert_customer_repository
|
||||
exit $__r
|
||||
fi
|
||||
|
||||
if ! check_hardware_compatibility "$conf_ini_files" ; then
|
||||
if ! check_hardware_compatibility "$json_ini_files" ; then
|
||||
local __r=$?
|
||||
log_error "$func:${LINENO}: conf/ini-files not fit for PSA"
|
||||
log_error "$func:${LINENO}: json/ini-files not fit for PSA"
|
||||
revert_customer_repository
|
||||
exit $__r
|
||||
fi
|
||||
|
||||
# copy *.conf and/or *.ini-files to their corresponding system-directories
|
||||
if ! copy $conf_ini_files; then
|
||||
if ! copy $json_ini_files; then
|
||||
local __r=$?
|
||||
log_error "$func:${LINENO}: copy operation failed"
|
||||
revert_customer_repository
|
||||
@ -147,6 +167,10 @@ update_psa() {
|
||||
if ! cleanup_previous_version; then
|
||||
log_error "$func:${LINENO}: cleanup_previous_version failed"
|
||||
fi
|
||||
|
||||
# TODO: nach (erfolgreichem) abschluss sollte man immer das aktuelle setting
|
||||
# ans ISMAS schicken. ISMAS sollte immer wissen, was gerade auf dem
|
||||
# Automaten steht.
|
||||
|
||||
update_psa_cleanup $UPDATE_ISMAS_PROGRESS \
|
||||
$RC_SUCCESS "cleanup after psa update"
|
||||
|
Loading…
x
Reference in New Issue
Block a user