Compare commits

...

7 Commits

5 changed files with 54 additions and 40 deletions

View File

@ -245,12 +245,8 @@ changed_file_names () {
git_res=${git_res//[$'\r\n\t']/ } git_res=${git_res//[$'\r\n\t']/ }
log_debug "$func:${LINENO}: git_res=$git_res" log_debug "$func:${LINENO}: git_res=$git_res"
local file_names="" local file_names=""
local known_files=(update.conf current.conf emp.conf)
known_files=(${known_files[@]} device.conf printer.conf opkg_commands)
known_files=(${known_files[@]} ATBQT.ini sysconfig.ini ISMASMgr.ini)
known_files=(${known_files[@]} SystemControl.ini)
for f in ${known_files[@]} ; do for f in ${known_files[@]} ; do
if grep -qE ".*/${f}\s+.*" <<< $git_res; then if grep -qE ".*\s+${f}\s+.*" <<< $git_res; then
if ! [ -z $file_names ]; then if ! [ -z $file_names ]; then
file_names="$f $file_names" file_names="$f $file_names"
else else

View File

@ -27,7 +27,7 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
if [ -z "$workspace_dir" ]; then if [ -z "$workspace_dir" ]; then
log_fatal "$func:${LINENO}: workspace_dir not set in $1" log_fatal "$func:${LINENO}: workspace_dir not set in $1"
fi fi
log_debug "$func:${LINENO}: workspace_dir=$working_dir" log_debug "$func:${LINENO}: workspace_dir=$workspace_dir"
readonly customer_location=$(cat "$1" | jq -r .customer_location) readonly customer_location=$(cat "$1" | jq -r .customer_location)
if [ -z "$customer_location" ]; then if [ -z "$customer_location" ]; then
@ -69,6 +69,11 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
local __customer_base_dir="$working_directory/${workspace_dir}" local __customer_base_dir="$working_directory/${workspace_dir}"
__customer_base_dir="${__customer_base_dir}/${customer_id}" __customer_base_dir="${__customer_base_dir}/${customer_id}"
readonly customer_id_base_dir=${__customer_base_dir}
log_debug "$func:${LINENO}: customer_id_base_dir="
log_debug "$func:${LINENO}: $customer_id_base_dir"
__customer_base_dir="${__customer_base_dir}/${customer_location}" __customer_base_dir="${__customer_base_dir}/${customer_location}"
readonly customer_location_dir="$__customer_base_dir" readonly customer_location_dir="$__customer_base_dir"
@ -140,7 +145,7 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
log_fatal "$func:${LINENO}: $psa_ismasmgr_dir does not exist" log_fatal "$func:${LINENO}: $psa_ismasmgr_dir does not exist"
fi fi
readonly psa_atbqt_dir="${psa_base_ini_dir}/ATBQT" readonly psa_atbqt_dir="${psa_base_ini_dir}/ATBAPP"
if [ -d "$psa_atbqt_dir" ]; then if [ -d "$psa_atbqt_dir" ]; then
log_debug "$func:${LINENO}: psa_atbqt_dir=" log_debug "$func:${LINENO}: psa_atbqt_dir="
log_debug "$func:${LINENO}: $psa_atbqt_dir" log_debug "$func:${LINENO}: $psa_atbqt_dir"
@ -220,6 +225,19 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
log_fatal "$func:${LINENO}: $opkg_cmds_file does not exist" log_fatal "$func:${LINENO}: $opkg_cmds_file does not exist"
fi fi
readonly known_files=(${customer_location}/update.conf \
${customer_location}/current.conf \
${device_conf##*${customer_id}/} \
${emp_conf##*${customer_id}/} \
${printer_conf##*${customer_id}/} \
${opkg_cmds_file##*${customer_id}/} \
${atbqt_ini##*${customer_id}/} \
${ismasmgr_ismasmgr_ini##*${customer_id}/} \
${sysconfig_ismasmgr_ini##*${customer_id}/} \
${sysconfig_sysconfig_ini##*${customer_id}/} \
${sysconfig_sysctrl_ini##*${customer_id}/})
log_debug "$func:${LINENO}: conf/ini_files=$(echo ${known_files[@]})"
log_debug "$func:${LINENO}: sanity of ${customer_repository_path} OK" log_debug "$func:${LINENO}: sanity of ${customer_repository_path} OK"
return 0 return 0

View File

@ -90,24 +90,24 @@ update() {
revert_customer_repository ; exit 1 revert_customer_repository ; exit 1
fi fi
local files=$(changed_file_names) local changed_files=$(changed_file_names)
local system_files=$(filter_system_files "$files") # conf/ini-files local conf_ini_files=$(filter_conf_ini_files "$changed_files")
# check if *.conf and/or *.ini-files have to md5-sum as denoted # check if *.conf and/or *.ini-files have to md5-sum as denoted
# in update.conf # in update.conf
if ! check_md5_for_changed_conf_and_ini_files "$system_files" ; then if ! check_md5_for_changed_conf_and_ini_files "$conf_ini_files" ; then
log_error "$func:${LINENO}: new customer files wrong" log_error "$func:${LINENO}: new customer files wrong"
revert_customer_repository ; exit 1 revert_customer_repository ; exit 1
fi fi
# copy *.conf and/or *.ini-files to their corresponding system-directories # copy *.conf and/or *.ini-files to their corresponding system-directories
if ! copy $system_files; then if ! copy $conf_ini_files; then
log_error "$func:${LINENO}: copy operation failed" log_error "$func:${LINENO}: copy operation failed"
revert_customer_repository ; exit 1 revert_customer_repository ; exit 1
fi 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.*?" <<< $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
readarray opkg_commands < <(cat $opkg_cmds_file) readarray opkg_commands < <(cat $opkg_cmds_file)
for opkg_c in "${opkg_commands[@]}"; do for opkg_c in "${opkg_commands[@]}"; do

View File

@ -36,21 +36,30 @@ copy () {
readarray -td' ' files <<< "$1" readarray -td' ' files <<< "$1"
for f in ${files[@]}; do for f in ${files[@]}; do
if [ "$f" = "update.conf" ] || [ "$f" = "current.conf" ]; then if [[ "$f" =~ .*update[.]conf.* ]] || [[ "$f" =~ .*current[.]conf.* ]]
then
continue continue
fi fi
if grep -qE "^.*[.]conf\s*$" <<< ${f}; then if grep -qE "^.*[.]conf\s*$" <<< ${f}; then
local __f="${psa_config_dir}/${f}" local __f=${f#*etc/}
if ! cp ${__f} /etc/psa_config; then if ! cp "${customer_id_base_dir}/${f}" "/etc/${__f}"; then
log_error "$func:${LINENO}: cannot cp ${__f} /etc/psa_config" log_error "$func:${LINENO}: cannot "\
"cp ${customer_id_base_dir}/${f} /etc/${__f}"
return 1 return 1
fi fi
log_info "$func:${LINENO}: copied $f to /etc/psa_config" log_info "$func:${LINENO}: copied $f to /etc/${__f}"
elif grep -qE "^.*[.]ini\s*$" <<< ${f}; then elif grep -qE "^.*[.]ini\s*$" <<< ${f}; then
# TODO # TODO: die anderen system-verzeichnisse werden gebraucht
set -x local __f=${f#*opt/app/ATBAPP/}
: if [ "$__f" = "ATBQT.ini" ]; then
set +x if ! cp "${customer_id_base_dir}/${f}" /opt/app/ATBAPP/${__f}
then
log_error "$func:${LINENO}: cannot "\
"cp ${customer_id_base_dir}/${f} /opt/app/ATBAPP/${__f}"
return 1
fi
fi
log_info "$func:${LINENO}: copied $f to /opt/app/ATBAPP/${__f}"
fi fi
done done
@ -58,7 +67,7 @@ copy () {
return 0; return 0;
} }
filter_system_files () { filter_conf_ini_files () {
local func="${FUNCNAME[0]}" local func="${FUNCNAME[0]}"
log_debug "$func:${LINENO} $1" log_debug "$func:${LINENO} $1"
readarray -td' ' files <<< "$1" readarray -td' ' files <<< "$1"
@ -96,44 +105,35 @@ check_md5_for_changed_conf_and_ini_files () {
readarray -td' ' files <<< "$1" readarray -td' ' files <<< "$1"
for file in ${files[@]}; do for file in ${files[@]}; do
log_debug "$func:${LINENO} file=$file" log_debug "$func:${LINENO} file=$file"
if [ "$file" = "emp.conf" ]; then if [[ "$file" =~ .*emp[.]conf.* ]]; then
js_key=".conf.szeged.zg[1].z[1].etc.psa_config.emp" js_key=".conf.szeged.zg[1].z[1].etc.psa_config.emp"
md5sum_update_conf=$(cat $update_conf | jq -r $js_key) md5sum_update_conf=$(cat $update_conf | jq -r $js_key)
md5sum_repository="$(md5_of $emp_conf)" md5sum_repository="$(md5_of $emp_conf)"
elif [ "$file" = "printer.conf" ]; then elif [[ "$file" =~ .*printer[.]conf.* ]]; then
js_key=".conf.szeged.zg[1].z[1].etc.psa_config.printer" js_key=".conf.szeged.zg[1].z[1].etc.psa_config.printer"
md5sum_update_conf=$(cat $update_conf | jq -r $js_key) md5sum_update_conf=$(cat $update_conf | jq -r $js_key)
md5sum_repository="$(md5_of $printer_conf)" md5sum_repository="$(md5_of $printer_conf)"
elif [ "$file" = "device.conf" ]; then elif [[ "$file" =~ .*device[.]conf.* ]]; then
js_key=".conf.szeged.zg[1].z[1].etc.psa_config.device" js_key=".conf.szeged.zg[1].z[1].etc.psa_config.device"
md5sum_update_conf=$(cat $update_conf | jq -r $js_key) md5sum_update_conf=$(cat $update_conf | jq -r $js_key)
md5sum_repository="$(md5_of $device_conf)" md5sum_repository="$(md5_of $device_conf)"
elif [ "$file" = "ATBQT.ini" ]; then elif [[ "$file" =~ .*ATBQT[.]ini.* ]]; then
js_key=".ini.szeged.zg[1].z[1].opt.app.ATBQT.ATBQT" js_key=".ini.szeged.zg[1].z[1].opt.app.ATBAPP.ATBQT"
md5sum_update_conf=$(cat $update_conf | jq -r $js_key) md5sum_update_conf=$(cat $update_conf | jq -r $js_key)
md5sum_repository="$(md5_of $atbqt_ini)" md5sum_repository="$(md5_of $atbqt_ini)"
elif [ "$file" = "sysconfig.ini" ]; then elif [[ "$file" =~ .*sysconfig[.]ini.* ]]; then
js_key=".ini.szeged.zg[1].z[1].opt.app.sysconfig.sysconfig" js_key=".ini.szeged.zg[1].z[1].opt.app.sysconfig.sysconfig"
md5sum_update_conf=$(cat $update_conf | jq -r $js_key) md5sum_update_conf=$(cat $update_conf | jq -r $js_key)
md5sum_repository=$(md5_of $sysconfig_sysconfig_ini) md5sum_repository=$(md5_of $sysconfig_sysconfig_ini)
elif [ "$file" = "SystemControl.ini" ]; then elif [[ "$file" =~ .*SystemControl[.]ini.* ]]; then
js_key=".ini.szeged.zg[1].z[1].opt.app.sysconfig.SystemControl" js_key=".ini.szeged.zg[1].z[1].opt.app.sysconfig.SystemControl"
md5sum_update_conf=$(cat $update_conf | jq -r $js_key) md5sum_update_conf=$(cat $update_conf | jq -r $js_key)
md5sum_repository=$(md5_of $sysconfig_sysctrl_ini) md5sum_repository=$(md5_of $sysconfig_sysctrl_ini)
elif [ "$file" = "ISMASMgr.ini" ]; then elif [[ "$file" =~ .*ISMASMgr/ISMASMgr[.]ini.* ]]; then
js_key=".ini.szeged.zg[1].z[1].opt.app.ISMASMgr.ISMASMgr" js_key=".ini.szeged.zg[1].z[1].opt.app.ISMASMgr.ISMASMgr"
md5sum_update_conf=$(cat $update_conf | jq -r $js_key) md5sum_update_conf=$(cat $update_conf | jq -r $js_key)
md5sum_repository=$(md5_of $ismasmgr_ismasmgr_ini) md5sum_repository=$(md5_of $ismasmgr_ismasmgr_ini)
if [ "$md5sum_repository" = "$md5sum_update_conf" ]; then elif [[ "$file" =~ .*sysconfig/ISMASMgr[.]ini.* ]]; 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
js_key=".ini.szeged.zg[1].z[1].opt.app.sysconfig.ISMASMgr" js_key=".ini.szeged.zg[1].z[1].opt.app.sysconfig.ISMASMgr"
md5sum_update_conf=$(cat $update_conf | jq -r $js_key) md5sum_update_conf=$(cat $update_conf | jq -r $js_key)
md5sum_repository=$(md5_of $sysconfig_ismasmgr_ini) md5sum_repository=$(md5_of $sysconfig_ismasmgr_ini)