2022-06-02 17:22:27 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# if [ ${git_helpers_sourced:-1} = "1" ]; then
|
|
|
|
# readonly git_helpers_sourced=${BASH_SOURCE[0]}
|
|
|
|
#else
|
|
|
|
# return 0
|
|
|
|
#fi
|
|
|
|
|
2022-06-04 14:43:27 +02:00
|
|
|
source ./general_utils
|
|
|
|
|
2022-06-03 20:48:37 +02:00
|
|
|
exec_opkg_command () {
|
|
|
|
local func="${FUNCNAME[0]}"
|
|
|
|
log_debug "$func:${LINENO} exec-ing [$*]"
|
|
|
|
|
2022-06-04 14:43:27 +02:00
|
|
|
local __result=$(exec_process_substitution $*)
|
2022-06-04 18:16:10 +02:00
|
|
|
local __result_code=$?
|
|
|
|
|
2022-06-04 14:43:27 +02:00
|
|
|
log_debug "$func:${LINENO} result=$__result"
|
2022-06-03 20:48:37 +02:00
|
|
|
|
2022-06-04 14:43:27 +02:00
|
|
|
printf '%s' "$__result"
|
2022-06-04 18:16:10 +02:00
|
|
|
return $__result_code
|
2022-06-03 20:48:37 +02:00
|
|
|
}
|
|
|
|
|
2022-06-02 17:22:27 +02:00
|
|
|
# Fetch/merge updates from predefined repository using git.
|
|
|
|
#
|
|
|
|
fetch_customer_updates() {
|
2022-06-03 20:48:37 +02:00
|
|
|
if ! pull_customer_repository $1; then
|
|
|
|
return 1
|
2022-06-02 17:22:27 +02:00
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2022-06-05 16:50:04 +02:00
|
|
|
copy () {
|
|
|
|
local func="${FUNCNAME[0]}"
|
2022-06-04 21:46:30 +02:00
|
|
|
local copy_necessary=0
|
2022-06-05 16:50:04 +02:00
|
|
|
|
|
|
|
readarray -td' ' files <<< "$1"
|
|
|
|
for f in ${files[@]}; do
|
2022-06-05 19:25:23 +02:00
|
|
|
log_debug "$func:${LINENO}: $f"
|
|
|
|
# $f is determined by git
|
2022-06-06 19:04:09 +02:00
|
|
|
if [[ "$f" =~ .*update[.]conf.* ]]; then
|
2022-06-02 22:28:03 +02:00
|
|
|
continue
|
|
|
|
fi
|
2022-06-02 22:11:12 +02:00
|
|
|
|
|
|
|
# macht fuer dc keinen sinn
|
|
|
|
# local sysdir=$(echo $f |
|
|
|
|
# sed -E -e s'=(.*szeged/[0-9]/[0-9])(.*)(/.*)=\2=g')
|
2022-06-04 21:46:30 +02:00
|
|
|
|
|
|
|
copy_necessary=1
|
|
|
|
|
|
|
|
PERCENT=$((PERCENT+1))
|
|
|
|
test $PERCENT -gt 100 && PERCENT=100
|
|
|
|
|
2022-06-05 15:31:10 +02:00
|
|
|
local readonly __f=${f##*/}
|
|
|
|
local readonly __m="${CUSTOMER_ID_BASE_DIR}/${f}"
|
|
|
|
local __p=""
|
2022-06-02 22:11:12 +02:00
|
|
|
|
|
|
|
# echo "TEST -> $sysdir/$__f"
|
2022-06-05 15:31:10 +02:00
|
|
|
|
2022-06-02 21:52:48 +02:00
|
|
|
if grep -qE "^.*$DC\s*$" <<< ${f}; then
|
2022-06-02 22:11:12 +02:00
|
|
|
__p="${DC_SYS_DIR}/${__f}"
|
2022-06-05 15:31:10 +02:00
|
|
|
log_debug "$func:${LINENO}: __m=$__m"
|
2022-06-02 21:52:48 +02:00
|
|
|
elif grep -qE "^.*[.]json\s*$" <<< ${f}; then
|
2022-06-02 22:11:12 +02:00
|
|
|
__p="${CONF_SYS_DIR}/${__f}"
|
2022-06-05 15:31:10 +02:00
|
|
|
log_debug "$func:${LINENO}: __m=$__m"
|
2022-06-02 22:28:03 +02:00
|
|
|
elif grep -qE "^.*[.]ini\s*$" <<< ${f}; then
|
2022-06-05 19:25:23 +02:00
|
|
|
if [ "$__f" = "$ATBQT_INI" ]; then
|
2022-06-05 15:31:10 +02:00
|
|
|
log_debug "$func:${LINENO}: __m=$__m $ATB_SYS_DIR/$__f ${f%/*}"
|
|
|
|
if grep -qE "$ATB_SYS_DIR" <<< "${f%/*}"; then
|
|
|
|
__p="$ATB_SYS_DIR/${__f}"
|
|
|
|
else
|
|
|
|
__p="$ATBAPP_SYS_DIR/${__f}"
|
|
|
|
fi
|
2022-06-05 19:25:23 +02:00
|
|
|
elif [ "$__f" = "$SYSTEM_CONTROL_INI" ]; then
|
2022-06-05 15:31:10 +02:00
|
|
|
if grep -qE "$ATB_SYS_DIR" <<< "${f%/*}"; then
|
|
|
|
__p="$ATB_SYS_DIR/${__f}"
|
|
|
|
else
|
|
|
|
__p="$SYSCONFIG_SYS_DIR/${__f}"
|
|
|
|
fi
|
2022-06-05 19:25:23 +02:00
|
|
|
elif [ "$__f" = "$SYS_CONFIG_INI" ]; then
|
2022-06-05 15:31:10 +02:00
|
|
|
if grep -qE "$ATB_SYS_DIR" <<< "${f%/*}"; then
|
|
|
|
__p="$ATB_SYS_DIR/${__f}"
|
|
|
|
else
|
|
|
|
__p="$SYSCONFIG_SYS_DIR/${__f}"
|
|
|
|
fi
|
2022-06-05 19:25:23 +02:00
|
|
|
elif [ "$__f" = "$ISMASMGR_INI" ]; then
|
|
|
|
if grep -qE "$ISMASMGR_SYS_DIR" <<< "${f%/*}"; then
|
2022-06-05 15:31:10 +02:00
|
|
|
__p="$ISMASMGR_SYS_DIR/${__f}"
|
|
|
|
elif grep -qE "$ATB_SYS_DIR" <<< "${f%/*}"; then
|
|
|
|
__p="$ATB_SYS_DIR/${__f}"
|
2022-06-05 19:25:23 +02:00
|
|
|
else
|
2022-06-05 15:31:10 +02:00
|
|
|
__p="$SYSCONFIG_SYS_DIR/${__f}"
|
2022-06-03 19:27:28 +02:00
|
|
|
fi
|
|
|
|
fi
|
2022-06-05 19:25:23 +02:00
|
|
|
fi
|
2022-06-05 15:31:10 +02:00
|
|
|
|
|
|
|
if [ ! -z "$__p" ]; then
|
|
|
|
if cp "$__m" "$__p"; then
|
|
|
|
log_info "$func:${LINENO}: cp $__m $__p ok"
|
|
|
|
update_psa_copy_conf_and_ini_files $UPDATE_ISMAS_PROGRESS \
|
|
|
|
$RC_SUCCESS "cp $__m $__p ok"
|
|
|
|
else
|
|
|
|
log_error "$func:${LINENO}: cp $__m $__p failed: error-code=$?"
|
|
|
|
update_psa_copy_conf_and_ini_files \
|
|
|
|
$UPDATE_ISMAS_ERROR $RC_COPY_ERROR "cp $__m $__p failed"
|
|
|
|
return $?
|
|
|
|
fi
|
2022-06-05 19:25:23 +02:00
|
|
|
else
|
2022-06-05 15:31:10 +02:00
|
|
|
log_error "$func:${LINENO}: __p still empty"
|
|
|
|
update_psa_copy_conf_and_ini_files \
|
|
|
|
$UPDATE_ISMAS_ERROR $RC_COPY_ERROR "__p still empty"
|
|
|
|
EXITCODE=$((EXITCODE+1))
|
|
|
|
return $EXITCODE
|
2022-06-05 16:50:04 +02:00
|
|
|
fi
|
|
|
|
done
|
2022-06-04 21:46:30 +02:00
|
|
|
|
2022-06-05 19:25:23 +02:00
|
|
|
if [ $copy_necessary -eq 0 ]; then
|
|
|
|
update_psa_copy_conf_and_ini_files $UPDATE_ISMAS_PROGRESS $RC_SUCCESS \
|
2022-06-06 19:04:09 +02:00
|
|
|
"no copy of json/ini-files necessary"
|
2022-06-05 19:25:23 +02:00
|
|
|
log_debug "$func:${LINENO}: no copy of conf/ini-files necessary"
|
|
|
|
else
|
|
|
|
log_debug "$func:${LINENO}: copied *conf/*ini-files to system-dirs"
|
|
|
|
fi
|
2022-06-05 15:31:10 +02:00
|
|
|
|
2022-06-05 19:25:23 +02:00
|
|
|
return 0
|
2022-06-05 16:50:04 +02:00
|
|
|
}
|
|
|
|
|
2022-06-02 21:52:48 +02:00
|
|
|
filter_changed_files () {
|
2022-06-05 16:50:04 +02:00
|
|
|
local func="${FUNCNAME[0]}"
|
2022-06-02 22:28:03 +02:00
|
|
|
log_debug "$func:${LINENO} $1"
|
2022-06-05 16:50:04 +02:00
|
|
|
readarray -td' ' files <<< "$1"
|
|
|
|
local __system_files=""
|
|
|
|
for f in ${files[@]}; do
|
2022-06-05 19:25:23 +02:00
|
|
|
log_debug "$func:${LINENO} $f"
|
2022-06-02 21:52:48 +02:00
|
|
|
if grep -qE "^.*[.]($2)\s*$" <<< $f; then
|
2022-06-02 22:28:03 +02:00
|
|
|
if [ -z $__system_files ]; then
|
|
|
|
__system_files="${f}"
|
|
|
|
else
|
|
|
|
__system_files="$__system_files ${f}"
|
|
|
|
fi
|
|
|
|
fi
|
2022-06-05 16:50:04 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
log_debug "$func:${LINENO} system-files=$__system_files"
|
|
|
|
printf '%s' "$__system_files"
|
|
|
|
}
|
|
|
|
|
2022-06-02 22:28:03 +02:00
|
|
|
#
|
|
|
|
md5_of () {
|
|
|
|
printf '%s' "$(md5sum "$1" | cut -d' ' -f1)"
|
|
|
|
}
|
2022-06-05 16:50:04 +02:00
|
|
|
|
2022-06-02 17:22:27 +02:00
|
|
|
# Check if the fetched/merged files have the correct md5 and are
|
|
|
|
# valid for the PSA.
|
|
|
|
#
|
2022-06-06 19:04:09 +02:00
|
|
|
check_md5_for_changed_json_and_ini_files () {
|
2022-06-03 20:48:37 +02:00
|
|
|
local func="${FUNCNAME[0]}"
|
2022-06-02 22:28:03 +02:00
|
|
|
local js_key="" # used by json-parser 'jq'
|
2022-06-04 21:30:42 +02:00
|
|
|
local md5sum_update_conf=""
|
|
|
|
local md5sum_repository=""
|
2022-06-02 22:28:03 +02:00
|
|
|
local readonly cut_md5="cut -d' ' -f1"
|
2022-06-04 21:30:42 +02:00
|
|
|
log_debug "$func:${LINENO} files=$1"
|
|
|
|
if ! [ -z $1 ]; then
|
|
|
|
readarray -td' ' files <<< "$1"
|
2022-06-02 21:52:48 +02:00
|
|
|
local readonly __cl=$CUSTOMER_LOCATION
|
2022-06-04 21:30:42 +02:00
|
|
|
for file in ${files[@]}; do
|
2022-06-02 22:11:12 +02:00
|
|
|
# .../szeged/1/1...
|
2022-06-04 21:46:30 +02:00
|
|
|
log_debug "$func:${LINENO} checking file=${file}..."
|
2022-06-02 22:11:12 +02:00
|
|
|
local __fs=${file##*.}
|
|
|
|
# local __bn=$(basename $file .$__fsuffix)
|
|
|
|
# local __key_suffix=$(echo $file |
|
|
|
|
# sed -E -e 's=(.*[0-9]/[0-9])([^.]+)(.*)=\2=g' -e 's=/=.=g')
|
|
|
|
js_key=""
|
|
|
|
|
|
|
|
case $file in
|
|
|
|
*.ini | *.json | *.hex)
|
|
|
|
|
|
|
|
set -x
|
|
|
|
local __key_suffix=$(echo $file |
|
|
|
|
sed -E -e 's=(.*[0-9]/[0-9])([^.]+)(.*)=\2=g' -e 's=/=.=g')
|
|
|
|
js_key=".$__fs.$__cl.zg[$ZONE_GROUP].z[$ZONE]$__key_suffix"
|
|
|
|
md5sum_update_conf=$(cat $PSA_UPDATE_CONF | jq -r $js_key)
|
|
|
|
md5sum_repository="$(md5_of $CUSTOMER_ID_BASE_DIR/$file)"
|
|
|
|
set +x
|
|
|
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
# *.hex)
|
|
|
|
# js_key=$(echo $file |
|
|
|
|
# sed -E -e 's=(.*szeged)([^.]+)(.*)=\2=g' -e 's=/=.=g')
|
|
|
|
# md5sum_update_conf=$(cat $PSA_UPDATE_CONF | jq -r $js_key)
|
|
|
|
# md5sum_repository="$(md5_of $CUSTOMER_ID_BASE_DIR/$file)"
|
|
|
|
# ;;
|
|
|
|
*)
|
|
|
|
log_crit "$func:${LINENO} unknown file=${file}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
#if [[ "$file" =~ .*dc2c.hex.* ]]; then
|
|
|
|
# js_key=$(echo $file |
|
|
|
|
# sed -E -e 's=(.*$CUSTOMER_LOCATION)([^.]+)(.*)=\2=g'
|
|
|
|
# -e 's=/=.=g')
|
|
|
|
# md5sum_update_conf=$(cat $PSA_UPDATE_CONF | jq -r $js_key)
|
|
|
|
# md5sum_repository="$(md5_of $CUSTOMER_ID_BASE_DIR/$file)"
|
|
|
|
#else
|
|
|
|
# if [[ "$file" =~ .*cash[.]json.* ]]; then
|
|
|
|
# js_key=".ini.$__cl.zg[$ZONE_GROUP].z[$ZONE]$__key_suffix"
|
|
|
|
# md5sum_update_conf=$(cat $PSA_UPDATE_CONF | jq -r $js_key)
|
|
|
|
# md5sum_repository="$(md5_of $CUSTOMER_ID_BASE_DIR/$file)"
|
|
|
|
# elif [[ "$file" =~ .*print[0-9][0-9][.]json.* ]]; then
|
|
|
|
# js_key=".ini.$__cl.zg[$ZONE_GROUP].z[$ZONE]$__key_suffix"
|
|
|
|
# md5sum_update_conf=$(cat $PSA_UPDATE_CONF | jq -r $js_key)
|
|
|
|
# md5sum_repository="$(md5_of $CUSTOMER_ID_BASE_DIR/$file)"
|
|
|
|
# elif [[ "$file" =~ .*conf[.]json.* ]]; then
|
|
|
|
# js_key=".ini.$__cl.zg[$ZONE_GROUP].z[$ZONE]$__key_suffix"
|
|
|
|
# md5sum_update_conf=$(cat $PSA_UPDATE_CONF | jq -r $js_key)
|
|
|
|
# md5sum_repository="$(md5_of $CUSTOMER_ID_BASE_DIR/$file)"
|
|
|
|
# elif [[ "$file" =~ .*serial[.]json.* ]]; then
|
|
|
|
# js_key=".ini.$__cl.zg[$ZONE_GROUP].z[$ZONE]$__key_suffix"
|
|
|
|
# md5sum_update_conf=$(cat $PSA_UPDATE_CONF | jq -r $js_key)
|
|
|
|
# md5sum_repository="$(md5_of $CUSTOMER_ID_BASE_DIR/$file)"
|
|
|
|
####################################################################
|
|
|
|
## ATBQT.ini
|
|
|
|
####################################################################
|
|
|
|
# elif [[ "$file" =~ .*/$ATBQT_INI.* ]]; then
|
|
|
|
# js_key=".ini.$__cl.zg[$ZONE_GROUP].z[$ZONE]$__key_suffix"
|
|
|
|
# md5sum_update_conf=$(cat $PSA_UPDATE_CONF | jq -r $js_key)
|
|
|
|
# md5sum_repository=$(md5_of $CUSTOMER_ID_BASE_DIR/$file)
|
|
|
|
####################################################################
|
|
|
|
## sysconfig.ini
|
|
|
|
####################################################################
|
|
|
|
# elif [[ "$file" =~ .*/$SYSCONF_INI.* ]]; then
|
|
|
|
# js_key=".ini.$__cl.zg[$ZONE_GROUP].z[$ZONE]$__key_suffix"
|
|
|
|
# md5sum_update_conf=$(cat $PSA_UPDATE_CONF | jq -r $js_key)
|
|
|
|
# md5sum_repository=$(md5_of $CUSTOMER_ID_BASE_DIR/$file)
|
|
|
|
####################################################################
|
|
|
|
## SystemControl.ini
|
|
|
|
####################################################################
|
|
|
|
# elif [[ "$file" =~ .*/$SYSCTRL_INI.* ]]; then
|
|
|
|
# js_key=".ini.$__cl.zg[$ZONE_GROUP].z[$ZONE]$__key_suffix"
|
|
|
|
# md5sum_update_conf=$(cat $PSA_UPDATE_CONF | jq -r $js_key)
|
|
|
|
# md5sum_repository=$(md5_of $CUSTOMER_ID_BASE_DIR/$file)
|
|
|
|
####################################################################
|
|
|
|
## ISMASMgr.ini
|
|
|
|
####################################################################
|
|
|
|
# elif [[ "$file" =~ .*/$ISMASMMGR_INI.* ]]; then
|
|
|
|
# js_key=".ini.$__cl.zg[$ZONE_GROUP].z[$ZONE]$__key_suffix"
|
|
|
|
# md5sum_update_conf=$(cat $PSA_UPDATE_CONF | jq -r $js_key)
|
|
|
|
# md5sum_repository=$(md5_of $CUSTOMER_ID_BASE_DIR/$file)
|
|
|
|
# fi
|
|
|
|
#fi
|
|
|
|
|
|
|
|
test -z $js_key && continue
|
2022-06-04 21:46:30 +02:00
|
|
|
|
|
|
|
PERCENT=$((PERCENT+1))
|
|
|
|
test $PERCENT -gt 100 && PERCENT=100
|
2022-06-04 21:30:42 +02:00
|
|
|
|
|
|
|
if [ "$md5sum_repository" = "$md5sum_update_conf" ]; then
|
|
|
|
log_info "$func:${LINENO}: md5sum for $file ok"
|
2022-06-04 21:46:30 +02:00
|
|
|
update_psa_check_hash $UPDATE_ISMAS_PROGRESS $RC_SUCCESS \
|
|
|
|
"md5sum -|$md5sum_repository|- for $file ok"
|
2022-06-04 21:30:42 +02:00
|
|
|
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"
|
2022-06-04 21:46:30 +02:00
|
|
|
update_psa_check_hash $UPDATE_ISMAS_ERROR $RC_HASH_VALUE_ERROR \
|
|
|
|
"md5sum -|$md5sum_repository|- for $file wrong"
|
|
|
|
return $?
|
2022-06-04 21:30:42 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
|
|
|
log_debug "$func:${LINENO} no changed conf-/ini-files"
|
|
|
|
fi
|
2022-06-03 20:48:37 +02:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2022-06-04 21:46:30 +02:00
|
|
|
check_hardware_compatibility () {
|
|
|
|
local func="${FUNCNAME[0]}"
|
|
|
|
# RC_HW_COMPATIBILITY_ERROR=6
|
|
|
|
update_psa_check_hardware_compatibility $UPDATE_ISMAS_PROGRESS \
|
|
|
|
$RC_SUCCESS "TODO: hardware compatibility"
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
2022-06-03 20:48:37 +02:00
|
|
|
check_md5_for_opkg_packages () {
|
2022-06-02 17:22:27 +02:00
|
|
|
local func="${FUNCNAME[0]}"
|
2022-06-03 20:48:37 +02:00
|
|
|
local -n opkg_output_ref=$1
|
|
|
|
local package=""
|
2022-06-04 18:16:10 +02:00
|
|
|
local md5sum_opkg_info=""
|
2022-06-03 20:48:37 +02:00
|
|
|
local filename=""
|
|
|
|
for line in ${opkg_output_ref[@]}; do
|
2022-06-04 18:16:10 +02:00
|
|
|
log_info "$func:${LINENO}: line=$line"
|
2022-06-03 20:48:37 +02:00
|
|
|
if grep -qE "^\s*Package\s*:.*?$" <<< "$line"; then
|
|
|
|
package=${line#*:* }
|
|
|
|
elif grep -qE "^\s*MD5Sum\s*:.*?$" <<< "$line"; then
|
2022-06-04 18:16:10 +02:00
|
|
|
md5sum_opkg_info=${line#*:* }
|
2022-06-03 20:48:37 +02:00
|
|
|
elif grep -qE "^\s*Filename\s*:.*?$" <<< "$line"; then
|
|
|
|
filename=${line#*:* }
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2022-06-03 21:50:15 +02:00
|
|
|
local __update_conf="${CUSTOMER_LOCATION_DIR}/update.conf"
|
2022-06-04 18:16:10 +02:00
|
|
|
md5sum_repo=$(cat $__update_conf | jq -r .opkg.${package}.MD5Sum)
|
|
|
|
if ! [ -z $md5sum_repo ]; then
|
|
|
|
if [ "$md5sum_opkg_info" = "$md5sum_repo" ]; then
|
|
|
|
log_info "$func:${LINENO}: md5 $md5sum_repo OK for $package"
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
log_error "$func:${LINENO}: md5sum_repo [$md5sum_repo] "\
|
|
|
|
"!= md5sum_opkg_info [$md5sum_opkg_info] for $package"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
log_error "$func:${LINENO}: md5sum_repo empty"
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 1
|
2022-06-02 17:22:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# In case the new checked-out files are not correct, revert the git
|
|
|
|
# repository to its previous state.
|
|
|
|
#
|
2022-06-04 21:30:42 +02:00
|
|
|
revert_customer_repository () {
|
2022-06-02 17:22:27 +02:00
|
|
|
local func="${FUNCNAME[0]}"
|
2022-06-05 19:25:23 +02:00
|
|
|
# TODO
|
2022-06-02 17:22:27 +02:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
# Backup before the update-process.
|
|
|
|
#
|
2022-06-03 20:48:37 +02:00
|
|
|
backup_previous_version () {
|
2022-06-02 17:22:27 +02:00
|
|
|
local func="${FUNCNAME[0]}"
|
2022-06-05 19:25:23 +02:00
|
|
|
# TODO
|
2022-06-02 17:22:27 +02:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2022-06-03 20:48:37 +02:00
|
|
|
exec_opkg_info () {
|
|
|
|
local func="${FUNCNAME[0]}"
|
2022-06-04 18:16:10 +02:00
|
|
|
log_info "$func:${LINENO}: executing info $1"
|
2022-06-03 20:48:37 +02:00
|
|
|
|
|
|
|
opkg_result=$(exec_opkg_command "opkg info $1")
|
2022-06-04 18:16:10 +02:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
# make sure the keywords start with '\n'
|
|
|
|
opkg_result=$(sed -E -e "s/(^.*)(Package)(.*$)/\n\2\3/g"\
|
|
|
|
-e "s/(^.*)(Version)(.*$)/\1\n\2\3/g"\
|
|
|
|
-e "s/(^.*)(Depends)(.*$)/\1\n\2\3/g"\
|
|
|
|
-e "s/(^.*)(Status)(.*$)/\1\n\2\3/g"\
|
|
|
|
-e "s/(^.*)(Architecture)(.*$)/\1\n\2\3/g"\
|
|
|
|
-e "s/(^.*)(Maintainer)(.*$)/\1\n\2\3/g"\
|
|
|
|
-e "s/(^.*)(MD5Sum)(.*$)/\1\n\2\3/g"\
|
|
|
|
-e "s/(^.*)(Filename)(.*$)/\1\n\2\3/g"\
|
|
|
|
-e "s/(^.*)(Source)(.*$)/\1\n\2\3/g"\
|
|
|
|
-e "s/(^.*)(Description)(.*$)/\1\n\2\3/g"\
|
|
|
|
-e "s/(^.*)(Installed-Size)(.*$)/\1\n\2\3/g"\
|
|
|
|
-e "s/(^.*)(Section)(.*$)/\1\n\2\3/g"\
|
|
|
|
-e "s/(^.*[^-])(Size)(.*$)/\1\n\2\3/g"\
|
|
|
|
-e "s/(^.*)(Installed-Time)(.*$)/\1\n\2\3/g"
|
|
|
|
<<< "$opkg_result")
|
|
|
|
|
|
|
|
local -n output_ref=$2
|
|
|
|
|
|
|
|
readarray -d $'\n' output_ref < <(printf '%s' "$opkg_result")
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
log_error "$func:${LINENO}: readarray finished with error"
|
|
|
|
return 1
|
|
|
|
fi
|
2022-06-03 20:48:37 +02:00
|
|
|
|
2022-06-04 18:16:10 +02:00
|
|
|
log_info "$func:${LINENO}: ... done"
|
|
|
|
# log_info "$func:${LINENO}: opkg_result=${output_ref[@]}"
|
|
|
|
return 0
|
2022-06-03 20:48:37 +02:00
|
|
|
fi
|
2022-06-04 18:16:10 +02:00
|
|
|
|
|
|
|
log_error "$func:${LINENO}: executing info $1"
|
|
|
|
return 1
|
2022-06-03 20:48:37 +02:00
|
|
|
}
|
|
|
|
|
2022-06-02 17:22:27 +02:00
|
|
|
# Try to install new opkg-packages (in case the are some
|
|
|
|
# in the new git-checkout).
|
|
|
|
#
|
2022-06-04 21:30:42 +02:00
|
|
|
exec_opkg_noaction() {
|
2022-06-02 17:22:27 +02:00
|
|
|
local func="${FUNCNAME[0]}"
|
2022-06-03 20:48:37 +02:00
|
|
|
local opkg_command_no_action="opkg --noaction $1"
|
2022-06-04 21:30:42 +02:00
|
|
|
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
|
2022-06-02 17:22:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Install the new packages using opkg.
|
|
|
|
#
|
2022-06-03 20:48:37 +02:00
|
|
|
exec_opkg () {
|
2022-06-02 17:22:27 +02:00
|
|
|
local func="${FUNCNAME[0]}"
|
2022-06-04 18:16:10 +02:00
|
|
|
log_debug "$func:${LINENO}: executing $1"
|
2022-06-03 22:18:00 +02:00
|
|
|
|
2022-06-04 18:16:10 +02:00
|
|
|
local __opkg_result=$(exec_opkg_command "opkg $1")
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
log_info "$func:${LINENO}: opkg_result=$__opkg_result"
|
|
|
|
return 0
|
|
|
|
fi
|
2022-06-03 22:18:00 +02:00
|
|
|
|
2022-06-04 18:16:10 +02:00
|
|
|
log_error "$func:${LINENO}: error executing $1"
|
|
|
|
return 1
|
2022-06-02 17:22:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# In case there was some error, re-install the previous package(s)
|
|
|
|
# and use the backup to restore any conf/ini-files.
|
|
|
|
#
|
|
|
|
fallback_to_previous_version() {
|
|
|
|
local func="${FUNCNAME[0]}"
|
2022-06-05 19:25:23 +02:00
|
|
|
# TODO
|
2022-06-02 17:22:27 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
# If all went well, then execute all necessary cleanup steps.
|
|
|
|
#
|
|
|
|
cleanup_previous_version() {
|
|
|
|
local func="${FUNCNAME[0]}"
|
2022-06-05 19:25:23 +02:00
|
|
|
# TODO
|
2022-06-02 17:22:27 +02:00
|
|
|
return 0
|
|
|
|
}
|
2022-06-03 21:50:15 +02:00
|
|
|
|
|
|
|
check_for_apism () {
|
|
|
|
nc localhost 7778
|
|
|
|
}
|
|
|
|
|
2022-06-07 21:51:24 +02:00
|
|
|
get_customer_id () {
|
|
|
|
echo $(cat CUST_ID_FILE)
|
|
|
|
}
|
|
|
|
|
|
|
|
get_zone_nr () {
|
|
|
|
echo $(cat ZONE_FILE)
|
|
|
|
}
|
|
|
|
|
2022-06-02 21:52:48 +02:00
|
|
|
get_plugins () {
|
|
|
|
local __plugins=""
|
|
|
|
for __f in /opt/app/ATBAPP/plugins/*; do
|
|
|
|
local plugin=$__f
|
|
|
|
plugins+="
|
|
|
|
\"${plugin##*/}\": {
|
|
|
|
"
|
|
|
|
plugins+=$(strings $__f |
|
|
|
|
grep -A4 \"Interface\": |
|
|
|
|
grep \"Version\" |
|
|
|
|
sed -E -e 's/^\s*/\n/g')
|
|
|
|
# remove trailing ',' which is already contained in returned value
|
|
|
|
plugins=${plugins/%,}
|
|
|
|
plugins+="
|
|
|
|
},"
|
|
|
|
done
|
|
|
|
printf '%s' ${plugins/%,}
|
|
|
|
}
|
|
|
|
# get_plugins
|