+check_md5_for_changed_conf_and_ini_files(), +exec_opkg_noaction()

This commit is contained in:
Gerhard Hoffmann 2022-06-04 21:30:42 +02:00
parent cb0586fb6b
commit cb7cb51b24

View File

@ -34,14 +34,44 @@ fetch_customer_updates() {
# 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_customer_files () { check_md5_for_changed_conf_and_ini_files () {
local func="${FUNCNAME[0]}" local func="${FUNCNAME[0]}"
#for file in ($1); do local json_key=""
# Check the updates for correct MD5 local md5sum_update_conf=""
# log_error "$func:${LINENO}: new customer files wrong" local md5sum_repository=""
# revert_customer_repository ; exit 1 log_debug "$func:${LINENO} files=$1"
# fi if ! [ -z $1 ]; then
#done readarray -td' ' files <<< "$1"
for file in ${files[@]}; do
if [ "$file" = "emp.conf" ]; then
json_key=".conf.szeged.zg1.z1.etc.psa_config.emp"
md5sum_update_conf=$(cat $update_conf | jq -r $json_key)
md5sum_repository="$(md5sum $emp_conf | awk '{ print $1}')"
elif [ "$file" = "printer.conf" ]; then
json_key=".conf.szeged.zg1.z1.etc.psa_config.printer"
md5sum_update_conf=$(cat $update_conf | jq -r $json_key)
md5sum_repository="$(md5sum $printer_conf | awk '{ print $1}')"
elif [ "$file" = "device.conf" ]; then
json_key=".conf.szeged.zg1.z1.etc.psa_config.device"
md5sum_update_conf=$(cat $update_conf | jq -r $json_key)
md5sum_repository="$(md5sum $device_conf | awk '{ print $1}')"
else
continue
fi
if [ "$md5sum_repository" = "$md5sum_update_conf" ]; then
log_info "$func:${LINENO}: md5sum for $file ok"
else
local __r="repository: $md5sum_repository"
local __u="update.conf=$md5sum_update_conf"
local __m="$__r != $__u"
log_error "$func:${LINENO}: md5sum for $file wrong: $__m"
return 1
fi
done
else
log_debug "$func:${LINENO} no changed conf-/ini-files"
fi
return 0 return 0
} }
@ -82,7 +112,7 @@ check_md5_for_opkg_packages () {
# In case the new checked-out files are not correct, revert the git # In case the new checked-out files are not correct, revert the git
# repository to its previous state. # repository to its previous state.
# #
revert_customer_repository() { revert_customer_repository () {
local func="${FUNCNAME[0]}" local func="${FUNCNAME[0]}"
return 0 return 0
} }
@ -137,11 +167,19 @@ exec_opkg_info () {
# Try to install new opkg-packages (in case the are some # Try to install new opkg-packages (in case the are some
# in the new git-checkout). # in the new git-checkout).
# #
exec_opkg_no_action() { exec_opkg_noaction() {
local func="${FUNCNAME[0]}" local func="${FUNCNAME[0]}"
local opkg_command_no_action="opkg --noaction $1" local opkg_command_no_action="opkg --noaction $1"
log_info "$func:${LINENO}: executing $opkg_command_no_action" log_debug "$func:${LINENO}: executing $opkg_command_no_action"
return 0
local __opkg_result=$(exec_opkg_command "opkg --noaction $1")
if [ $? -eq 0 ]; then
log_info "$func:${LINENO}: opkg_result=$__opkg_result"
return 0
fi
log_error "$func:${LINENO}: error executing opkg --noaction $1"
return 1
} }
# Install the new packages using opkg. # Install the new packages using opkg.