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