Compare commits

..

No commits in common. "05714985030e5a37f2c440f24d045167a7105216" and "0ee446dcc0e398f6a638fbdda0c5a545cffdf481" have entirely different histories.

7 changed files with 172 additions and 279 deletions

View File

@ -1,4 +1,4 @@
#! /bin/bash - #!/bin/bash
# set -x # set -x
source ./log_helpers source ./log_helpers
@ -34,13 +34,12 @@ if [ "${general_utils_sourced:-1}" = "1" ]; then # include only once
local ps_pid=$! # remember pid of process substitution local ps_pid=$! # remember pid of process substitution
local __result="" local __result=""
while read __tmp <&$fd; do while read __tmp <&$fd; do
if ! [ -z "$__tmp" ]; then if ! [ -z "$__tmp" ]; then
__result+=" $__tmp" __result="${__result}$__tmp"
fi fi
done done
exec {fd}>&- # close fd (i.e. process substitution) exec {fd}>&- # close fd (i.e. process substitution)
wait $ps_pid # wait for the subshell to finish wait $ps_pid # wait for the subshell to finish
@ -50,7 +49,6 @@ if [ "${general_utils_sourced:-1}" = "1" ]; then # include only once
printf '%s' "$__result" printf '%s' "$__result"
return $__result_code return $__result_code
} }
# exec_process_substitution 'opkg --noaction list'
usage () { usage () {
echo "Usage: $PROGRAM [--file config] [--?] [--help] [--version] [--dbg]" echo "Usage: $PROGRAM [--file config] [--?] [--help] [--version] [--dbg]"

View File

@ -139,17 +139,16 @@ cd_home () {
pull_customer_repository () { pull_customer_repository () {
local func="${FUNCNAME[0]}" local func="${FUNCNAME[0]}"
if ! cd_customer_repository; then if ! cd_customer_repository ; then
return 1 return 1
fi fi
local commit_before_pull=$(latest_commit) local commit_before_pull=$(latest_commit)
if [ -z $commit_before_pull ]; then if [ -z $commit_before_pull ]; then
log_warn "$func:${LINENO}: commit_before_pull empty"
cd_home ; return 1 cd_home ; return 1
fi fi
log_debug "$func:${LINENO}: commit_before_pull=$commit_before_pull" 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') local git_result=$(exec_git_command 'git pull')
@ -257,13 +256,12 @@ changed_file_names () {
log_debug "$func:${LINENO}: git_res=$git_res" log_debug "$func:${LINENO}: git_res=$git_res"
local file_names="" local file_names=""
for f in ${KNOWN_FILES[@]} ; do for f in ${KNOWN_FILES[@]} ; do
if grep -qE "${f}" <<< "$git_res"; then if grep -qE ".*\s+${f}\s+.*" <<< $git_res; then
if ! [ -z $file_names ]; then if ! [ -z $file_names ]; then
file_names="$f $file_names" file_names="$f $file_names"
else else
file_names="$f" file_names="$f"
fi fi
log_debug "$func:${LINENO}: $f found in $git_res"
fi fi
done done

View File

@ -1,4 +1,4 @@
#! /bin/bash - #!/bin/bash
# set -x # set -x
source ./log_helpers source ./log_helpers
@ -7,8 +7,7 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
readonly read_config_sourced=${BASH_SOURCE[0]} readonly read_config_sourced=${BASH_SOURCE[0]}
readonly DATEFLAGS="+%Y.%m.%dT%H.%M.%S" readonly DATEFLAGS="+%Y.%m.%dT%H.%M.%S"
readonly STRIPCOMMENTS='sed -e s/#.*$//g' readonly STRIPCOMMENTS='sed -e s/#.*$//'
readonly STRIPWHITESPACE='sed -E -e s/^[[:space:]]*$//g'
readonly INDENT="awk '{ print \"\t\t\t\" \$0 }'" readonly INDENT="awk '{ print \"\t\t\t\" \$0 }'"
readonly JOINLINES="tr '\n' '\040'" readonly JOINLINES="tr '\n' '\040'"
@ -22,21 +21,22 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
readonly WORKSPACE_DIR=workspace readonly WORKSPACE_DIR=workspace
WORKING_DIRECTORY=${WORKING_DIRECTORY:-$UPDATEPSAHOME} ${WORKING_DIRECTORY:=$UPDATEPSAHOME}
CONFIGFILENAME=${CONFIGFILENAME:-'update_psa.conf'} ${CONFIGFILENAME:=update_psa.conf}
if ! [ -f "$CONFIGFILENAME" ]; then if ! [ -f "$CONFIGFILENAME" ]; then
log_fatal "$func:${LINENO}: $CONFIGFILENAME not found" log_fatal "$func:${LINENO}: $CONFIGFILENAME not found"
fi fi
if ! [ -d "$WORKING_DIRECTORY" ]; then if [ -z "$WORKING_DIRECTORY" ]; then
log_fatal "$func:${LINENO}: $WORKING_DIRECTORY not found" log_fatal "$func:${LINENO}: WORKING_DIRECTORY not set in $cf"
fi fi
EXITCODE=0 EXITCODE=0
CLONE_CUSTOMER_REPOSITORY=false CLONE_CUSTOMER_REPOSITORY=false
# read config file (JSON syntax) # read config file (JSON syntax)
#
read_config() { read_config() {
local func="${FUNCNAME[0]}" local func="${FUNCNAME[0]}"
@ -78,24 +78,15 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
readonly CUSTOMER_REPOSITORY_PATH="${__r_path}/${CUSTOMER_ID}.git" readonly CUSTOMER_REPOSITORY_PATH="${__r_path}/${CUSTOMER_ID}.git"
log_debug "$func:${LINENO}: customer-r-path=$CUSTOMER_REPOSITORY_PATH" log_debug "$func:${LINENO}: customer-r-path=$CUSTOMER_REPOSITORY_PATH"
local __number_of_zone_groups=$(cat "$cf" | readonly number_of_zone_groups="$(cat "$cf" | jq -r .zone_group[0])"
jq -r .zg[0] | log_debug "$func:${LINENO}: $number_of_zone_groups zone_group(s)"
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=($__number_of_zone_groups) local __zone_groups=(0)
for zg in `seq 1 $__number_of_zone_groups`; do for zg in `seq 1 $number_of_zone_groups`; do
local __n_zones=$(cat "$cf" | local __n_zones="$(cat "$cf" | jq -r .zone_group[$zg].zone[0])"
jq -r .zg[$zg].z |
sed -E -e 's/[][,[:space:]]*//g') # rm ][ as well
__zone_groups[$zg]=$__n_zones __zone_groups[$zg]=$__n_zones
done done
readonly ZONE_GROUPS=(${__zone_groups[@]})
log_debug "$func:${LINENO}: ZONE_GROUPS=${ZONE_GROUPS[@]}"
log_debug "$func:${LINENO}: reading ${wd} done" log_debug "$func:${LINENO}: reading ${wd} done"
return 0 return 0
@ -106,14 +97,16 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
check_sanity_of_repository () { check_sanity_of_repository () {
local func="${FUNCNAME[0]}" local func="${FUNCNAME[0]}"
local __customer_id_base_dir="$WORKING_DIRECTORY/${WORKSPACE_DIR}" local __customer_base_dir="$WORKING_DIRECTORY/${WORKSPACE_DIR}"
readonly CUSTOMER_ID_BASE_DIR="${__customer_id_base_dir}/${CUSTOMER_ID}" __customer_base_dir="${__customer_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="
log_debug "$func:${LINENO}: $CUSTOMER_ID_BASE_DIR" log_debug "$func:${LINENO}: $CUSTOMER_ID_BASE_DIR"
CUSTOMER_LOCATION_DIR="${CUSTOMER_ID_BASE_DIR}/${CUSTOMER_LOCATION}" __customer_base_dir="${__customer_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="
log_debug "$func:${LINENO}: $CUSTOMER_LOCATION_DIR" log_debug "$func:${LINENO}: $CUSTOMER_LOCATION_DIR"
@ -121,41 +114,27 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
log_debug "$func:${LINENO}: UPDATE.CONF=" log_debug "$func:${LINENO}: UPDATE.CONF="
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[@]}) # readonly zone_groups=(${__zone_groups[@]})
# by now (03.03.2023) there is only one zone group. # for (( j=0; j<${#zone_groups[@]}; ++j)); do
readonly local __zgroup=1 # log_debug "$func:${LINENO}: zgroup[$j]: ${zone_groups[$j]} zones"
local __number_of_zone_groups=${ZONE_GROUPS[0]} # done
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 CUSTOMER_BASE_DIRS=(${__customer_base_dirs[@]}) # TODO: falls mehrere gruppen/zonen auftauchen hier anpassen
readonly zgroup=1
if [ ${#CUSTOMER_BASE_DIRS[@]} -eq 0 ]; then readonly zone=1
log_fatal "$func:${LINENO}: CUSTOMER_BASE_DIRS empty" readonly customer_base_dir="${__customer_base_dir}/${zgroup}/${zone}"
fi if [ -d "$customer_base_dir" ]; then
log_debug "$func:${LINENO}: customer-base-dir="
# TODO log_debug "$func:${LINENO}: $customer_base_dir"
# 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 else
log_fatal "$func:${LINENO}: $CUSTOMER_BASE_DIR does not exist" log_fatal "$func:${LINENO}: $customer_base_dir does not exist"
fi fi
readonly psa_config_dir="${CUSTOMER_BASE_DIR}/etc/psa_config" readonly psa_config_dir="${customer_base_dir}/etc/psa_config"
if [ -d "$psa_config_dir" ]; then if [ -d "$psa_config_dir" ]; then
log_debug "$func:${LINENO}: psa_config_dir=" log_debug "$func:${LINENO}: psa_config_dir="
log_debug "$func:${LINENO}: $psa_config_dir" log_debug "$func:${LINENO}: $psa_config_dir"
@ -163,7 +142,7 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
log_fatal "$func:${LINENO}: $psa_config_dir does not exist" log_fatal "$func:${LINENO}: $psa_config_dir does not exist"
fi 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 if [ -d "$psa_update_dir" ]; then
log_debug "$func:${LINENO}: psa_update_dir=" log_debug "$func:${LINENO}: psa_update_dir="
log_debug "$func:${LINENO}: $psa_update_dir" log_debug "$func:${LINENO}: $psa_update_dir"
@ -171,7 +150,7 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
log_fatal "$func:${LINENO}: $psa_update_dir does not exist" log_fatal "$func:${LINENO}: $psa_update_dir does not exist"
fi 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 if [ -d "$psa_base_ini_dir" ]; then
log_debug "$func:${LINENO}: psa_base_ini_dir=" log_debug "$func:${LINENO}: psa_base_ini_dir="
log_debug "$func:${LINENO}: $psa_base_ini_dir" log_debug "$func:${LINENO}: $psa_base_ini_dir"
@ -179,14 +158,13 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
log_fatal "$func:${LINENO}: $psa_base_ini_dir does not exist" log_fatal "$func:${LINENO}: $psa_base_ini_dir does not exist"
fi fi
readonly SYSCONFIG_SYS_DIR="/opt/app/sysconfig" readonly psa_sysconfig_dir="${psa_base_ini_dir}/sysconfig"
readonly PSA_SYSCONFIG_DIR="$CUSTOMER_BASE_DIR$SYSCONFIG_SYS_DIR"
# if [ -d "$psa_syconfig_dir" ]; DOES NOT WORK !!! # if [ -d "$psa_syconfig_dir" ]; DOES NOT WORK !!!
if ls -al $PSA_SYSCONFIG_DIR > /dev/null; then if ls -al $psa_sysconfig_dir > /dev/null; then
log_debug "$func:${LINENO}: PSA_SYSCONFIG_DIR=" log_debug "$func:${LINENO}: psa_sysconfig_dir="
log_debug "$func:${LINENO}: $PSA_SYSCONFIG_DIR" log_debug "$func:${LINENO}: $psa_sysconfig_dir"
else else
log_error "$func:${LINENO}: $PSA_SYSCONFIG_DIR does not exist" log_error "$func:${LINENO}: $psa_sysconfig_dir does not exist"
fi fi
readonly psa_ismasmgr_dir="${psa_base_ini_dir}/ISMASMgr" readonly psa_ismasmgr_dir="${psa_base_ini_dir}/ISMASMgr"
@ -196,12 +174,8 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
else else
log_fatal "$func:${LINENO}: $psa_ismasmgr_dir does not exist" log_fatal "$func:${LINENO}: $psa_ismasmgr_dir does not exist"
fi 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="$CUSTOMER_BASE_DIR$ATBAPP_SYS_DIR" readonly psa_atbqt_dir="${psa_base_ini_dir}/ATBAPP"
if [ -d "$psa_atbqt_dir" ]; then if [ -d "$psa_atbqt_dir" ]; then
log_debug "$func:${LINENO}: psa_atbqt_dir=" log_debug "$func:${LINENO}: psa_atbqt_dir="
log_debug "$func:${LINENO}: $psa_atbqt_dir" log_debug "$func:${LINENO}: $psa_atbqt_dir"
@ -209,95 +183,70 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
log_fatal "$func:${LINENO}: $psa_atbqt_dir does not exist" log_fatal "$func:${LINENO}: $psa_atbqt_dir does not exist"
fi fi
readonly ATBQT_INI="ATBQT.ini" readonly atbqt_ini="${psa_atbqt_dir}/ATBQT.ini"
readonly ATBQT_INI_FULL="${psa_atbqt_dir}/$ATBQT_INI" if [ -f "$atbqt_ini" ]; then
if [ -f "$ATBQT_INI_FULL" ]; then
log_debug "$func:${LINENO}: ATBTQT.ini=" log_debug "$func:${LINENO}: ATBTQT.ini="
log_debug "$func:${LINENO}: $ATBQT_INI_FULL" log_debug "$func:${LINENO}: $atbqt_ini"
else else
log_fatal "$func:${LINENO}: $ATBQT_INI_FULL does not exist" log_fatal "$func:${LINENO}: $atbqt_ini does not exist"
fi fi
readonly ISMASMGR_INI="ISMASMgr.ini"
readonly ISMASMGR_SYS_DIR="/opt/app/ISMASMgr"
readonly ISMASMGR_ISMASMGR_INI_FULL="${psa_ismasmgr_dir}/$ISMASMGR_INI" readonly ismasmgr_ismasmgr_ini="${psa_ismasmgr_dir}/ISMASMgr.ini"
if [ -f "$ISMASMGR_ISMASMGR_INI_FULL" ]; then if [ -f "$ismasmgr_ismasmgr_ini" ]; then
log_debug "$func:${LINENO}: ismasmgr_ismasmgr.ini=" log_debug "$func:${LINENO}: ismasmgr_ismasmgr.ini="
log_debug "$func:${LINENO}: $ISMASMGR_ISMASMGR_INI_FULL" log_debug "$func:${LINENO}: $ismasmgr_ismasmgr_ini"
else else
log_fatal "$func:${LINENO}: $ISMASMGR_ISMASMGR_INI_FULL "\ log_fatal "$func:${LINENO}: $ismasmgr_ismasmgr_ini does not exist"
"does not exist"
fi fi
readonly SYSCONFIG_ISMASMGR_INI_FULL="${PSA_SYSCONFIG_DIR}/ISMASMgr.ini" readonly sysconfig_ismasmgr_ini="${psa_sysconfig_dir}/ISMASMgr.ini"
if [ -f "$SYSCONFIG_ISMASMGR_INI_FULL" ]; then if [ -f "$sysconfig_ismasmgr_ini" ]; then
log_debug "$func:${LINENO}: sysconfig_ismasmgr.ini=" log_debug "$func:${LINENO}: sysconfig_ismasmgr.ini="
log_debug "$func:${LINENO}: $SYSCONFIG_ISMASMGR_INI_FULL" log_debug "$func:${LINENO}: $sysconfig_ismasmgr_ini"
else else
log_fatal "$func:${LINENO}: $SYSCONFIG_ISMASMGR_INI_FULL "\ log_fatal "$func:${LINENO}: $sysconfig_ismasmgr_ini does not exist"
"does not exist"
fi fi
readonly SYS_CONFIG_INI="sysconfig.ini" readonly sysconfig_sysconfig_ini="${psa_sysconfig_dir}/sysconfig.ini"
readonly __sysc_sysc_full="${PSA_SYSCONFIG_DIR}/$SYS_CONFIG_INI" if [ -f "$sysconfig_sysconfig_ini" ]; then
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" log_debug "$func:${LINENO}: $sysconfig_sysconfig_ini"
else else
log_fatal "$func:${LINENO}: "\ log_fatal "$func:${LINENO}: $sysconfig_sysconfig_ini does not exist"
"$SYSCONFIG_SYSCONFIG_INI_FULL does not exist"
fi fi
readonly "SYSTEM_CONTROL_INI"="SystemControl.ini" readonly sysconfig_sysctrl_ini="${psa_sysconfig_dir}/SystemControl.ini"
local __sysctrl_ini_full="${PSA_SYSCONFIG_DIR}/$SYSTEM_CONTROL_INI" if [ -f "$sysconfig_sysctrl_ini" ]; then
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_systemcontrol.ini="
log_debug "$func:${LINENO}: $SYSCONFIG_SYSCTRL_INI_FULL" log_debug "$func:${LINENO}: $sysconfig_sysctrl_ini"
else else
log_fatal "$func:${LINENO}: $SYSCONFIG_SYSCTRL_INI_FULL does not exist" log_fatal "$func:${LINENO}: $sysconfig_sysctrl_ini does not exist"
fi fi
readonly DC2C_SERIAL_JSON="${psa_config_dir}/DC2C_serial.json" readonly emp_conf="${psa_config_dir}/emp.conf"
if [ -f "$DC2C_SERIAL_JSON" ]; then if [ -f "$emp_conf" ]; then
log_debug "$func:${LINENO}: DC2C_SERIAL_JSON=" log_debug "$func:${LINENO}: emp.conf="
log_debug "$func:${LINENO}: $DC2C_SERIAL_JSON" log_debug "$func:${LINENO}: $emp_conf"
else else
log_fatal "$func:${LINENO}: $DC2C_SERIAL_JSON does not exist" log_fatal "$func:${LINENO}: $emp_conf does not exist"
fi fi
readonly DC2C_CASH_JSON="${psa_config_dir}/DC2C_cash.json" readonly device_conf="${psa_config_dir}/device.conf"
if [ -f "$DC2C_CASH_JSON" ]; then if [ -f "$device_conf" ]; then
log_debug "$func:${LINENO}: DC2C_CASH_JSON=" log_debug "$func:${LINENO}: device.conf="
log_debug "$func:${LINENO}: $DC2C_CASH_JSON" log_debug "$func:${LINENO}: $device_conf"
else else
log_debug "$func:${LINENO}: $DC2C_CASH_JSON does not exist" log_debug "$func:${LINENO}: $device_conf does not exist"
fi fi
readonly DC2C_CONF_JSON="${psa_config_dir}/DC2C_conf.json" readonly printer_conf="${psa_config_dir}/printer.conf"
if [ -f "$DC2C_CONF_JSON" ]; then if [ -f "$printer_conf" ]; then
log_debug "$func:${LINENO}: DC2C_CONF_JSON=" log_debug "$func:${LINENO}: printer.conf="
log_debug "$func:${LINENO}: $DC2C_CONF_JSON" log_debug "$func:${LINENO}: $printer_conf"
else else
log_fatal "$func:${LINENO}: $DC2C_CONF_JSON does not exist" log_fatal "$func:${LINENO}: $printer_conf does not exist"
fi 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" readonly opkg_cmds_file="${psa_update_dir}/opkg_commands"
if [ -f "$opkg_cmds_file" ]; then if [ -f "$opkg_cmds_file" ]; then
log_debug "$func:${LINENO}: opkg_commands=" log_debug "$func:${LINENO}: opkg_commands="
@ -306,18 +255,17 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
log_fatal "$func:${LINENO}: $opkg_cmds_file does not exist" log_fatal "$func:${LINENO}: $opkg_cmds_file does not exist"
fi fi
# TODO: anpassen, da z.B. fuer szeged mehrere zonen vorhanden sind readonly KNOWN_CONF_FILES=(${CUSTOMER_LOCATION}/update.conf \
readonly KNOWN_CONF_FILES=(${CUSTOMER_LOCATION}/update.conf \ ${CUSTOMER_LOCATION}/current.conf \
${DC2C_PRINT_JSON[@]##*${CUSTOMER_ID}/} \ ${device_conf##*${CUSTOMER_ID}/} \
${DC2C_CONF_JSON##*${CUSTOMER_ID}/} \ ${emp_conf##*${CUSTOMER_ID}/} \
${DC2C_CASH_JSON##*${CUSTOMER_ID}/} \ ${printer_conf##*${CUSTOMER_ID}/})
${DC2C_SERIAL_JSON##*${CUSTOMER_ID}/})
readonly KNOWN_INI_FILES=(${ATBQT_INI_FULL##*${CUSTOMER_ID}/} \ readonly KNOWN_INI_FILES=(${atbqt_ini##*${CUSTOMER_ID}/} \
${ISMASMGR_ISMASMGR_INI_FULL##*${CUSTOMER_ID}/} \ ${ismasmgr_ismasmgr_ini##*${CUSTOMER_ID}/} \
${SYSCONFIG_ISMASMGR_INI_FULL##*${CUSTOMER_ID}/} \ ${sysconfig_ismasmgr_ini##*${CUSTOMER_ID}/} \
${SYSCONFIG_SYSCONFIG_INI_FULL##*${CUSTOMER_ID}/} \ ${sysconfig_sysconfig_ini##*${CUSTOMER_ID}/}\
${SYSCONFIG_SYSCTRL_INI_FULL##*${CUSTOMER_ID}/}) ${sysconfig_sysctrl_ini##*${CUSTOMER_ID}/})
readonly KNOWN_FILES=(${KNOWN_CONF_FILES[@]} \ readonly KNOWN_FILES=(${KNOWN_CONF_FILES[@]} \
${KNOWN_INI_FILES[@]} \ ${KNOWN_INI_FILES[@]} \
@ -325,8 +273,7 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
log_debug "$func:${LINENO}: known conf/ini_files ->" log_debug "$func:${LINENO}: known conf/ini_files ->"
for (( i=0; i < ${#KNOWN_FILES[@]}; ++i )); do for (( i=0; i < ${#KNOWN_FILES[@]}; ++i )); do
tab=$'\t' log_debug "$func:${LINENO}: \t\t ${KNOWN_FILES[$i]}"
log_debug "$func:${LINENO}: $tab$tab ${KNOWN_FILES[$i]}"
done done
log_debug "$func:${LINENO}: sanity of ${CUSTOMER_REPOSITORY_PATH} OK" log_debug "$func:${LINENO}: sanity of ${CUSTOMER_REPOSITORY_PATH} OK"
@ -334,4 +281,3 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
} }
fi fi

View File

@ -62,13 +62,13 @@ then
if clone_customer_repository $CUSTOMER_REPOSITORY_PATH if clone_customer_repository $CUSTOMER_REPOSITORY_PATH
then then
check_sanity_of_repository check_sanity_of_repository
#set_updates_available # set_updates_available
#while : # while :
#do # do
# sleep 5 # sleep 5
# updates_available && break # updates_available && break
#done # done
update_psa update_psa
fi fi

View File

@ -1,20 +1,20 @@
{ {
"" : "use git without certificates", "c1" : "use git without certificates",
"GIT_SSL_NO_VERIFY" : 1, "GIT_SSL_NO_VERIFY" : 1,
"" : "explicit location of customer-project", "c4" : "explicit location of customer-project",
"customer_location" : "szeged", "customer_location" : "szeged",
"" : "unique customer identifier", "c5" : "unique customer identifier",
"customer_id" : "281", "customer_id" : "281",
"" : "each location can have multiple", "c6" : "each location can have multiple",
"" : "zone-groups and/or zones", "c7" : "zone-groups and/or zones",
"" : "0-index used as size of following array", "c8" : "0-index used as size of following array",
"" : ".zg[0]: #n of zones_groups", "c9" : ".zone_group[0]: #n of zones_groups",
"" : ".zg[1].z[0]: #n of zones in zg[1]", "c10" : ".zone_group[1].zone[0]: #n of zones in zg[1]",
"zg" : [ 1, { "z" : [ 3, 1, 2, 3] } ], "zone_group" : [ 1, { "zone" : [ 1, "1"] } ],
"" : "url of customer repository", "c11" : "url of customer repository",
"cust_repository_path" : "https://git.mimbach49.de/GerhardHoffmann" "cust_repository_path" : "https://git.mimbach49.de/GerhardHoffmann"
} }

View File

@ -24,6 +24,7 @@ exec_opkg_command () {
# Fetch/merge updates from predefined repository using git. # Fetch/merge updates from predefined repository using git.
# #
fetch_customer_updates() { fetch_customer_updates() {
local func="${FUNCNAME[0]}"
if ! pull_customer_repository $1; then if ! pull_customer_repository $1; then
return 1 return 1
fi fi
@ -36,9 +37,8 @@ copy () {
readarray -td' ' files <<< "$1" readarray -td' ' files <<< "$1"
for f in ${files[@]}; do for f in ${files[@]}; do
log_debug "$func:${LINENO}: $f" if [[ "$f" =~ .*update[.]conf.* ]] || [[ "$f" =~ .*current[.]conf.* ]]
# $f is determined by git then
if [[ "$f" =~ .*update[.]conf.* ]]; then
continue continue
fi fi
@ -47,72 +47,55 @@ copy () {
PERCENT=$((PERCENT+1)) PERCENT=$((PERCENT+1))
test $PERCENT -gt 100 && PERCENT=100 test $PERCENT -gt 100 && PERCENT=100
local __f=${f##*/} if grep -qE "^.*[.]conf\s*$" <<< ${f}; then
local __m="" local __f=${f#*etc/}
local __copy_error=0 local __msg="cp ${CUSTOMER_ID_BASE_DIR}/${f} to /etc/${__f}"
if ! cp "${CUSTOMER_ID_BASE_DIR}/${f}" "/etc/${__f}"; then
if grep -qE "^.*[.]json\s*$" <<< ${f}; then log_error "$func:${LINENO}: cannot $__msg"
__m="cp ${CUSTOMER_ID_BASE_DIR}/${f} to ${CONF_SYS_DIR}/${__f}" update_psa_copy_conf_ini_files $UPDATE_ISMAS_ERROR \
cp "${CUSTOMER_ID_BASE_DIR}/${f}" "${CONF_SYS_DIR}/${__f}" $RC_COPY_ERROR "$__msg failed"
__copy_error=$? return $?
fi
log_info "$func:${LINENO}: copied $f to /etc/${__f}"
update_psa_copy_conf_ini $UPDATE_ISMAS_PROGRESS \
$RC_SUCCESS "$__msg ok"
elif grep -qE "^.*[.]ini\s*$" <<< ${f}; then elif grep -qE "^.*[.]ini\s*$" <<< ${f}; then
if [ "$__f" = "$ATBQT_INI" ]; then # TODO: die anderen system-verzeichnisse werden gebraucht
__m="cp ${CUSTOMER_ID_BASE_DIR}/${f} $ATBAPP_SYS_DIR/${__f}" local __f=${f#*opt/app/ATBAPP/}
cp "${CUSTOMER_ID_BASE_DIR}/${f}" $ATBAPP_SYS_DIR/${__f} local __msg="cp ${CUSTOMER_ID_BASE_DIR}/${f} /opt/app/ATBAPP/${__f}"
__copy_error=$? if [ "$__f" = "ATBQT.ini" ]; then
elif [ "$__f" = "$SYSTEM_CONTROL_INI" ]; then if ! cp "${CUSTOMER_ID_BASE_DIR}/${f}" /opt/app/ATBAPP/${__f}
__m="cp ${CUSTOMER_ID_BASE_DIR}/${f} $SYSCONFIG_SYS_DIR/${__f}" then
cp "${CUSTOMER_ID_BASE_DIR}/${f}" $SYSCONFIG_SYS_DIR/${__f} log_error "$func:${LINENO}: cannot $__msg"
__copy_error=$? update_psa_copy_conf_ini_files \
elif [ "$__f" = "$SYS_CONFIG_INI" ]; then $UPDATE_ISMAS_ERROR $RC_COPY_ERROR "$__msg failed"
__m="cp ${CUSTOMER_ID_BASE_DIR}/${f} $SYSCONFIG_SYS_DIR/${__f}" return $?
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 fi
fi
if [ $__copy_error -ne 0 ]; then log_info "$func:${LINENO}: $__msg"
log_error "$func:${LINENO}: $__m failed" update_psa_copy_conf_ini $UPDATE_ISMAS_PROGRESS \
update_psa_copy_conf_and_ini_files \ $RC_SUCCESS "$__msg ok"
$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 fi
done done
if [ $copy_necessary -eq 0 ]; then log_debug "$func:${LINENO}: copied *conf/*ini-files to system-dirs"
update_psa_copy_conf_and_ini_files $UPDATE_ISMAS_PROGRESS $RC_SUCCESS \
"no copy of json/ini-files necessary" test $copy_necessary -eq 0 && \
log_debug "$func:${LINENO}: no copy of conf/ini-files necessary" update_psa_copy_conf_ini $UPDATE_ISMAS_PROGRESS $RC_SUCCESS \
else "no copy of conf/ini-files necessary"
log_debug "$func:${LINENO}: copied *conf/*ini-files to system-dirs"
fi return 0;
return 0
} }
filter_json_ini_files () { filter_conf_ini_files () {
local func="${FUNCNAME[0]}" local func="${FUNCNAME[0]}"
log_debug "$func:${LINENO} $1" log_debug "$func:${LINENO} $1"
readarray -td' ' files <<< "$1" readarray -td' ' files <<< "$1"
local __system_files="" local __system_files=""
for f in ${files[@]}; do for f in ${files[@]}; do
log_debug "$func:${LINENO} $f" if grep -qE "^.*[.](conf|ini)\s*$" <<< $f; then
if grep -qE "^.*[.](json|ini)\s*$" <<< $f; then
if [ -z $__system_files ]; then if [ -z $__system_files ]; then
__system_files="${f}" __system_files="${f}"
else else
@ -133,7 +116,7 @@ md5_of () {
# Check if the fetched/merged files have the correct md5 and are # Check if the fetched/merged files have the correct md5 and are
# valid for the PSA. # valid for the PSA.
# #
check_md5_for_changed_json_and_ini_files () { check_md5_for_changed_conf_and_ini_files () {
local func="${FUNCNAME[0]}" local func="${FUNCNAME[0]}"
local js_key="" # used by json-parser 'jq' local js_key="" # used by json-parser 'jq'
local md5sum_update_conf="" local md5sum_update_conf=""
@ -144,47 +127,38 @@ check_md5_for_changed_json_and_ini_files () {
readarray -td' ' files <<< "$1" readarray -td' ' files <<< "$1"
for file in ${files[@]}; do for file in ${files[@]}; do
log_debug "$func:${LINENO} checking file=${file}..." log_debug "$func:${LINENO} checking file=${file}..."
local __fsuffix=${file##*.} if [[ "$file" =~ .*emp[.]conf.* ]]; then
local __bn=$(basename $file .$__fsuffix) js_key=".conf.szeged.zg[1].z[1].etc.psa_config.emp"
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_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
md5sum_repository="$(md5_of $CUSTOMER_ID_BASE_DIR/$file)" md5sum_repository="$(md5_of $emp_conf)"
elif [[ "$file" =~ .*print[0-9][0-9][.]json.* ]]; then elif [[ "$file" =~ .*printer[.]conf.* ]]; then
js_key=".conf.szeged.zg[1].z[1].etc.psa_config.$__bn" js_key=".conf.szeged.zg[1].z[1].etc.psa_config.printer"
echo "$js_key"
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key) md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
md5sum_repository="$(md5_of $CUSTOMER_ID_BASE_DIR/$file)" md5sum_repository="$(md5_of $printer_conf)"
elif [[ "$file" =~ .*conf[.]json.* ]]; then elif [[ "$file" =~ .*device[.]conf.* ]]; then
js_key=".conf.szeged.zg[1].z[1].etc.psa_config.DC2C_conf" js_key=".conf.szeged.zg[1].z[1].etc.psa_config.device"
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key) md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
md5sum_repository="$(md5_of $CUSTOMER_ID_BASE_DIR/$file)" md5sum_repository="$(md5_of $device_conf)"
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 elif [[ "$file" =~ .*ATBQT[.]ini.* ]]; then
js_key=".ini.szeged.zg[1].z[1].opt.app.ATBAPP.ATBQT" js_key=".ini.szeged.zg[1].z[1].opt.app.ATBAPP.ATBQT"
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key) md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
md5sum_repository="$(md5_of $ATBQT_INI_FULL)" md5sum_repository="$(md5_of $atbqt_ini)"
elif [[ "$file" =~ .*sysconfig[.]ini.* ]]; then elif [[ "$file" =~ .*sysconfig[.]ini.* ]]; then
js_key=".ini.szeged.zg[1].z[1].opt.app.sysconfig.sysconfig" js_key=".ini.szeged.zg[1].z[1].opt.app.sysconfig.sysconfig"
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key) md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
md5sum_repository=$(md5_of $SYSCONFIG_SYSCONFIG_INI_FULL) md5sum_repository=$(md5_of $sysconfig_sysconfig_ini)
elif [[ "$file" =~ .*SystemControl[.]ini.* ]]; then elif [[ "$file" =~ .*SystemControl[.]ini.* ]]; then
js_key=".ini.szeged.zg[1].z[1].opt.app.sysconfig.SystemControl" js_key=".ini.szeged.zg[1].z[1].opt.app.sysconfig.SystemControl"
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key) md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
md5sum_repository=$(md5_of $SYSCONFIG_SYSCTRL_INI_FULL) md5sum_repository=$(md5_of $sysconfig_sysctrl_ini)
elif [[ "$file" =~ .*ISMASMgr/ISMASMgr[.]ini.* ]]; then elif [[ "$file" =~ .*ISMASMgr/ISMASMgr[.]ini.* ]]; then
js_key=".ini.szeged.zg[1].z[1].opt.app.ISMASMgr.ISMASMgr" js_key=".ini.szeged.zg[1].z[1].opt.app.ISMASMgr.ISMASMgr"
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key) md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
md5sum_repository=$(md5_of $ISMASMGR_ISMASMGR_INI_FULL) md5sum_repository=$(md5_of $ismasmgr_ismasmgr_ini)
elif [[ "$file" =~ .*sysconfig/ISMASMgr[.]ini.* ]]; then elif [[ "$file" =~ .*sysconfig/ISMASMgr[.]ini.* ]]; then
js_key=".ini.szeged.zg[1].z[1].opt.app.sysconfig.ISMASMgr" js_key=".ini.szeged.zg[1].z[1].opt.app.sysconfig.ISMASMgr"
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key) md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
md5sum_repository=$(md5_of $SYSCONFIG_ISMASMGR_INI_FULL) md5sum_repository=$(md5_of $sysconfig_ismasmgr_ini)
else else
continue continue
fi fi
@ -259,7 +233,6 @@ check_md5_for_opkg_packages () {
# #
revert_customer_repository () { revert_customer_repository () {
local func="${FUNCNAME[0]}" local func="${FUNCNAME[0]}"
# TODO
return 0 return 0
} }
@ -267,7 +240,6 @@ revert_customer_repository () {
# #
backup_previous_version () { backup_previous_version () {
local func="${FUNCNAME[0]}" local func="${FUNCNAME[0]}"
# TODO
return 0 return 0
} }
@ -350,7 +322,6 @@ exec_opkg () {
# #
fallback_to_previous_version() { fallback_to_previous_version() {
local func="${FUNCNAME[0]}" local func="${FUNCNAME[0]}"
# TODO
return 0; return 0;
} }
@ -358,11 +329,15 @@ fallback_to_previous_version() {
# #
cleanup_previous_version() { cleanup_previous_version() {
local func="${FUNCNAME[0]}" local func="${FUNCNAME[0]}"
# TODO
return 0 return 0
} }
check_for_apism () { check_for_apism () {
nc localhost 7778 nc localhost 7778
if [ $? -eq 0 ]
then
return 0
fi
return 1
} }

View File

@ -8,26 +8,6 @@ source ./read_config
source ./news_to_ismas source ./news_to_ismas
source ./news_from_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() { update_psa() {
if ! updates_available; then # check for false alarm if ! updates_available; then # check for false alarm
@ -87,28 +67,28 @@ update_psa() {
# dateinen zu ueberpruefen # dateinen zu ueberpruefen
local changed_files=$(changed_file_names) local changed_files=$(changed_file_names)
local json_ini_files=$(filter_json_ini_files "$changed_files") local conf_ini_files=$(filter_conf_ini_files "$changed_files")
update_psa_report_changed_file_names $changed_files # message to ISMAS update_psa_report_changed_file_names $changed_files # message to ISMAS
# check if *.conf and/or *.ini-files have to md5-sum as denoted # check if *.conf and/or *.ini-files have to md5-sum as denoted
# in update.conf # in update.conf
if ! check_md5_for_changed_json_and_ini_files "$json_ini_files" ; then if ! check_md5_for_changed_conf_and_ini_files "$conf_ini_files" ; then
local __r=$? local __r=$?
log_error "$func:${LINENO}: new customer files wrong" log_error "$func:${LINENO}: new customer files wrong"
revert_customer_repository revert_customer_repository
exit $__r exit $__r
fi fi
if ! check_hardware_compatibility "$json_ini_files" ; then if ! check_hardware_compatibility "$conf_ini_files" ; then
local __r=$? local __r=$?
log_error "$func:${LINENO}: json/ini-files not fit for PSA" log_error "$func:${LINENO}: conf/ini-files not fit for PSA"
revert_customer_repository revert_customer_repository
exit $__r exit $__r
fi fi
# copy *.conf and/or *.ini-files to their corresponding system-directories # copy *.conf and/or *.ini-files to their corresponding system-directories
if ! copy $json_ini_files; then if ! copy $conf_ini_files; then
local __r=$? local __r=$?
log_error "$func:${LINENO}: copy operation failed" log_error "$func:${LINENO}: copy operation failed"
revert_customer_repository revert_customer_repository
@ -167,10 +147,6 @@ update_psa() {
if ! cleanup_previous_version; then if ! cleanup_previous_version; then
log_error "$func:${LINENO}: cleanup_previous_version failed" log_error "$func:${LINENO}: cleanup_previous_version failed"
fi 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 \ update_psa_cleanup $UPDATE_ISMAS_PROGRESS \
$RC_SUCCESS "cleanup after psa update" $RC_SUCCESS "cleanup after psa update"