extended copy() to handle ini-files

This commit is contained in:
Gerhard Hoffmann 2022-06-05 19:25:23 +02:00
parent 1939779f67
commit 98a2e09bd5

View File

@ -24,7 +24,6 @@ exec_opkg_command () {
# Fetch/merge updates from predefined repository using git.
#
fetch_customer_updates() {
local func="${FUNCNAME[0]}"
if ! pull_customer_repository $1; then
return 1
fi
@ -37,6 +36,8 @@ copy () {
readarray -td' ' files <<< "$1"
for f in ${files[@]}; do
log_debug "$func:${LINENO}: $f"
# $f is determined by git
if [[ "$f" =~ .*update[.]conf.* ]] || [[ "$f" =~ .*current[.]conf.* ]]
then
continue
@ -47,46 +48,62 @@ copy () {
PERCENT=$((PERCENT+1))
test $PERCENT -gt 100 && PERCENT=100
local __f=${f##*/}
local __m=""
local __copy_error=0
if grep -qE "^.*[.]conf\s*$" <<< ${f}; then
local __f=${f#*etc/}
local __msg="cp ${CUSTOMER_ID_BASE_DIR}/${f} to /etc/${__f}"
if ! cp "${CUSTOMER_ID_BASE_DIR}/${f}" "/etc/${__f}"; then
log_error "$func:${LINENO}: cannot $__msg"
update_psa_copy_conf_ini_files $UPDATE_ISMAS_ERROR \
$RC_COPY_ERROR "$__msg failed"
return $?
fi
log_info "$func:${LINENO}: copied $f to /etc/${__f}"
update_psa_copy_conf_ini $UPDATE_ISMAS_PROGRESS \
$RC_SUCCESS "$__msg ok"
__m="cp ${CUSTOMER_ID_BASE_DIR}/${f} to ${CONF_SYS_DIR}/${__f}"
cp "${CUSTOMER_ID_BASE_DIR}/${f}" "${CONF_SYS_DIR}/${__f}"
__copy_error=$?
elif grep -qE "^.*[.]ini\s*$" <<< ${f}; then
# TODO: die anderen system-verzeichnisse werden gebraucht
local __f=${f#*opt/app/ATBAPP/}
local __msg="cp ${CUSTOMER_ID_BASE_DIR}/${f} /opt/app/ATBAPP/${__f}"
if [ "$__f" = "ATBQT.ini" ]; then
if ! cp "${CUSTOMER_ID_BASE_DIR}/${f}" /opt/app/ATBAPP/${__f}
then
log_error "$func:${LINENO}: cannot $__msg"
update_psa_copy_conf_ini_files \
$UPDATE_ISMAS_ERROR $RC_COPY_ERROR "$__msg failed"
return $?
if [ "$__f" = "$ATBQT_INI" ]; then
__m="cp ${CUSTOMER_ID_BASE_DIR}/${f} $ATBAPP_SYS_DIR/${__f}"
cp "${CUSTOMER_ID_BASE_DIR}/${f}" $ATBAPP_SYS_DIR/${__f}
__copy_error=$?
elif [ "$__f" = "$SYSTEM_CONTROL_INI" ]; then
__m="cp ${CUSTOMER_ID_BASE_DIR}/${f} $SYSCONFIG_SYS_DIR/${__f}"
cp "${CUSTOMER_ID_BASE_DIR}/${f}" $SYSCONFIG_SYS_DIR/${__f}
__copy_error=$?
elif [ "$__f" = "$SYS_CONFIG_INI" ]; then
__m="cp ${CUSTOMER_ID_BASE_DIR}/${f} $SYSCONFIG_SYS_DIR/${__f}"
cp "${CUSTOMER_ID_BASE_DIR}/${f}" $SYSCONFIG_SYS_DIR/${__f}
__copy_error=$?
elif [ "$__f" = "$ISMASMGR_INI" ]; then
if grep -qE "$ISMASMGR_SYS_DIR" <<< "${f%/*}"; then
__m="cp ${CUSTOMER_ID_BASE_DIR}/${f}"
__m="$__m $ISMASMGR_SYS_DIR/${__f}"
cp "${CUSTOMER_ID_BASE_DIR}/${f}" $ISMASMGR_SYS_DIR/${__f}
__copy_error=$?
else
__m="cp ${CUSTOMER_ID_BASE_DIR}/${f}"
__m="$__m $SYSCONFIG_SYS_DIR/${__f}"
cp "${CUSTOMER_ID_BASE_DIR}/${f}" $SYSCONFIG_SYS_DIR/${__f}
__copy_error=$?
fi
fi
fi
log_info "$func:${LINENO}: $__msg"
update_psa_copy_conf_ini $UPDATE_ISMAS_PROGRESS \
$RC_SUCCESS "$__msg ok"
if [ $__copy_error -ne 0 ]; then
log_error "$func:${LINENO}: $__m failed"
update_psa_copy_conf_and_ini_files \
$UPDATE_ISMAS_ERROR $RC_COPY_ERROR "$__m failed"
return $?
else
log_info "$func:${LINENO}: $__m ok"
update_psa_copy_conf_and_ini_files $UPDATE_ISMAS_PROGRESS \
$RC_SUCCESS "$__m ok"
fi
done
log_debug "$func:${LINENO}: copied *conf/*ini-files to system-dirs"
test $copy_necessary -eq 0 && \
update_psa_copy_conf_ini $UPDATE_ISMAS_PROGRESS $RC_SUCCESS \
if [ $copy_necessary -eq 0 ]; then
update_psa_copy_conf_and_ini_files $UPDATE_ISMAS_PROGRESS $RC_SUCCESS \
"no copy of conf/ini-files necessary"
return 0;
log_debug "$func:${LINENO}: no copy of conf/ini-files necessary"
else
log_debug "$func:${LINENO}: copied *conf/*ini-files to system-dirs"
fi
return 0
}
filter_conf_ini_files () {
@ -95,6 +112,7 @@ filter_conf_ini_files () {
readarray -td' ' files <<< "$1"
local __system_files=""
for f in ${files[@]}; do
log_debug "$func:${LINENO} $f"
if grep -qE "^.*[.](conf|ini)\s*$" <<< $f; then
if [ -z $__system_files ]; then
__system_files="${f}"
@ -142,23 +160,23 @@ check_md5_for_changed_conf_and_ini_files () {
elif [[ "$file" =~ .*ATBQT[.]ini.* ]]; then
js_key=".ini.szeged.zg[1].z[1].opt.app.ATBAPP.ATBQT"
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
md5sum_repository="$(md5_of $atbqt_ini)"
md5sum_repository="$(md5_of $ATBQT_INI_FULL)"
elif [[ "$file" =~ .*sysconfig[.]ini.* ]]; then
js_key=".ini.szeged.zg[1].z[1].opt.app.sysconfig.sysconfig"
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
md5sum_repository=$(md5_of $sysconfig_sysconfig_ini)
md5sum_repository=$(md5_of $SYSCONFIG_SYSCONFIG_INI_FULL)
elif [[ "$file" =~ .*SystemControl[.]ini.* ]]; then
js_key=".ini.szeged.zg[1].z[1].opt.app.sysconfig.SystemControl"
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
md5sum_repository=$(md5_of $sysconfig_sysctrl_ini)
md5sum_repository=$(md5_of $SYSCONFIG_SYSCTRL_INI_FULL)
elif [[ "$file" =~ .*ISMASMgr/ISMASMgr[.]ini.* ]]; then
js_key=".ini.szeged.zg[1].z[1].opt.app.ISMASMgr.ISMASMgr"
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
md5sum_repository=$(md5_of $ismasmgr_ismasmgr_ini)
md5sum_repository=$(md5_of $ISMASMGR_ISMASMGR_INI_FULL)
elif [[ "$file" =~ .*sysconfig/ISMASMgr[.]ini.* ]]; then
js_key=".ini.szeged.zg[1].z[1].opt.app.sysconfig.ISMASMgr"
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
md5sum_repository=$(md5_of $sysconfig_ismasmgr_ini)
md5sum_repository=$(md5_of $SYSCONFIG_ISMASMGR_INI_FULL)
else
continue
fi
@ -233,6 +251,7 @@ check_md5_for_opkg_packages () {
#
revert_customer_repository () {
local func="${FUNCNAME[0]}"
# TODO
return 0
}
@ -240,6 +259,7 @@ revert_customer_repository () {
#
backup_previous_version () {
local func="${FUNCNAME[0]}"
# TODO
return 0
}
@ -322,6 +342,7 @@ exec_opkg () {
#
fallback_to_previous_version() {
local func="${FUNCNAME[0]}"
# TODO
return 0;
}
@ -329,15 +350,11 @@ fallback_to_previous_version() {
#
cleanup_previous_version() {
local func="${FUNCNAME[0]}"
# TODO
return 0
}
check_for_apism () {
nc localhost 7778
if [ $? -eq 0 ]
then
return 0
fi
return 1
}