Compare commits

..

No commits in common. "103952bdb9ad9ac1e198835418f011b8daecd2f3" and "66511262e1fb119c8e35476ab2b71e2dc6697719" have entirely different histories.

5 changed files with 87 additions and 66 deletions

View File

@ -82,14 +82,10 @@ clone_customer_repository () {
then
$(exec_git_command git clone "$1")
if [ $? -eq 0 ]; then
log_debug "$func:${LINENO} cloning ${1} done"
local res=$(exec_git_command git --git-dir="${CUSTOMER_ID_BASE_DIR}/.git" --work-tree="/" init)
if ! [[ -z $res ]]; then
CLONE_CUSTOMER_REPOSITORY=true
log_debug "$func:${LINENO} re-init of ${1} done"
log_debug "$func:${LINENO} cloning ${1} done"
cd - ; return 0
fi
fi
cd -
fi
else
@ -115,7 +111,6 @@ clone_customer_repository () {
cd_customer_repository () {
local func="${FUNCNAME[0]}"
# has to be called in WORKING_DIRECTORY
cd "$WORKING_DIRECTORY"
if [ "$PWD" = "${WORKING_DIRECTORY}" ]; then
repository_dir="./$WORKSPACE_DIR/$CUSTOMER_ID"
if ! [[ -d "$repository_dir" ]]; then

View File

@ -400,8 +400,8 @@ if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
sed -E -e 's/.*:\s*(.*)/\1/g')\"
},
\"DC\" : {
\"VERSION\" : \"$(compute_hash ${DC_PSA_DC_FILE})\",
\"MD5SUM\" : \"\"
\"VERSION\" : \"$(cat $PSA_UPDATE_CONF | jq -r .dc.version)\",
\"MD5SUM\" : \"$(cat $PSA_UPDATE_CONF | jq -r .dc.dc2c)\"
},
\"PRINTER\" : {
},

View File

@ -25,13 +25,7 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
readonly PROGRAM=`basename $0`
readonly WORKSPACE_DIR=workspace
EXITCODE=$RC_SUCCESS
CLONE_CUSTOMER_REPOSITORY=false
# read config file (JSON syntax)
read_config() {
local func="${FUNCNAME[0]}"
# TODO: entfernen indem man subtree benutzt
WORKING_DIRECTORY=${WORKING_DIRECTORY:-$UPDATEPSAHOME}
CONFIGFILENAME=${CONFIGFILENAME:-'update_psa.conf'}
@ -43,6 +37,14 @@ 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"
@ -68,15 +70,12 @@ 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')
# 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"
log_debug "$func:${LINENO}: #n of zone_groups: $__number_of_zone_groups"
local __zone_groups=($__number_of_zone_groups)
for zg in `seq 1 $__number_of_zone_groups`; do
@ -95,56 +94,50 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
########################## parsing with jq finished ###########################
###############################################################################
compute_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
# TODO: wie genau soll der hash-wert berechnet werden ?
HASH="1234-abcd"
# HASH_="67890def"
echo $HASH
}
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_DIR="${CUSTOMER_ID_BASE_DIR}/${CUSTOMER_LOCATION}"
#CUST_LOC_DIR=$CUSTOMER_LOCATION_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
@ -153,9 +146,8 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
#
readonly ZONE_GROUP=1
readonly ZONE=1
readonly CUST_BASE_DIR="$CUSTOMER_ID_BASE_DIR"
#readonly CUST_BASE_DIR="${CUST_BASE_DIRS[$ZONE]}"
#assert_d CUST_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"
@ -232,7 +224,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"
@ -299,7 +291,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
@ -344,7 +336,8 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
TARIFF_FILES_JSON+=($__f)
done
readonly KNOWN_CONF_FILES=(${DC2C_PRINT_JSON[@]##*${CUSTOMER_ID}/} \
readonly KNOWN_CONF_FILES=(${CUSTOMER_LOCATION}/update.conf \
${DC2C_PRINT_JSON[@]##*${CUSTOMER_ID}/} \
${DC2C_PSA_CONF_JSON##*${CUSTOMER_ID}/} \
${DC2C_PSA_CASH_JSON##*${CUSTOMER_ID}/} \
${DC2C_PSA_SERIAL_JSON##*${CUSTOMER_ID}/})

View File

@ -6,7 +6,7 @@
"customer_location" : "szeged",
"" : "unique customer identifier",
"customer_id" : "customer_szeged_281",
"customer_id" : "customer_281",
"" : "zone file for PSA",
"zone" : "/etc/zone_nr",
@ -25,5 +25,5 @@
"zg" : [ 1, { "z" : [ 3, 1, 2, 3] } ],
"" : "url of customer repository",
"cust_repository_path" : "https://git.mimbach49.de/GerhardHoffmann/customer_szeged_281"
"cust_repository_path" : "https://git.mimbach49.de/GerhardHoffmann/customer_281"
}

View File

@ -71,9 +71,34 @@ update_psa() {
update_psa_pull_customer_repository # message to ISMAS
# no backup necessary as saved in git-repo
# TODO: backup implementieren
# Backup before any updates in case some previous test was wrong
if ! backup_previous_version; then
log_error "$func:${LINENO}: backup failed"
revert_customer_repository
update_psa_backup_error # message to ISMAS
exit $?
fi
update_psa_backup # message to ISMAS
# TODO: use CLONE_CUSTOMER_REPOSITORY=true
# d.h. wird das rep geklont, also neu angelegt, dann sind eigentlich alle
# dateinen zu ueberpruefen
local changed_files=$(changed_file_names)
local files_to_copy=$(filter_changed_files "$changed_files" 'json|ini|hex')
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_json_and_ini_files "$files_to_copy" ; then
local __r=$?
log_error "$func:${LINENO}: new customer files wrong"
revert_customer_repository
exit $__r
fi
if ! check_hardware_compatibility "$files_to_copy" ; then
local __r=$?
@ -82,6 +107,14 @@ update_psa() {
exit $__r
fi
# copy *.conf and/or *.ini-files to their corresponding system-directories
if ! copy $files_to_copy; then
local __r=$?
log_error "$func:${LINENO}: copy operation failed"
revert_customer_repository
exit $__r
fi
# check if the opkg-command-file has been changed during 'git pull'
if grep -qE ".*opkg_commands.*?" <<< $changed_files; then
# read opkg_cmds: each line respresents an opkg-command
@ -131,9 +164,9 @@ update_psa() {
fi
# Cleanup.
#if ! cleanup_previous_version; then
# log_error "$func:${LINENO}: cleanup_previous_version failed"
#fi
if ! cleanup_previous_version; then
log_error "$func:${LINENO}: cleanup_previous_version failed"
fi
# compute version string for current (i.e. new) version
compute_version