Compare commits

..

6 Commits

Author SHA1 Message Date
103952bdb9 use customer_szeged_281 for testing 2022-06-06 20:42:48 +02:00
0516843837 removed all needless parts: git is doing the working 2022-06-06 20:41:55 +02:00
d538f21a57 Minor change 2022-06-06 20:13:04 +02:00
f860c901f5 update.conf has been removed 2022-06-06 20:08:31 +02:00
8f07fbcf53 moved some code into read_config() to make sure proper initialization 2022-06-06 20:07:47 +02:00
326c6ea001 We use a different work-tree as usual when creatinng the repository.
Cloning the rep. does not save this setting. So we have to re-init the
rep:

git --git-dir=.git --work-tree=/ init
2022-06-06 20:05:05 +02:00
5 changed files with 66 additions and 87 deletions

View File

@ -82,9 +82,13 @@ clone_customer_repository () {
then
$(exec_git_command git clone "$1")
if [ $? -eq 0 ]; then
CLONE_CUSTOMER_REPOSITORY=true
log_debug "$func:${LINENO} cloning ${1} done"
cd - ; return 0
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"
cd -; return 0
fi
fi
cd -
fi
@ -111,6 +115,7 @@ 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\" : \"$(cat $PSA_UPDATE_CONF | jq -r .dc.version)\",
\"MD5SUM\" : \"$(cat $PSA_UPDATE_CONF | jq -r .dc.dc2c)\"
\"VERSION\" : \"$(compute_hash ${DC_PSA_DC_FILE})\",
\"MD5SUM\" : \"\"
},
\"PRINTER\" : {
},

View File

@ -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,12 +68,15 @@ 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
@ -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}/})

View File

@ -6,7 +6,7 @@
"customer_location" : "szeged",
"" : "unique customer identifier",
"customer_id" : "customer_281",
"customer_id" : "customer_szeged_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_281"
"cust_repository_path" : "https://git.mimbach49.de/GerhardHoffmann/customer_szeged_281"
}

View File

@ -71,34 +71,9 @@ update_psa() {
update_psa_pull_customer_repository # message to ISMAS
# 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
# no backup necessary as saved in git-repo
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=$?
@ -107,14 +82,6 @@ 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
@ -164,9 +131,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