Compare commits
7 Commits
0770d664b6
...
0ee446dcc0
Author | SHA1 | Date | |
---|---|---|---|
0ee446dcc0 | |||
99fe056626 | |||
6bc2854e78 | |||
d351f4485c | |||
283e4666c7 | |||
11e8ef90c0 | |||
6741ed8b34 |
@ -101,7 +101,9 @@ clone_customer_repository () {
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
return 1
|
||||
|
||||
update_psa_clone_error # message to ISMAS
|
||||
return $?
|
||||
}
|
||||
# clone_customer_repository ->
|
||||
# https://git.mimbach49.de/GerhardHoffmann/customer_281.git
|
||||
|
@ -12,7 +12,7 @@ if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
||||
if [ $? -eq 0 ]; then
|
||||
local trigger="$(echo $json_response | jq -r .Fileupload.TRG)"
|
||||
log_debug "$func:${LINENO}: apism_trigger=\"$trigger\""
|
||||
grep -qE "WAIT" <<< "$trigger" && return 0
|
||||
grep -qE "WAIT" <<< "$trigger" && return 0
|
||||
else
|
||||
log_error "$func:${LINENO}: apism request failed"
|
||||
fi
|
||||
|
369
news_to_ismas
369
news_to_ismas
@ -3,121 +3,350 @@
|
||||
source ./log_helpers
|
||||
|
||||
if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
||||
|
||||
readonly APISM_DB_PORT=7777
|
||||
readonly UPDATE_ISMAS_PROGRESS="U0010"
|
||||
readonly UPDATE_SUCCEEDED="U0001" # update finished: 100%
|
||||
readonly UPDATE_ACTIVATED="U0002" # reset TRG
|
||||
readonly UPDATE_ISMAS_ERROR="U0003" # update error
|
||||
|
||||
# error codes
|
||||
readonly RC_SUCCESS=0
|
||||
readonly RC_NO_UPDATE_NECESSARY=1
|
||||
readonly RC_GIT_CLONE_ERROR=2
|
||||
readonly RC_GIT_PULL_ERROR=3
|
||||
readonly RC_BACKUP_ERROR=4
|
||||
readonly RC_HASH_VALUE_ERROR=5
|
||||
readonly RC_HW_COMPATIBILITY_ERROR=6
|
||||
readonly RC_COPY_ERROR=7
|
||||
readonly RC_OPKG_COMMANDS_ERROR=8
|
||||
readonly RC_CLEANUP_ERROR=9
|
||||
|
||||
PERCENT=1
|
||||
|
||||
news_to_ismas () {
|
||||
# $1: EVENT: U0001 update finished: 100%
|
||||
# U0002 reset TRG
|
||||
# U0003 error
|
||||
# U0010 for update process
|
||||
# $2: PERCENT : "only for ISMAS: 0-100%",
|
||||
# $3: RESULTCODE : "only for ISMAS",
|
||||
# 0: Success
|
||||
# 1: no Update nessesary
|
||||
# 2: Backup failed
|
||||
# 3: Package error/ Wrong package
|
||||
# 4: Install Error
|
||||
# $4: STEP : "running step (only for us): update_psa...",
|
||||
# $5: STEP_RESULT : "error and result text",
|
||||
# $6: VERSION : "opkg and conf info; what will be updated"
|
||||
#
|
||||
local func="${FUNCNAME[0]}"
|
||||
local p=("$@")
|
||||
local data="#M=APISM#C=CMD_EVENT#J=
|
||||
{
|
||||
\"REASON\":\"SW_UP\",
|
||||
\"Timestamp\":\"$(date +%Y-%m-%dT%T.000%z)\",
|
||||
\"EVENT\":\"$1\",
|
||||
\"TIMESTAMP\":\"$(date +%Y-%m-%dT%T.000%z)\",
|
||||
\"EVENT_ID\":\"0\",
|
||||
\"EVENT\":\"${p[0]}\",
|
||||
\"EVENTSTATE\":1,
|
||||
\"PARAMETER\":\"Testdaten\"
|
||||
\"PARAMETER\": {
|
||||
\"PERCENT\" : ${p[1]},
|
||||
\"RESULTCODE\" : ${p[2]},
|
||||
\"STEP\" : \"update_psa_${p[3]}\",
|
||||
\"STEP_RESULT\" : \"${p[4]}\",
|
||||
\"VERSION\" : \"${p[5]}\"
|
||||
}
|
||||
}"
|
||||
log_debug "$func:${LINENO}: data=$data"
|
||||
echo $((echo "$data"; sleep 1) | nc localhost $APISM_DB_PORT)
|
||||
}
|
||||
|
||||
# WAIT
|
||||
|
||||
###########################################################################
|
||||
###########################################################################
|
||||
|
||||
update_psa_activated () {
|
||||
news_to_ismas "U0010"
|
||||
PERCENT=$((PERCENT+1))
|
||||
local params=("U0010" # event
|
||||
$PERCENT
|
||||
$RC_SUCCESS # resultcode
|
||||
"activated" # step
|
||||
"detected WAIT state" # step_result
|
||||
"") # version
|
||||
news_to_ismas ${params[*]}
|
||||
return $?
|
||||
}
|
||||
|
||||
update_psa_false_alarm () {
|
||||
PERCENT=$((PERCENT+1))
|
||||
local params=("U0003"
|
||||
$PERCENT
|
||||
$RC_NO_UPDATE_NECESSARY
|
||||
"false_alarm"
|
||||
"$1"
|
||||
"")
|
||||
news_to_ismas ${params[*]}
|
||||
|
||||
EXITCODE=$((EXITCODE+1))
|
||||
test $EXITCODE -gt 125 && EXITCODE=125
|
||||
return $EXITCODE
|
||||
}
|
||||
|
||||
update_psa_activated_new_software () {
|
||||
PERCENT=100
|
||||
local params=("U0010"
|
||||
$PERCENT
|
||||
$RC_SUCCESS
|
||||
"activated_new_software"
|
||||
"<hier nochmal eine liste was alles installiert wurde>"
|
||||
"<zugehoerige versionen>")
|
||||
news_to_ismas ${params[*]}
|
||||
return $?
|
||||
}
|
||||
|
||||
###########################################################################
|
||||
###########################################################################
|
||||
|
||||
# git pull
|
||||
update_psa_pull_customer_repository () {
|
||||
# text im PARAMETER?
|
||||
news_to_ismas "U0011" "git pull customer repository"
|
||||
PERCENT=10
|
||||
local params=("U0010" # event
|
||||
$PERCENT # percent
|
||||
0 # resultcode
|
||||
"pull_customer_repository" # step
|
||||
"git pulled $CUSTOMER_REPOSITORY_PATH" # step_result
|
||||
"") # version
|
||||
news_to_ismas ${params[*]}
|
||||
return $?
|
||||
}
|
||||
|
||||
update_psa_pull_error () {
|
||||
PERCENT=10
|
||||
local params=("U0003"
|
||||
$PERCENT
|
||||
$RC_GIT_PULL_ERROR
|
||||
"pull_error"
|
||||
"git failed to pull $CUSTOMER_REPOSITORY_PATH"
|
||||
"")
|
||||
news_to_ismas ${params[*]}
|
||||
|
||||
EXITCODE=$((EXITCODE+1))
|
||||
test $EXITCODE -gt 125 && EXITCODE=125
|
||||
return $EXITCODE
|
||||
}
|
||||
|
||||
update_psa_clone_error () {
|
||||
PERCENT=10
|
||||
local params=("U0003"
|
||||
$PERCENT
|
||||
$RC_GIT_CLONE_ERROR
|
||||
"clone_error"
|
||||
"git failed to clone $CUSTOMER_REPOSITORY_PATH"
|
||||
"")
|
||||
news_to_ismas ${params[*]}
|
||||
|
||||
EXITCODE=$((EXITCODE+1))
|
||||
test $EXITCODE -gt 125 && EXITCODE=125
|
||||
return $EXITCODE
|
||||
}
|
||||
|
||||
###########################################################################
|
||||
###########################################################################
|
||||
|
||||
update_psa_backup () {
|
||||
news_to_ismas "U0011" "backup before update steps"
|
||||
PERCENT=20
|
||||
local params=("U0010"
|
||||
$PERCENT
|
||||
$RC_SUCCESS
|
||||
"backup"
|
||||
"backup of (hier noch alle dateien angeben)"
|
||||
"")
|
||||
news_to_ismas ${params[*]}
|
||||
return $?
|
||||
}
|
||||
|
||||
update_psa_backup_error () {
|
||||
PERCENT=20
|
||||
local params=("U0010"
|
||||
$PERCENT
|
||||
$RC_BACKUP_ERROR
|
||||
"backup_error"
|
||||
"backup of (hier noch alle dateien angeben) failed"
|
||||
"")
|
||||
news_to_ismas ${params[*]}
|
||||
|
||||
EXITCODE=$((EXITCODE+1))
|
||||
test $EXITCODE -gt 125 && EXITCODE=125
|
||||
return $EXITCODE
|
||||
}
|
||||
|
||||
###########################################################################
|
||||
###########################################################################
|
||||
|
||||
update_psa_report_changed_file_names () {
|
||||
PERCENT=30
|
||||
local params=("U0010"
|
||||
$PERCENT
|
||||
$RC_SUCCESS
|
||||
"report_changed_file_names"
|
||||
"changed filenames: [$@]"
|
||||
"")
|
||||
news_to_ismas ${params[*]}
|
||||
return $?
|
||||
}
|
||||
|
||||
###########################################################################
|
||||
###########################################################################
|
||||
|
||||
update_psa_check_hash_values () {
|
||||
news_to_ismas "U0011" "checking file integrity"
|
||||
return $?
|
||||
update_psa_check_hash () {
|
||||
PERCENT=40
|
||||
local params=($1 # event
|
||||
$PERCENT
|
||||
$2 # resultcode
|
||||
"check_hash" # step
|
||||
"$3" # step_result
|
||||
"")
|
||||
news_to_ismas ${params[*]}
|
||||
test $2 -eq $RC_SUCCESS && return $?
|
||||
|
||||
EXITCODE=$((EXITCODE+1))
|
||||
test $EXITCODE -gt 125 && EXITCODE=125
|
||||
return $EXITCODE
|
||||
}
|
||||
|
||||
###########################################################################
|
||||
###########################################################################
|
||||
|
||||
update_psa_check_hardware_compatibility () {
|
||||
news_to_ismas "U0011" "check hardware compatiblity"
|
||||
return $?
|
||||
PERCENT=50
|
||||
local params=($1 # event
|
||||
$PERCENT
|
||||
$2 # resultcode
|
||||
"check_hardware_compatibility" # step
|
||||
"$3" # step_result
|
||||
"")
|
||||
news_to_ismas ${params[*]}
|
||||
test $2 -eq $RC_SUCCESS && return $?
|
||||
|
||||
EXITCODE=$((EXITCODE+1))
|
||||
test $EXITCODE -gt 125 && EXITCODE=125
|
||||
return $EXITCODE
|
||||
}
|
||||
|
||||
###########################################################################
|
||||
###########################################################################
|
||||
|
||||
# conf/ini files
|
||||
update_psa_copy_files () {
|
||||
news_to_ismas "U0011" "copy conf/ini-files"
|
||||
return $?
|
||||
update_psa_copy_conf_and_ini_files () {
|
||||
PERCENT=60
|
||||
local params=($1 # event
|
||||
$PERCENT
|
||||
$2 # resultcode
|
||||
"copy_conf_and_ini_files" # step
|
||||
"$3" # step_result
|
||||
"")
|
||||
news_to_ismas ${params[*]}
|
||||
test $2 -eq $RC_SUCCESS && return $?
|
||||
|
||||
EXITCODE=$((EXITCODE+1))
|
||||
test $EXITCODE -gt 125 && EXITCODE=125
|
||||
return $EXITCODE
|
||||
}
|
||||
|
||||
###########################################################################
|
||||
###########################################################################
|
||||
|
||||
# exec opkg-commands (dry-run)
|
||||
update_psa_install_packages_dry_run () {
|
||||
news_to_ismas "U0011" "install opkg-packages (dry-run)"
|
||||
return $?
|
||||
update_psa_install_opkg_packages_dry_run () {
|
||||
PERCENT=70
|
||||
# TODO
|
||||
return 0
|
||||
}
|
||||
|
||||
###########################################################################
|
||||
###########################################################################
|
||||
|
||||
# exec opkg-commands
|
||||
update_psa_install_packages () {
|
||||
news_to_ismas "U0011" "install opkg-packages"
|
||||
return $?
|
||||
update_psa_install_opkg_packages () {
|
||||
PERCENT=80
|
||||
local params=($1 # event
|
||||
$PERCENT
|
||||
$2 # resultcode
|
||||
"install_opkg_packages" # step
|
||||
"$3" # step_result
|
||||
"")
|
||||
news_to_ismas ${params[*]}
|
||||
test $2 -eq $RC_SUCCESS && return $?
|
||||
|
||||
EXITCODE=$((EXITCODE+1))
|
||||
test $EXITCODE -gt 125 && EXITCODE=125
|
||||
return $EXITCODE
|
||||
}
|
||||
|
||||
###########################################################################
|
||||
###########################################################################
|
||||
# remove backup in case of success
|
||||
update_psa_cleanup () {
|
||||
news_to_ismas "U0011" "cleanup"
|
||||
return $?
|
||||
PERCENT=90
|
||||
local params=($1 # event
|
||||
$PERCENT
|
||||
$2 # resultcode
|
||||
"cleanup" # step
|
||||
"$3" # step_result
|
||||
"")
|
||||
news_to_ismas ${params[*]}
|
||||
test $2 -eq $RC_SUCCESS && return $?
|
||||
|
||||
EXITCODE=$((EXITCODE+1))
|
||||
test $EXITCODE -gt 125 && EXITCODE=125
|
||||
return $EXITCODE
|
||||
}
|
||||
|
||||
update_psa_finished () {
|
||||
news_to_ismas "U0012"
|
||||
return $?
|
||||
###########################################################################
|
||||
###########################################################################
|
||||
|
||||
update_psa_update_succeeded () {
|
||||
PERCENT=100
|
||||
local params=($1 # event
|
||||
$PERCENT
|
||||
$2 # resultcode
|
||||
"update_succeeded" # step
|
||||
"$3" # step_result
|
||||
"")
|
||||
news_to_ismas ${params[*]}
|
||||
test $2 -eq $RC_SUCCESS && return $?
|
||||
|
||||
EXITCODE=$((EXITCODE+1))
|
||||
test $EXITCODE -gt 125 && EXITCODE=125
|
||||
return $EXITCODE
|
||||
}
|
||||
|
||||
# results
|
||||
update_psa_succeeded () {
|
||||
news_to_ismas "U0001" "updates installed"
|
||||
return $?
|
||||
###########################################################################
|
||||
###########################################################################
|
||||
|
||||
update_psa_activate_update () {
|
||||
PERCENT=100
|
||||
local params=($1 # event
|
||||
$PERCENT
|
||||
$2 # resultcode
|
||||
"activate_update" # step
|
||||
"$3" # step_result
|
||||
"")
|
||||
news_to_ismas ${params[*]}
|
||||
test $2 -eq $RC_SUCCESS && return $?
|
||||
|
||||
EXITCODE=$((EXITCODE+1))
|
||||
test $EXITCODE -gt 125 && EXITCODE=125
|
||||
return $EXITCODE
|
||||
}
|
||||
|
||||
reset_update_trigger () {
|
||||
news_to_ismas "U0002" "updates activated"
|
||||
return $?
|
||||
}
|
||||
|
||||
update_psa_canceled_no_updates_available () {
|
||||
# text im PARAMETER?
|
||||
news_to_ismas "U0003" # "No updates available, but 'WAIT' active. Missing check-in?"
|
||||
return $?
|
||||
}
|
||||
|
||||
update_psa_backup_failed () {
|
||||
news_to_ismas "U0003" # "Backup failed"
|
||||
return $?
|
||||
}
|
||||
|
||||
update_psa_wrong_hash_values () {
|
||||
news_to_ismas "U0003" # "Wrong hash value for file <xxx>. Missing check-in?"
|
||||
return $?
|
||||
}
|
||||
|
||||
update_psa_hardware_not_compatible () {
|
||||
news_to_ismas "U0003" "conf/ini-file <xxx> and psa hardware <yyy> not compatible"
|
||||
return $?
|
||||
}
|
||||
|
||||
update_psa_opkg_command_failure () {
|
||||
news_to_ismas "U0003" "opkg-command <xxx> failed"
|
||||
return $?
|
||||
}
|
||||
|
||||
update_psa_failed () {
|
||||
news_to_ismas "U0003" "Unknown error"
|
||||
return $?
|
||||
}
|
||||
|
||||
# only for testing
|
||||
set_updates_available () {
|
||||
news_to_ismas "U0099"
|
||||
local params=("U0099" # event
|
||||
$PERCENT # percent
|
||||
0 # resultcode
|
||||
"set_updates_available" # step
|
||||
"" # step_result
|
||||
"") # version
|
||||
news_to_ismas ${params[*]}
|
||||
return $?
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||
log_fatal "$func:${LINENO}: customer repository path not set in $cf"
|
||||
fi
|
||||
readonly CUSTOMER_REPOSITORY_PATH="${__r_path}/${CUSTOMER_ID}.git"
|
||||
log_debug "$func:${LINENO}: customer r-path=$CUSTOMER_REPOSITORY_PATH"
|
||||
log_debug "$func:${LINENO}: customer-r-path=$CUSTOMER_REPOSITORY_PATH"
|
||||
|
||||
readonly number_of_zone_groups="$(cat "$cf" | jq -r .zone_group[0])"
|
||||
log_debug "$func:${LINENO}: $number_of_zone_groups zone_group(s)"
|
||||
|
18
update_psa
18
update_psa
@ -62,18 +62,14 @@ then
|
||||
if clone_customer_repository $CUSTOMER_REPOSITORY_PATH
|
||||
then
|
||||
check_sanity_of_repository
|
||||
|
||||
# set_updates_available
|
||||
# while :
|
||||
# do
|
||||
# sleep 5
|
||||
# updates_available && break
|
||||
# done
|
||||
|
||||
# reset_update_trigger
|
||||
# set_updates_available
|
||||
# sleep 10
|
||||
# if updates_available
|
||||
# then
|
||||
# update_psa_started
|
||||
# sleep 5
|
||||
# update_psa_in_progress
|
||||
# sleep 5
|
||||
# update_status
|
||||
# fi
|
||||
update_psa
|
||||
fi
|
||||
fi
|
||||
|
@ -33,6 +33,7 @@ fetch_customer_updates() {
|
||||
|
||||
copy () {
|
||||
local func="${FUNCNAME[0]}"
|
||||
local copy_necessary=0
|
||||
|
||||
readarray -td' ' files <<< "$1"
|
||||
for f in ${files[@]}; do
|
||||
@ -40,30 +41,51 @@ copy () {
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
copy_necessary=1
|
||||
|
||||
PERCENT=$((PERCENT+1))
|
||||
test $PERCENT -gt 100 && PERCENT=100
|
||||
|
||||
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 "\
|
||||
"cp ${CUSTOMER_ID_BASE_DIR}/${f} /etc/${__f}"
|
||||
return 1
|
||||
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
|
||||
# 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 "\
|
||||
"cp ${CUSTOMER_ID_BASE_DIR}/${f} /opt/app/ATBAPP/${__f}"
|
||||
return 1
|
||||
log_error "$func:${LINENO}: cannot $__msg"
|
||||
update_psa_copy_conf_ini_files \
|
||||
$UPDATE_ISMAS_ERROR $RC_COPY_ERROR "$__msg failed"
|
||||
return $?
|
||||
fi
|
||||
fi
|
||||
log_info "$func:${LINENO}: copied $f to /opt/app/ATBAPP/${__f}"
|
||||
|
||||
log_info "$func:${LINENO}: $__msg"
|
||||
update_psa_copy_conf_ini $UPDATE_ISMAS_PROGRESS \
|
||||
$RC_SUCCESS "$__msg 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 \
|
||||
"no copy of conf/ini-files necessary"
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -104,7 +126,7 @@ check_md5_for_changed_conf_and_ini_files () {
|
||||
if ! [ -z $1 ]; then
|
||||
readarray -td' ' files <<< "$1"
|
||||
for file in ${files[@]}; do
|
||||
log_debug "$func:${LINENO} file=$file"
|
||||
log_debug "$func:${LINENO} checking file=${file}..."
|
||||
if [[ "$file" =~ .*emp[.]conf.* ]]; then
|
||||
js_key=".conf.szeged.zg[1].z[1].etc.psa_config.emp"
|
||||
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
|
||||
@ -140,15 +162,22 @@ check_md5_for_changed_conf_and_ini_files () {
|
||||
else
|
||||
continue
|
||||
fi
|
||||
|
||||
PERCENT=$((PERCENT+1))
|
||||
test $PERCENT -gt 100 && PERCENT=100
|
||||
|
||||
if [ "$md5sum_repository" = "$md5sum_update_conf" ]; then
|
||||
log_info "$func:${LINENO}: md5sum for $file ok"
|
||||
update_psa_check_hash $UPDATE_ISMAS_PROGRESS $RC_SUCCESS \
|
||||
"md5sum -|$md5sum_repository|- 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
|
||||
update_psa_check_hash $UPDATE_ISMAS_ERROR $RC_HASH_VALUE_ERROR \
|
||||
"md5sum -|$md5sum_repository|- for $file wrong"
|
||||
return $?
|
||||
fi
|
||||
done
|
||||
else
|
||||
@ -157,6 +186,14 @@ check_md5_for_changed_conf_and_ini_files () {
|
||||
return 0
|
||||
}
|
||||
|
||||
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 $?
|
||||
}
|
||||
|
||||
check_md5_for_opkg_packages () {
|
||||
local func="${FUNCNAME[0]}"
|
||||
local -n opkg_output_ref=$1
|
||||
|
@ -9,12 +9,17 @@ source ./news_to_ismas
|
||||
source ./news_from_ismas
|
||||
|
||||
update_psa() {
|
||||
|
||||
if ! updates_available; then # check for false alarm
|
||||
update_psa_false_alarm "update requested, but no WAIT state detected"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
update_psa_activated # message to ISMAS
|
||||
|
||||
local try_update_count=0
|
||||
local func="${FUNCNAME[0]}"
|
||||
|
||||
# read config parameters
|
||||
# read_config
|
||||
|
||||
log_debug "$func:${LINENO}: fetch/merge updates..."
|
||||
|
||||
# Fetch new updates (using git)
|
||||
@ -25,27 +30,38 @@ update_psa() {
|
||||
if [ "$repository_is_already_up_to_date" = "yes" ]; then
|
||||
log_error "$func:${LINENO}: $customer_id is up-to-date"\
|
||||
"-> no files to update -> no psa update"
|
||||
exit 1
|
||||
update_psa_false_alarm \
|
||||
"update request, but no change in $CUSTOMER_REPOSITORY_PATH"
|
||||
exit $?
|
||||
fi
|
||||
try_updates_count=$((try_updates_count+1))
|
||||
if [[ "$try_updates_count" -eq 5 ]]; then
|
||||
log_error "$func:${LINENO}: fetch/merging failed" ; exit 1
|
||||
log_error "$func:${LINENO}: fetch/merging failed"
|
||||
update_psa_pull_error # message to ISMAS
|
||||
exit $?
|
||||
fi
|
||||
sleep 60s
|
||||
update_psa_pull_error # message to ISMAS
|
||||
sleep 10s
|
||||
else
|
||||
# Fetched updates successfully
|
||||
try_updates_count=0
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
update_psa_pull_customer_repository # message to ISMAS
|
||||
|
||||
# TODO: backup implementieren
|
||||
# Backup before any updates in case some previous test was wrong
|
||||
if ! backup_previous_version; then
|
||||
log_error "$func:${LINENO}: backup failed"
|
||||
revert_customer_repository ; exit 1
|
||||
revert_customer_repository
|
||||
update_psa_backup_error # message to ISMAS
|
||||
exit $?
|
||||
fi
|
||||
|
||||
|
||||
update_psa_backup # message to ISMAS
|
||||
|
||||
# TODO: use CLONE_CUSTOMER_REPOSITORY=true
|
||||
# d.h. wird das rep geklont, also neu angelegt, dann sind eigentlich alle
|
||||
# dateinen zu ueberpruefen
|
||||
@ -53,17 +69,30 @@ update_psa() {
|
||||
local changed_files=$(changed_file_names)
|
||||
local conf_ini_files=$(filter_conf_ini_files "$changed_files")
|
||||
|
||||
update_psa_report_changed_file_names $changed_files # message to ISMAS
|
||||
|
||||
# check if *.conf and/or *.ini-files have to md5-sum as denoted
|
||||
# in update.conf
|
||||
if ! check_md5_for_changed_conf_and_ini_files "$conf_ini_files" ; then
|
||||
local __r=$?
|
||||
log_error "$func:${LINENO}: new customer files wrong"
|
||||
revert_customer_repository ; exit 1
|
||||
revert_customer_repository
|
||||
exit $__r
|
||||
fi
|
||||
|
||||
if ! check_hardware_compatibility "$conf_ini_files" ; then
|
||||
local __r=$?
|
||||
log_error "$func:${LINENO}: conf/ini-files not fit for PSA"
|
||||
revert_customer_repository
|
||||
exit $__r
|
||||
fi
|
||||
|
||||
# copy *.conf and/or *.ini-files to their corresponding system-directories
|
||||
if ! copy $conf_ini_files; then
|
||||
local __r=$?
|
||||
log_error "$func:${LINENO}: copy operation failed"
|
||||
revert_customer_repository ; exit 1
|
||||
revert_customer_repository
|
||||
exit $__r
|
||||
fi
|
||||
|
||||
# check if the opkg-command-file has been changed during 'git pull'
|
||||
@ -109,13 +138,24 @@ update_psa() {
|
||||
fi
|
||||
done
|
||||
else
|
||||
log_info "$func:${LINENO}: no opkg commnds to execute"
|
||||
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
|
||||
|
||||
update_psa_cleanup $UPDATE_ISMAS_PROGRESS \
|
||||
$RC_SUCCESS "cleanup after psa update"
|
||||
|
||||
update_psa_update_succeeded $UPDATE_SUCCEEDED \
|
||||
$RC_SUCCESS "psa update succeeded"
|
||||
|
||||
update_psa_update_succeeded $UPDATE_ACTIVATED \
|
||||
$RC_SUCCESS "psa update activated"
|
||||
|
||||
log_info "$func:${LINENO}: success"
|
||||
exit 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user