Compare commits
No commits in common. "103952bdb9ad9ac1e198835418f011b8daecd2f3" and "66511262e1fb119c8e35476ab2b71e2dc6697719" have entirely different histories.
103952bdb9
...
66511262e1
@ -82,13 +82,9 @@ clone_customer_repository () {
|
|||||||
then
|
then
|
||||||
$(exec_git_command git clone "$1")
|
$(exec_git_command git clone "$1")
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
|
CLONE_CUSTOMER_REPOSITORY=true
|
||||||
log_debug "$func:${LINENO} cloning ${1} done"
|
log_debug "$func:${LINENO} cloning ${1} done"
|
||||||
local res=$(exec_git_command git --git-dir="${CUSTOMER_ID_BASE_DIR}/.git" --work-tree="/" init)
|
cd - ; return 0
|
||||||
if ! [[ -z $res ]]; then
|
|
||||||
CLONE_CUSTOMER_REPOSITORY=true
|
|
||||||
log_debug "$func:${LINENO} re-init of ${1} done"
|
|
||||||
cd -; return 0
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
cd -
|
cd -
|
||||||
fi
|
fi
|
||||||
@ -115,7 +111,6 @@ clone_customer_repository () {
|
|||||||
cd_customer_repository () {
|
cd_customer_repository () {
|
||||||
local func="${FUNCNAME[0]}"
|
local func="${FUNCNAME[0]}"
|
||||||
# has to be called in WORKING_DIRECTORY
|
# has to be called in WORKING_DIRECTORY
|
||||||
cd "$WORKING_DIRECTORY"
|
|
||||||
if [ "$PWD" = "${WORKING_DIRECTORY}" ]; then
|
if [ "$PWD" = "${WORKING_DIRECTORY}" ]; then
|
||||||
repository_dir="./$WORKSPACE_DIR/$CUSTOMER_ID"
|
repository_dir="./$WORKSPACE_DIR/$CUSTOMER_ID"
|
||||||
if ! [[ -d "$repository_dir" ]]; then
|
if ! [[ -d "$repository_dir" ]]; then
|
||||||
|
@ -400,8 +400,8 @@ if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
|||||||
sed -E -e 's/.*:\s*(.*)/\1/g')\"
|
sed -E -e 's/.*:\s*(.*)/\1/g')\"
|
||||||
},
|
},
|
||||||
\"DC\" : {
|
\"DC\" : {
|
||||||
\"VERSION\" : \"$(compute_hash ${DC_PSA_DC_FILE})\",
|
\"VERSION\" : \"$(cat $PSA_UPDATE_CONF | jq -r .dc.version)\",
|
||||||
\"MD5SUM\" : \"\"
|
\"MD5SUM\" : \"$(cat $PSA_UPDATE_CONF | jq -r .dc.dc2c)\"
|
||||||
},
|
},
|
||||||
\"PRINTER\" : {
|
\"PRINTER\" : {
|
||||||
},
|
},
|
||||||
|
93
read_config
93
read_config
@ -25,24 +25,26 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
|||||||
readonly PROGRAM=`basename $0`
|
readonly PROGRAM=`basename $0`
|
||||||
readonly WORKSPACE_DIR=workspace
|
readonly WORKSPACE_DIR=workspace
|
||||||
|
|
||||||
|
# TODO: entfernen indem man subtree benutzt
|
||||||
|
WORKING_DIRECTORY=${WORKING_DIRECTORY:-$UPDATEPSAHOME}
|
||||||
|
CONFIGFILENAME=${CONFIGFILENAME:-'update_psa.conf'}
|
||||||
|
|
||||||
|
if ! [ -f "$CONFIGFILENAME" ]; then
|
||||||
|
log_fatal "$func:${LINENO}: $CONFIGFILENAME not found"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [ -d "$WORKING_DIRECTORY" ]; then
|
||||||
|
log_fatal "$func:${LINENO}: $WORKING_DIRECTORY not found"
|
||||||
|
fi
|
||||||
|
|
||||||
EXITCODE=$RC_SUCCESS
|
EXITCODE=$RC_SUCCESS
|
||||||
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]}"
|
||||||
|
|
||||||
WORKING_DIRECTORY=${WORKING_DIRECTORY:-$UPDATEPSAHOME}
|
|
||||||
CONFIGFILENAME=${CONFIGFILENAME:-'update_psa.conf'}
|
|
||||||
|
|
||||||
if ! [ -f "$CONFIGFILENAME" ]; then
|
|
||||||
log_fatal "$func:${LINENO}: $CONFIGFILENAME not found"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! [ -d "$WORKING_DIRECTORY" ]; then
|
|
||||||
log_fatal "$func:${LINENO}: $WORKING_DIRECTORY not found"
|
|
||||||
fi
|
|
||||||
|
|
||||||
log_debug "$func:${LINENO}: CONFIGFILENAME=$CONFIGFILENAME"
|
log_debug "$func:${LINENO}: CONFIGFILENAME=$CONFIGFILENAME"
|
||||||
log_debug "$func:${LINENO}: WORKING_DIRECTORY=$WORKING_DIRECTORY"
|
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)"
|
jq -r .cust_repository_path)"
|
||||||
assert_s CUSTOMER_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" |
|
local __number_of_zone_groups=$(cat "$cf" |
|
||||||
jq -r .zg[0] |
|
jq -r .zg[0] |
|
||||||
sed -E -e 's/[[:space:]]*//g')
|
sed -E -e 's/[[:space:]]*//g')
|
||||||
# TODO: was ist hier falsch
|
# TODO: was ist hier falsch
|
||||||
# __n_of_zgroups=$(echo "$__n_of_zgrps" | ${STRIPWHITESPACE} )
|
# __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)
|
local __zone_groups=($__number_of_zone_groups)
|
||||||
for zg in `seq 1 $__number_of_zone_groups`; do
|
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 ###########################
|
########################## parsing with jq finished ###########################
|
||||||
###############################################################################
|
###############################################################################
|
||||||
compute_hash () {
|
compute_hash () {
|
||||||
if cd_customer_repository; then
|
# TODO: wie genau soll der hash-wert berechnet werden ?
|
||||||
local hash=""
|
HASH="1234-abcd"
|
||||||
if [[ -z $1 ]]; then
|
# HASH_="67890def"
|
||||||
hash=$(git log -n 1 --pretty=format:%H)
|
echo $HASH
|
||||||
else
|
|
||||||
hash=$(git log -n 1 --pretty=format:%H -- $1)
|
|
||||||
fi
|
|
||||||
echo ${hash:0:10} # return the first 10 hex characters
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
compute_version () {
|
compute_version () {
|
||||||
VERSION="$MAJOR.$MINOR.$PATCH+$CUSTOMER_LOCATION-$(compute_hash)"
|
VERSION="$MAJOR.$MINOR.$PATCH+$CUSTOMER_LOCATION-$(compute_hash)"
|
||||||
cd_home; return 0
|
|
||||||
return 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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}"
|
||||||
|
readonly CUSTOMER_ID_BASE_DIR="${__customer_id_base_dir}/${CUSTOMER_ID}"
|
||||||
assert_d CUSTOMER_ID_BASE_DIR
|
assert_d CUSTOMER_ID_BASE_DIR
|
||||||
|
|
||||||
CUSTOMER_LOCATION_DIR="$CUSTOMER_ID_BASE_DIR"
|
CUSTOMER_LOCATION_DIR="${CUSTOMER_ID_BASE_DIR}/${CUSTOMER_LOCATION}"
|
||||||
#CUSTOMER_LOCATION_DIR="${CUSTOMER_ID_BASE_DIR}/${CUSTOMER_LOCATION}"
|
CUST_LOC_DIR=$CUSTOMER_LOCATION_DIR
|
||||||
#CUST_LOC_DIR=$CUSTOMER_LOCATION_DIR
|
|
||||||
assert_d CUSTOMER_LOCATION_DIR
|
assert_d CUSTOMER_LOCATION_DIR
|
||||||
|
|
||||||
# readonly zone_groups=(${__zone_groups[@]})
|
# readonly zone_groups=(${__zone_groups[@]})
|
||||||
# by now (03.03.2023) there is only one zone group.
|
# by now (03.03.2023) there is only one zone group.
|
||||||
#readonly local __zgroup=1
|
readonly local __zgroup=1
|
||||||
#local __number_of_zone_groups=${ZONE_GROUPS[0]}
|
local __number_of_zone_groups=${ZONE_GROUPS[0]}
|
||||||
#local __zindex=1
|
local __zindex=1
|
||||||
#local __customer_base_dirs=("placeholder")
|
local __customer_base_dirs=("placeholder")
|
||||||
#for __zg in `seq 1 $__number_of_zone_groups`; do
|
for __zg in `seq 1 $__number_of_zone_groups`; do
|
||||||
# local __n_of_zones=${ZONE_GROUPS[$__zindex]}
|
local __n_of_zones=${ZONE_GROUPS[$__zindex]}
|
||||||
# log_debug "$func:${LINENO}: zgroup $__zg has $__n_of_zones zones"
|
log_debug "$func:${LINENO}: zgroup $__zg has $__n_of_zones zones"
|
||||||
# for (( j=1; j<=$__n_of_zones; ++j)); do
|
for (( j=1; j<=$__n_of_zones; ++j)); do
|
||||||
# __customer_base_dirs+=("${CUSTOMER_LOCATION_DIR}/$__zgroup/$j")
|
__customer_base_dirs+=("${CUSTOMER_LOCATION_DIR}/$__zgroup/$j")
|
||||||
# log_debug "$func:${LINENO}: zone $j"
|
log_debug "$func:${LINENO}: zone $j"
|
||||||
# ((++__zindex))
|
((++__zindex))
|
||||||
# done
|
done
|
||||||
#done
|
done
|
||||||
|
|
||||||
# for szeged:
|
# for szeged:
|
||||||
# placeholder
|
# placeholder
|
||||||
# /home/root/szeged/UpdateController/workspace/customer_281/szeged/1/1
|
# /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/2
|
||||||
# /home/root/szeged/UpdateController/workspace/customer_281/szeged/1/3
|
# /home/root/szeged/UpdateController/workspace/customer_281/szeged/1/3
|
||||||
# readonly CUST_BASE_DIRS=(${__customer_base_dirs[@]})
|
readonly CUST_BASE_DIRS=(${__customer_base_dirs[@]})
|
||||||
# assert_a CUST_BASE_DIRS
|
assert_a CUST_BASE_DIRS
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
# TODO: falls mehrere gruppen/zonen auftauchen hier anpassen
|
# 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_GROUP=1
|
||||||
readonly ZONE=1
|
readonly ZONE=1
|
||||||
readonly CUST_BASE_DIR="$CUSTOMER_ID_BASE_DIR"
|
readonly CUST_BASE_DIR="${CUST_BASE_DIRS[$ZONE]}"
|
||||||
#readonly CUST_BASE_DIR="${CUST_BASE_DIRS[$ZONE]}"
|
assert_d CUST_BASE_DIR
|
||||||
#assert_d CUST_BASE_DIR
|
|
||||||
|
|
||||||
readonly ETC_SYS_DIR="/etc"
|
readonly ETC_SYS_DIR="/etc"
|
||||||
readonly ATB_SYS_DIR="/etc/atb"
|
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 SYSCTRL_SCF_PSA_INI_FILE="${SYSCONFIG_PSA_DIR}/$SYSCTRL_INI"
|
||||||
readonly OPKG_CMDS_PSA_FILE="${OPKG_PSA_DIR}/opkg_commands"
|
readonly OPKG_CMDS_PSA_FILE="${OPKG_PSA_DIR}/opkg_commands"
|
||||||
readonly TC_PSA_TC_FILE="${ATBAPP_PSA_DIR}/$TARIFF_CURRENT"
|
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_SERIAL_JSON="${CONF_PSA_DIR}/DC2C_serial.json"
|
||||||
readonly DC2C_PSA_CASH_JSON="${CONF_PSA_DIR}/DC2C_cash.json"
|
readonly DC2C_PSA_CASH_JSON="${CONF_PSA_DIR}/DC2C_cash.json"
|
||||||
readonly DC2C_PSA_CONF_JSON="${CONF_PSA_DIR}/DC2C_conf.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_ATB_PSA_INI_FILE
|
||||||
assert_f SYSCTRL_SCF_PSA_INI_FILE
|
assert_f SYSCTRL_SCF_PSA_INI_FILE
|
||||||
assert_f TC_PSA_TC_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 OPKG_CMDS_PSA_FILE
|
||||||
assert_f DC2C_PSA_CONF_JSON
|
assert_f DC2C_PSA_CONF_JSON
|
||||||
assert_f DC2C_PSA_SERIAL_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)
|
TARIFF_FILES_JSON+=($__f)
|
||||||
done
|
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_CONF_JSON##*${CUSTOMER_ID}/} \
|
||||||
${DC2C_PSA_CASH_JSON##*${CUSTOMER_ID}/} \
|
${DC2C_PSA_CASH_JSON##*${CUSTOMER_ID}/} \
|
||||||
${DC2C_PSA_SERIAL_JSON##*${CUSTOMER_ID}/})
|
${DC2C_PSA_SERIAL_JSON##*${CUSTOMER_ID}/})
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
"customer_location" : "szeged",
|
"customer_location" : "szeged",
|
||||||
|
|
||||||
"" : "unique customer identifier",
|
"" : "unique customer identifier",
|
||||||
"customer_id" : "customer_szeged_281",
|
"customer_id" : "customer_281",
|
||||||
|
|
||||||
"" : "zone file for PSA",
|
"" : "zone file for PSA",
|
||||||
"zone" : "/etc/zone_nr",
|
"zone" : "/etc/zone_nr",
|
||||||
@ -25,5 +25,5 @@
|
|||||||
"zg" : [ 1, { "z" : [ 3, 1, 2, 3] } ],
|
"zg" : [ 1, { "z" : [ 3, 1, 2, 3] } ],
|
||||||
|
|
||||||
"" : "url of customer repository",
|
"" : "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"
|
||||||
}
|
}
|
||||||
|
@ -71,9 +71,34 @@ update_psa() {
|
|||||||
|
|
||||||
update_psa_pull_customer_repository # message to ISMAS
|
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 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
|
if ! check_hardware_compatibility "$files_to_copy" ; then
|
||||||
local __r=$?
|
local __r=$?
|
||||||
@ -82,6 +107,14 @@ update_psa() {
|
|||||||
exit $__r
|
exit $__r
|
||||||
fi
|
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'
|
# check if the opkg-command-file has been changed during 'git pull'
|
||||||
if grep -qE ".*opkg_commands.*?" <<< $changed_files; then
|
if grep -qE ".*opkg_commands.*?" <<< $changed_files; then
|
||||||
# read opkg_cmds: each line respresents an opkg-command
|
# read opkg_cmds: each line respresents an opkg-command
|
||||||
@ -131,9 +164,9 @@ update_psa() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Cleanup.
|
# Cleanup.
|
||||||
#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
|
||||||
|
|
||||||
# compute version string for current (i.e. new) version
|
# compute version string for current (i.e. new) version
|
||||||
compute_version
|
compute_version
|
||||||
|
Loading…
x
Reference in New Issue
Block a user