diff --git a/update_psa_helpers b/update_psa_helpers index 8760bf1..e1b6cd0 100755 --- a/update_psa_helpers +++ b/update_psa_helpers @@ -34,14 +34,44 @@ fetch_customer_updates() { # Check if the fetched/merged files have the correct md5 and are # valid for the PSA. # -check_md5_for_changed_customer_files () { +check_md5_for_changed_conf_and_ini_files () { local func="${FUNCNAME[0]}" - #for file in ($1); do - # Check the updates for correct MD5 - # log_error "$func:${LINENO}: new customer files wrong" - # revert_customer_repository ; exit 1 - # fi - #done + local json_key="" + local md5sum_update_conf="" + local md5sum_repository="" + log_debug "$func:${LINENO} files=$1" + if ! [ -z $1 ]; then + 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 } @@ -82,7 +112,7 @@ check_md5_for_opkg_packages () { # In case the new checked-out files are not correct, revert the git # repository to its previous state. # -revert_customer_repository() { +revert_customer_repository () { local func="${FUNCNAME[0]}" return 0 } @@ -137,11 +167,19 @@ exec_opkg_info () { # Try to install new opkg-packages (in case the are some # in the new git-checkout). # -exec_opkg_no_action() { +exec_opkg_noaction() { local func="${FUNCNAME[0]}" local opkg_command_no_action="opkg --noaction $1" - log_info "$func:${LINENO}: executing $opkg_command_no_action" - return 0 + log_debug "$func:${LINENO}: executing $opkg_command_no_action" + + 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.