Taken over some parts from update_psa:
cloning of customer_repository, some sanity checks, check for available updates.
This commit is contained in:
parent
215b155f2d
commit
ef4d27eb91
117
update_psa_impl
117
update_psa_impl
@ -32,8 +32,36 @@ collect_current_configuration () {
|
||||
|
||||
update_psa() {
|
||||
update_psa_activated # message to ISMAS
|
||||
|
||||
local func="${FUNCNAME[0]}"
|
||||
|
||||
check_default_route
|
||||
check_route_to_repository "185.191.219.134" # git.mimbach.de
|
||||
# even for a git clone a running APISM is needed
|
||||
check_for_running_apism
|
||||
|
||||
# an initial clone of the customer-repository (e.g. customer_281) is
|
||||
# always possible, even without a ISMAS-WAIT-button
|
||||
clone_customer_repository ${CUSTOMER_REPOSITORY_PATH}
|
||||
check_sanity_of_repository
|
||||
$INITIAL_CLONE && return 0
|
||||
|
||||
if [ "$MAINTENANCE" = "NO" ]; then
|
||||
log_info "update_psa:${LINENO}: MAINTENANCE OFF. Checking for updates..."
|
||||
# someone must have activated the WAIT-button in ISMAS.
|
||||
# Request the status of this button in updates_available().
|
||||
if ! updates_available; then
|
||||
update_psa_false_alarm "update requested, but no WAIT state detected !!!"
|
||||
log_fatal "update_psa:${LINENO}: update requested, but no WAIT state detected !!!"
|
||||
fi
|
||||
else
|
||||
# simulate an activated WAIT-button
|
||||
set_updates_available
|
||||
while :
|
||||
do
|
||||
sleep 5
|
||||
updates_available && break
|
||||
done
|
||||
fi
|
||||
|
||||
log_debug "$func:${LINENO}: fetch/merge updates..."
|
||||
|
||||
@ -50,92 +78,5 @@ update_psa() {
|
||||
fi
|
||||
|
||||
update_psa_pull_customer_repository # message to ISMAS
|
||||
|
||||
# no backup necessary as saved in git-repo
|
||||
|
||||
# local changed_files=$(changed_file_names)
|
||||
|
||||
if [[ -f "$GIT_PULL_TMP" ]]; then
|
||||
# TODO
|
||||
if ! check_hardware_compatibility "$files_to_copy" ; then
|
||||
local __r=$?
|
||||
log_error "$func:${LINENO}: json/ini-files not fit for PSA"
|
||||
revert_customer_repository
|
||||
exit $__r
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -f "$OPKG_CMDS_TMP" ]]; then
|
||||
local commands="$(cat ${OPKG_CMDS_TMP} | tr '\n' '; ')"
|
||||
log_info "$func:${LINENO}: executed opkg commands"
|
||||
update_psa_install_opkg_packages $UPDATE_ISMAS_PROGRESS \
|
||||
$RC_SUCCESS "$commands"
|
||||
else
|
||||
log_info "$func:${LINENO}: no opkg commands to execute"
|
||||
update_psa_install_opkg_packages $UPDATE_ISMAS_PROGRESS \
|
||||
$RC_SUCCESS "no opkg commands to execute"
|
||||
fi
|
||||
|
||||
# check if the opkg-command-file has been changed during 'git pull'
|
||||
#if grep -qE ".*opkg_commands.*?" <<< $changed_files; then
|
||||
# # read opkg_cmds: each line respresents an opkg-command
|
||||
# readarray opkg_commands < <(cat $OPKG_CMDS_PSA_FILE)
|
||||
# for opkg_c in "${opkg_commands[@]}"; do
|
||||
# if grep -qE "^\s*[#]+.*$" <<< $opkg_c; then
|
||||
# continue # found comment line
|
||||
# fi
|
||||
|
||||
# # package manipulation commands without package:
|
||||
# local cwp="update|upgrade|clean"
|
||||
# # informational commands without package:
|
||||
# cwp="${cwp}|list|list-installed|list-upgradable"
|
||||
|
||||
# if grep -qE "^.*\s+($cwp)\s+.*$" <<< $opkg_c; then
|
||||
# local p=$(printf '%s' "$opkg_c" | awk '{ print $NF }')
|
||||
# local opkg_output=()
|
||||
# if ! exec_opkg_info "$p" opkg_output; then
|
||||
# log_error "$func:${LINENO}: opkg info $opkg_c failed"
|
||||
# revert_customer_repository ; exit 1
|
||||
# fi
|
||||
|
||||
# if ! check_md5_for_opkg_packages opkg_output; then
|
||||
# log_error "$func:${LINENO}: "\
|
||||
# "wrong md5sum for opkg packages"
|
||||
# revert_customer_repository ; exit 1
|
||||
# fi
|
||||
# fi
|
||||
#
|
||||
# # perform a dry-run and check if everything might work as expected.
|
||||
# if ! exec_opkg_noaction $opkg_c; then
|
||||
# log_error "$func:${LINENO}: "\
|
||||
# "opkg --noaction $opkg_c failed"
|
||||
# fi
|
||||
|
||||
# # Actually execute the opkg command
|
||||
# if ! exec_opkg $opkg_c; then
|
||||
# log_error "$func:${LINENO}: exec_opkg $opkg_c failed"
|
||||
# fallback_to_previous_version
|
||||
# revert_customer_repository ; exit 1
|
||||
# fi
|
||||
# done
|
||||
#else
|
||||
# log_info "$func:${LINENO}: no opkg commands to execute"
|
||||
# update_psa_install_opkg_packages $UPDATE_ISMAS_PROGRESS \
|
||||
# $RC_SUCCESS "no opkg commands to execute"
|
||||
#fi
|
||||
|
||||
# Cleanup.
|
||||
#if ! cleanup_previous_version; then
|
||||
# log_error "$func:${LINENO}: cleanup_previous_version failed"
|
||||
#fi
|
||||
|
||||
# compute version string for current (i.e. new) version
|
||||
compute_version
|
||||
|
||||
update_psa_cleanup $UPDATE_ISMAS_PROGRESS \
|
||||
$RC_SUCCESS "cleanup after psa update"
|
||||
|
||||
# TODO
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user