Compare commits
113 Commits
0571498503
...
master
Author | SHA1 | Date | |
---|---|---|---|
0a428d8756 | |||
1ecabe79ca | |||
3affefe82a | |||
a957894d9a | |||
0e7f5938c7 | |||
fcf179bee1 | |||
f7badfea2e | |||
4921cb9f06 | |||
ff2ea6b8f2 | |||
0cbd5f523f | |||
5bca1f498b | |||
2d1f11fd74 | |||
2d76b37e5d | |||
b5b3aa7e34 | |||
e3403b2ddd | |||
82d6dc643a | |||
ef4d27eb91 | |||
215b155f2d | |||
901fa4c319 | |||
e356456fb5 | |||
bcc96a388f | |||
8f50f62a52 | |||
847c58afc8 | |||
2abdf963ac | |||
96d76b856a | |||
9eff70b780 | |||
2a8be547a8 | |||
17521771e3 | |||
515c77bed4 | |||
f2617d8151 | |||
4f9c6155e1 | |||
33511a5bcb | |||
bd0d07f56f | |||
b8bc61daea | |||
27cd99f96a | |||
729778043a | |||
31e1aad762 | |||
f8c091ad0c | |||
e5e6c4c1cd | |||
95a9307631 | |||
fc1c2221b1 | |||
9b1549306d | |||
a8f691741b | |||
c229f7072c | |||
7a35039dad | |||
42fb74a041 | |||
d69f767002 | |||
7c2d78e6db | |||
9dd7eb7a3c | |||
87be571e43 | |||
2045dcedf5 | |||
9d6bb99963 | |||
8b5cda7f73 | |||
52271bef21 | |||
f080f34bb3 | |||
6f8ba186dd | |||
0541206033 | |||
b3eed36db8 | |||
966a779065 | |||
da3c9abbf5 | |||
3574453066 | |||
27445f354a | |||
83aa2dbd5c | |||
cfce4ae53c | |||
7a77d03c7e | |||
103952bdb9 | |||
0516843837 | |||
d538f21a57 | |||
f860c901f5 | |||
8f07fbcf53 | |||
326c6ea001 | |||
66511262e1 | |||
21591d8e3d | |||
a3e311e375 | |||
73a18d5615 | |||
a769fe0e12 | |||
0285fed0a1 | |||
ba556f02bd | |||
e46f596270 | |||
c3def117a5 | |||
fcef0f6ed6 | |||
729c0f8c18 | |||
ba1f70fec4 | |||
dc6226bbb7 | |||
6bf95ba131 | |||
7a06811aa5 | |||
259b61cda5 | |||
fe52f263a8 | |||
7e0eccc8d0 | |||
e941af6420 | |||
4b6723b8e6 | |||
ec660a9fad | |||
a884019431 | |||
da32f34b4e | |||
e419b74e46 | |||
a0602c820c | |||
fa5bbc76a5 | |||
4a0b0896bb | |||
39dea2f43f | |||
32fab5c34b | |||
33a6dcb181 | |||
262a851045 | |||
1ad3b7e68f | |||
312f87487d | |||
5d53c448bc | |||
f3b933fc1d | |||
c99cbce45a | |||
3bbbe57c54 | |||
da9f0a73a4 | |||
23150e1e3e | |||
e41bdf540d | |||
bcb961fc95 | |||
f70e4946d7 |
9
clone_customer_repository
Executable file
9
clone_customer_repository
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
#! /bin/bash -
|
||||||
|
# set -x
|
||||||
|
|
||||||
|
if [ $# -eq 2 ]; then
|
||||||
|
test mkdir -p $1 && cd $1 && git clone $2
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Usage: ./${0##*/} <workspace-directory> <path-to-customer-repository>
|
@@ -80,4 +80,47 @@ if [ "${general_utils_sourced:-1}" = "1" ]; then # include only once
|
|||||||
echo "INFO: $2 completed successfully" >&2
|
echo "INFO: $2 completed successfully" >&2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert_s () {
|
||||||
|
# if [ -z ${!1} ]; then
|
||||||
|
# log_fatal "$1 not set"
|
||||||
|
# fi
|
||||||
|
# log_debug "$1=${!1}"
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_d () {
|
||||||
|
# if [ ! -d ${!1} ]; then
|
||||||
|
# log_fatal "$1 does not exist"
|
||||||
|
# fi
|
||||||
|
# log_debug "$1=${!1}"
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_f () {
|
||||||
|
# if [ ! -f ${!1} ]; then
|
||||||
|
# log_fatal "$1 does not exist"
|
||||||
|
# fi
|
||||||
|
#log_debug "$1=${!1}"
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_a () {
|
||||||
|
local readonly __m="${1}[@]"
|
||||||
|
local readonly __n=(${!__m})
|
||||||
|
local __len=${#__n[@]}
|
||||||
|
# if [ $__len -eq 0 ]; then
|
||||||
|
# log_fatal "$1 not set"
|
||||||
|
# fi
|
||||||
|
# log_debug "$1=$__n"
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
empty_file () {
|
||||||
|
if [[ -f "$1" ]]; then
|
||||||
|
echo -n "" > $1
|
||||||
|
else
|
||||||
|
log_error "$1 does not exist"
|
||||||
|
fi
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
|
276
git_helpers
276
git_helpers
@@ -57,6 +57,18 @@ revert_to_commit_before_pull () {
|
|||||||
}
|
}
|
||||||
# revert_to_commit_before_pull
|
# revert_to_commit_before_pull
|
||||||
|
|
||||||
|
git_branch () {
|
||||||
|
# always relative to a git repository
|
||||||
|
echo $(git branch -a | grep '*' | awk '{ print $2 }')
|
||||||
|
}
|
||||||
|
|
||||||
|
git_customer_branch () {
|
||||||
|
if cd_customer_repository; then
|
||||||
|
customer_branch=$(git_branch)
|
||||||
|
cd_home;
|
||||||
|
echo $customer_branch
|
||||||
|
fi
|
||||||
|
}
|
||||||
# clone the customer repository in ./workspace.
|
# clone the customer repository in ./workspace.
|
||||||
# this is done only once.
|
# this is done only once.
|
||||||
#
|
#
|
||||||
@@ -70,67 +82,106 @@ revert_to_commit_before_pull () {
|
|||||||
#
|
#
|
||||||
clone_customer_repository () {
|
clone_customer_repository () {
|
||||||
local func="${FUNCNAME[0]}"
|
local func="${FUNCNAME[0]}"
|
||||||
if [ "$PWD" = "$WORKING_DIRECTORY" ]; then
|
if [ "$PWD" != "$WORKING_DIRECTORY" ]; then
|
||||||
if ! [[ -d "./$WORKSPACE_DIR" ]]; then
|
log_fatal "$func:${LINENO} PD != WD ($PWD != $WORKING_DIRECTORY)"
|
||||||
{ mkdir -p ./$WORKSPACE_DIR; }
|
fi
|
||||||
|
|
||||||
|
mkdir -p "./$WORKSPACE_DIR"
|
||||||
|
# check if the directory is empty. If so, clone the
|
||||||
|
# customer repository
|
||||||
|
if ! find ./$WORKSPACE_DIR -mindepth 1 -maxdepth 1 | read; then
|
||||||
|
log_info "$func:${LINENO} cloning ${1} into ${PWD}/${WORKSPACE_DIR}..."
|
||||||
|
if ! cd "./$WORKSPACE_DIR"; then
|
||||||
|
update_psa_clone_error # message to ISMAS
|
||||||
|
log_fatal "$func:${LINENO} can not change to $WORKSPACE_DIR"
|
||||||
fi
|
fi
|
||||||
# check if the directory is empty. If so, clone the
|
if ! exec_git_command git clone "$1"; then
|
||||||
# customer repository
|
update_psa_clone_error # message to ISMAS
|
||||||
if ! find ./$WORKSPACE_DIR -mindepth 1 -maxdepth 1 | read; then
|
log_fatal "$func:${LINENO} can not clone $1"
|
||||||
log_debug "$func:${LINENO} cloning ${1} ..."
|
|
||||||
if cd "./$WORKSPACE_DIR"
|
|
||||||
then
|
|
||||||
$(exec_git_command git clone "$1")
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
CLONE_CUSTOMER_REPOSITORY=true
|
|
||||||
log_debug "$func:${LINENO} cloning ${1} done"
|
|
||||||
cd - ; return 0
|
|
||||||
fi
|
|
||||||
cd -
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# the directory is not empty, so we assume the
|
|
||||||
# customer-repository has been cloned already
|
|
||||||
if ! [[ -d "./${WORKSPACE_DIR}/$CUSTOMER_ID" ]]; then
|
|
||||||
log_fatal "$func:${LINENO} $PWD $WORKSPACE_DIR/$CUSTOMER_ID"\
|
|
||||||
"wrong repository: $(ls -d './${WORKSPACE_DIR}/*')"
|
|
||||||
else
|
|
||||||
local __m="./${WORKSPACE_DIR}/$CUSTOMER_ID exists"
|
|
||||||
log_debug "$func:${LINENO} $__m"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
########################## CLONING DONE ############################
|
||||||
|
log_debug "$func:${LINENO} cloning ${1} done"
|
||||||
|
# after cloning, cd into repository, and re-initialize,
|
||||||
|
# setting the work-tree as "/". This has the effect that
|
||||||
|
# a "git pull" will automatically fetched files in the
|
||||||
|
# corresponding sytem-folders.
|
||||||
|
####################### CD INTO REPOSITORY ##########################
|
||||||
|
if ! cd ${CUSTOMER_ID_BASE_DIR}; then
|
||||||
|
update_psa_clone_error # message to ISMAS
|
||||||
|
log_fatal "$func:${LINENO} can not change to $CUSTOMER_ID_BASE_DIR"
|
||||||
|
fi
|
||||||
|
log_debug "$func:${LINENO} cd into $CUSTOMER_ID_BASE_DIR"
|
||||||
|
##################### CONFIGURE HOOKS DIRECTORY ######################
|
||||||
|
if ! exec_git_command git config core.hooksPath .githooks; then
|
||||||
|
update_psa_clone_error # message to ISMAS
|
||||||
|
log_fatal "$func:${LINENO} can not configure hooks directory"
|
||||||
|
fi
|
||||||
|
###################### CHECKOUT LOCAL BRANCH #########################
|
||||||
|
if ! exec_git_command git checkout "$LOCAL_BRANCH"; then
|
||||||
|
update_psa_clone_error # message to ISMAS
|
||||||
|
log_fatal "$func:${LINENO} can not checkout $LOCAL_BRANCH"
|
||||||
|
fi
|
||||||
|
log_debug "$func:${LINENO} checked out local branch $LOCAL_BRANCH"
|
||||||
|
######################## CONFIGURE WORKTREE ##########################
|
||||||
|
if ! exec_git_command git config core.worktree "/"; then
|
||||||
|
update_psa_clone_error # message to ISMAS
|
||||||
|
log_fatal "$func:${LINENO} can not configure worktree '/'"
|
||||||
|
fi
|
||||||
|
log_debug "$func:${LINENO} configured worktree '/'"
|
||||||
|
########################### FETCH ALL #################################
|
||||||
|
if ! exec_git_command git fetch --all; then
|
||||||
|
update_psa_clone_error # message to ISMAS
|
||||||
|
log_fatal "$func:${LINENO} can not fetch --all for $LOCAL_BRANCH"
|
||||||
|
fi
|
||||||
|
log_debug "$func:${LINENO} fetch repository"
|
||||||
|
########################## RE-INIT REPOSITORY ########################
|
||||||
|
if ! exec_git_command git reset --hard "$LOCAL_BRANCH"; then
|
||||||
|
update_psa_clone_error # message to ISMAS
|
||||||
|
log_fatal "$func:${LINENO} re-init of $LOCAL_BRANCH failed"
|
||||||
|
fi
|
||||||
|
log_debug "$func:${LINENO} reset --hard $LOCAL_BRANCH"
|
||||||
|
INITIAL_CLONE=true
|
||||||
|
log_debug "$func:${LINENO} re-init of ${1} done"
|
||||||
|
update_psa_clone_customer_repository
|
||||||
|
else
|
||||||
|
# the directory is not empty, so we assume the
|
||||||
|
# customer-repository has been cloned already
|
||||||
|
if ! [[ -d "./${WORKSPACE_DIR}/$CUSTOMER_ID" ]]; then
|
||||||
|
log_fatal "$func:${LINENO} $PWD $WORKSPACE_DIR/$CUSTOMER_ID"\
|
||||||
|
"wrong repository: $(ls -d './${WORKSPACE_DIR}/*')"
|
||||||
|
fi
|
||||||
|
local __m="./${WORKSPACE_DIR}/$CUSTOMER_ID exists"
|
||||||
|
log_info "$func:${LINENO} $__m, no clone necessary"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
update_psa_clone_error # message to ISMAS
|
cd_home
|
||||||
return $?
|
|
||||||
|
log_info "$func:${LINENO} nach cd_home $PWD"
|
||||||
}
|
}
|
||||||
# clone_customer_repository ->
|
# clone_customer_repository ->
|
||||||
# https://git.mimbach49.de/GerhardHoffmann/customer_281.git
|
# https://git.mimbach49.de/GerhardHoffmann/customer_281.git
|
||||||
|
|
||||||
cd_customer_repository () {
|
cd_customer_repository () {
|
||||||
local func="${FUNCNAME[0]}"
|
local func="${FUNCNAME[0]}"
|
||||||
# has to be called in WORKING_DIRECTORY
|
|
||||||
if [ "$PWD" = "${WORKING_DIRECTORY}" ]; then
|
|
||||||
repository_dir="./$WORKSPACE_DIR/$CUSTOMER_ID"
|
|
||||||
if ! [[ -d "$repository_dir" ]]; then
|
|
||||||
log_crit "$func:${LINENO}: $repository_dir does not exist!"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! { cd $repository_dir; } ; then
|
|
||||||
log_crit "$func:${LINENO}: cannot cd to $repository_dir!"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
log_debug "$func:${LINENO}: cd to $repository_dir!"
|
if [ "$PWD" != "$WORKING_DIRECTORY" ]; then
|
||||||
return 0
|
log_fatal "$func:${LINENO} PD != WD ($PWD != $WORKING_DIRECTORY)"
|
||||||
fi
|
fi
|
||||||
return 1
|
|
||||||
|
if ! [[ -d "$CUSTOMER_ID_BASE_DIR" ]]; then
|
||||||
|
log_fatal "$func:${LINENO}: $CUSTOMER_ID_BASE_DIR does not exist!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! cd "$CUSTOMER_ID_BASE_DIR"; then
|
||||||
|
log_fatal "$func:${LINENO}: cannot cd to $CUSTOMER_ID_BASE_DIR !!!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
log_debug "$func:${LINENO}: cd to $CUSTOMER_ID_BASE_DIR"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
cd_home () {
|
cd_home () {
|
||||||
if cd - &>/dev/null ; then
|
if cd "$WORKING_DIRECTORY" &>/dev/null ; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
return 1
|
return 1
|
||||||
@@ -143,109 +194,20 @@ pull_customer_repository () {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local commit_before_pull=$(latest_commit)
|
log_crit "$func:${LINENO}: executing 'git pull'..."
|
||||||
if [ -z $commit_before_pull ]; then
|
exec_git_command 'git pull'
|
||||||
log_warn "$func:${LINENO}: commit_before_pull empty"
|
|
||||||
cd_home ; return 1
|
# GIT_UPDATE_LOG updated by hook post-merge. it contains the names of the
|
||||||
|
# changed files or opkg-commands to execute.
|
||||||
|
# If 'git pull' has fetched new data, then there are lines starting with
|
||||||
|
# DOWNLOAD or EXECUTE.
|
||||||
|
if grep -qE "^[[:space:]]*(DOWNLOAD|EXECUTE)" "$GIT_UPDATE_LOG"; then
|
||||||
|
log_info "$func:${LINENO}: new data fetched from repository"
|
||||||
|
cd_home; return 0
|
||||||
fi
|
fi
|
||||||
log_debug "$func:${LINENO}: commit_before_pull=$commit_before_pull"
|
|
||||||
log_debug "$func:${LINENO}: executing 'git pull'..."
|
log_warn "$func:${LINENO}: no data fetched from repository"
|
||||||
|
cd_home; return 1
|
||||||
local git_result=$(exec_git_command 'git pull')
|
|
||||||
|
|
||||||
if [ -z "$git_result" ]; then
|
|
||||||
log_warn "$func:${LINENO}: git result empty" ; cd_home;
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# see https://www.gnu.org/
|
|
||||||
# software/bash/manual/html_node/Shell-Parameter-Expansion.html
|
|
||||||
# [...]
|
|
||||||
#
|
|
||||||
# ${parameter//pattern/string}
|
|
||||||
#
|
|
||||||
# If there are two slashes separating parameter and pattern (...),
|
|
||||||
# all matches of pattern are replaced with string.
|
|
||||||
#
|
|
||||||
# If the expansion of string is null, matches of pattern are deleted.
|
|
||||||
# [...]
|
|
||||||
git_result=${git_result//[$'\r\n\t']/ }
|
|
||||||
|
|
||||||
log_debug "$func:${LINENO} git-pull-result=${git_result}"
|
|
||||||
|
|
||||||
if grep -qE "^Already\s+\up\s+\to\s+date.*$" <<< "$git_result"; then
|
|
||||||
log_warn "$func:${LINENO}: repository $PWD already up to date."
|
|
||||||
read $1 <<< 'yes'
|
|
||||||
cd_home ; return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
local commit_after_pull=$(latest_commit)
|
|
||||||
if [ -z $commit_after_pull ]; then
|
|
||||||
cd_home ; return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
log_debug "$func:${LINENO}: commit_after_pull=$commit_after_pull"
|
|
||||||
|
|
||||||
# Note: # 'git pull' is a 'git fetch' followed by a 'git merge'.
|
|
||||||
# Here's the fetch portion:
|
|
||||||
#
|
|
||||||
# remote: Counting objects: 11, done.
|
|
||||||
# remote: Compressing objects: 100% (5/5), done.
|
|
||||||
# remote: Total 7 (delta 2), reused 0 (delta 0)
|
|
||||||
#
|
|
||||||
# At this point, you've told the remote what you want.
|
|
||||||
# It finds all the objects it needs to give you,
|
|
||||||
# compresses them for faster transfer over the network,
|
|
||||||
# and then reports what it's sending you.
|
|
||||||
#
|
|
||||||
# Unpacking objects: 100% (7/7), done.
|
|
||||||
#
|
|
||||||
# You receive the pack (set of compressed objects) and unpack it.
|
|
||||||
#
|
|
||||||
# From ssh://my.remote.host.com/~/git/myproject
|
|
||||||
# * branch master -> FETCH_HEAD
|
|
||||||
|
|
||||||
# You've fetched the branch 'master' from the given remote;
|
|
||||||
# the ref FETCH_HEAD now points to it.
|
|
||||||
# Now we move on to the merge - precisely, git will merge
|
|
||||||
# FETCH_HEAD (the remote's master branch) into your current branch
|
|
||||||
# (presumably master).
|
|
||||||
#
|
|
||||||
#######################################################################
|
|
||||||
# here starts "message"
|
|
||||||
#
|
|
||||||
# Updating 9d447d2..f74fb21
|
|
||||||
# Fast forward
|
|
||||||
#
|
|
||||||
# It turns out that you haven't diverged from the remote's master branch,
|
|
||||||
# so the merge is a fast-forward (a trivial merge where it simply moves
|
|
||||||
# you forward in the history).
|
|
||||||
#
|
|
||||||
# Git notes the original position of your master branch (9d447d2)
|
|
||||||
# and the new position (f74fb21) it's been fast-forwarded to.
|
|
||||||
# If you had diverged from the remote's master branch,
|
|
||||||
# you'd see the output of a recursive merge here - Merge made
|
|
||||||
# by recursive, possibly along with some Auto-merged <file>
|
|
||||||
# and (oh no!) merge conflicts!
|
|
||||||
#
|
|
||||||
# szeged/1/1/etc/psa_config/device.conf | 13 +++++++------
|
|
||||||
# szeged/update.conf | 2 +-
|
|
||||||
# 2 files changed, 8 insertions(+), 7 deletions(-)
|
|
||||||
#
|
|
||||||
# Finally, it shows you the diffstat between the original and post-merge
|
|
||||||
# position of your master branch;
|
|
||||||
# this is basically what you'd get from
|
|
||||||
#
|
|
||||||
# git diff --stat master@{1} master.
|
|
||||||
#
|
|
||||||
|
|
||||||
update_commit="${commit_before_pull}..${commit_after_pull}"
|
|
||||||
if ! grep -qE ".*Updating\s+${update_commit}.*?" <<< $git_result; then
|
|
||||||
log_crit "$func:${LINENO}: no $update_commit in [ $git_result ]"
|
|
||||||
cd_home ; return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd_home ; return 0
|
|
||||||
}
|
}
|
||||||
# pull_customer_repository customer_281
|
# pull_customer_repository customer_281
|
||||||
|
|
||||||
@@ -274,4 +236,20 @@ changed_file_names () {
|
|||||||
"while in $PWD"
|
"while in $PWD"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
# fi
|
|
||||||
|
get_blob () { # get the blob of the file(name) passed as $1
|
||||||
|
# note: this can be used for any file in the filesystem
|
||||||
|
echo $(git hash-object $1)
|
||||||
|
}
|
||||||
|
|
||||||
|
get_commit_for_blob () {
|
||||||
|
blob=$(get_blob $1)
|
||||||
|
if [ ! -z $blob ]; then
|
||||||
|
# search for the blob in all commits for the file(name) $1
|
||||||
|
echo $(echo $(git log --all --pretty=format:%H -- $1) |
|
||||||
|
xargs -I{} sh -c "git ls-tree {} -- $1 |
|
||||||
|
grep -q $blob && echo {}")
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
33
load_tariff
Executable file
33
load_tariff
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
#! /bin/bash -
|
||||||
|
# set -x
|
||||||
|
|
||||||
|
#
|
||||||
|
# echo "Usage: ./${0##*/} <tariff.config> <tariff.current>"
|
||||||
|
#
|
||||||
|
# tariff.config: a JSON-file representing the tariff which should be used
|
||||||
|
# (this tariff-file is generated by a web-based tool of
|
||||||
|
# Mobilisis)
|
||||||
|
# tariff.current: a file containing infos about the currently used tariff:
|
||||||
|
# VERSION: version of the tariff
|
||||||
|
# PROJECT: e.g. szeged
|
||||||
|
# ZONE: usually 1
|
||||||
|
# INFO: additional info for the tariff (optional)
|
||||||
|
# LOADED: date when tariff has been loaded
|
||||||
|
#
|
||||||
|
# This file will be used by the update_psa-script to send
|
||||||
|
# a message to ISMAS containing the current settings of the PSA.
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ $# -eq 2 ]; then
|
||||||
|
if [ -f $1 ]; then
|
||||||
|
out="\"VERSION\":\"$(cat $1 | jq -r .version)\"",
|
||||||
|
out+="\"PROJECT\":\"$(cat $1 | jq -r .project)\"",
|
||||||
|
out+="\"ZONE\":$(cat $1 | jq -r .zone)",
|
||||||
|
out+="\"INFO\":\"$(cat $1 | jq -r .info)\"",
|
||||||
|
out+="\"LOADED\":\"$(date +%Y-%m-%dT%T)\""
|
||||||
|
echo $out > $2
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Usage: ./${0##*/} <tariff.config> <tariff.current>"
|
20
log_helpers
20
log_helpers
@@ -17,7 +17,8 @@ if [ "${log_helpers_sourced:-1}" = "1" ]; then # include only once
|
|||||||
readonly FATAL=5
|
readonly FATAL=5
|
||||||
readonly MAX_DEBUG_LEVEL=6
|
readonly MAX_DEBUG_LEVEL=6
|
||||||
|
|
||||||
log_level=0
|
log_level=$INFO
|
||||||
|
FATAL_FAILURE=false
|
||||||
|
|
||||||
set_dbg_level () {
|
set_dbg_level () {
|
||||||
if [ $1 < $MAX_DEBUG_LEVEL ]; then
|
if [ $1 < $MAX_DEBUG_LEVEL ]; then
|
||||||
@@ -29,50 +30,61 @@ if [ "${log_helpers_sourced:-1}" = "1" ]; then # include only once
|
|||||||
return $log_level
|
return $log_level
|
||||||
}
|
}
|
||||||
|
|
||||||
log() {
|
log_to_file() {
|
||||||
if [[ $(("$(wc -l < $log_file)")) -ge $((100000)) ]]; then
|
if [[ $(("$(wc -l < $log_file)")) -ge $((100000)) ]]; then
|
||||||
# remove first line
|
# remove first line
|
||||||
sed -e 1d -i $log_file
|
sed -e 1d -i $log_file
|
||||||
fi
|
fi
|
||||||
local msg="$(date +'%Y-%m-%d_%T'): $*"
|
local msg="$(date +'%Y-%m-%d_%T'): $*"
|
||||||
echo "log:$msg" >&2
|
|
||||||
echo "$msg" >> $log_file
|
echo "$msg" >> $log_file
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log() {
|
||||||
|
local msg="$(date +'%Y-%m-%d_%T'): $*"
|
||||||
|
echo "log:$msg" >&2
|
||||||
|
}
|
||||||
|
|
||||||
log_debug() {
|
log_debug() {
|
||||||
if [ $log_level = $DEBUG ]; then
|
log_to_file "DEBUG $*"
|
||||||
|
if [ $log_level -le $DEBUG ]; then
|
||||||
log "DEBUG $*"
|
log "DEBUG $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
log_info() {
|
log_info() {
|
||||||
|
log_to_file "INFO $*"
|
||||||
if [ $log_level -le $INFO ]; then
|
if [ $log_level -le $INFO ]; then
|
||||||
log "INFO $*"
|
log "INFO $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
log_warn() {
|
log_warn() {
|
||||||
|
log_to_file "WARN $*"
|
||||||
if [ $log_level -le $WARN ]; then
|
if [ $log_level -le $WARN ]; then
|
||||||
log "WARN $*"
|
log "WARN $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
log_crit() {
|
log_crit() {
|
||||||
|
log_to_file "CRIT $*"
|
||||||
if [ $log_level -le $CRIT ]; then
|
if [ $log_level -le $CRIT ]; then
|
||||||
log "CRIT $*"
|
log "CRIT $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
log_error() {
|
log_error() {
|
||||||
|
log_to_file "ERROR $*"
|
||||||
if [ $log_level -le $ERROR ]; then
|
if [ $log_level -le $ERROR ]; then
|
||||||
log "ERROR $*"
|
log "ERROR $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
log_fatal() {
|
log_fatal() {
|
||||||
|
log_to_file "FATAL $*"
|
||||||
if [ $log_level -le $FATAL ]; then
|
if [ $log_level -le $FATAL ]; then
|
||||||
log "FATAL $*"
|
log "FATAL $*"
|
||||||
log "exiting ..."
|
log "exiting ..."
|
||||||
|
FATAL_FAILURE=true
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@@ -2,19 +2,34 @@
|
|||||||
|
|
||||||
source ./log_helpers
|
source ./log_helpers
|
||||||
|
|
||||||
if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
if [ "${news_from_ismas_sourced:-1}" = "1" ]; then # include only once
|
||||||
|
readonly news_from_ismas_sourced=${BASH_SOURCE[0]}
|
||||||
readonly APISM_DIRECT_PORT=7778
|
readonly APISM_DIRECT_PORT=7778
|
||||||
|
|
||||||
updates_available () {
|
updates_available () {
|
||||||
local func="${FUNCNAME[0]}"
|
local func="${FUNCNAME[0]}"
|
||||||
local json_response="$((echo -n '#M=APISM #C=REQ_ISMASParameter #J={}';
|
local json_response="$((echo -n '#M=APISM #C=REQ_ISMASParameter #J={}';
|
||||||
sleep 1) | nc localhost $APISM_DIRECT_PORT)"
|
sleep 5) | nc localhost $APISM_DIRECT_PORT)"
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
local trigger="$(echo $json_response | jq -r .Fileupload.TRG)"
|
local trigger="$(echo $json_response | jq -r .Fileupload.TRG)"
|
||||||
log_debug "$func:${LINENO}: apism_trigger=\"$trigger\""
|
local ismas_device_id="$(echo $json_response | jq -r .Dev_ID.Device_ID)"
|
||||||
grep -qE "WAIT" <<< "$trigger" && return 0
|
local machine_nr=$(cat "/etc/machine_nr")
|
||||||
|
log_info "$func:${LINENO}: json_response=$json_response"
|
||||||
|
log_info "$func:${LINENO}: apism_trigger=<$trigger> device_id=<$ismas_device_id> machine_nr=<$machine_nr>"
|
||||||
|
if [ ! -z "$ismas_device_id" -a "$ismas_device_id" != " " ]; then
|
||||||
|
if [ ! -z "$machine_nr" -a "$machine_nr" != " " ]; then
|
||||||
|
if [ "$ismas_device_id" != "$machine_nr" ]; then
|
||||||
|
log_error "$func:${LINENO}: ISMAS DEVICE ID <$ismas_deviceId> != LOCAL_MACHINE_NUMBER <$machine_nr>"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if grep -qE "WAIT" <<< "$trigger"; then
|
||||||
|
log_info "$func:${LINENO}: FOUND WAIT TRIGGER"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
log_error "$func:${LINENO}: apism request failed"
|
log_error "$func:${LINENO}: APISM REQUEST FAILED"
|
||||||
fi
|
fi
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
@@ -22,11 +37,11 @@ if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
|||||||
update_status () {
|
update_status () {
|
||||||
local func="${FUNCNAME[0]}"
|
local func="${FUNCNAME[0]}"
|
||||||
local json_response="$((echo -n '#M=APISM #C=REQ_ISMASParameter #J={}';
|
local json_response="$((echo -n '#M=APISM #C=REQ_ISMASParameter #J={}';
|
||||||
sleep 1) | nc localhost $APISM_DIRECT_PORT)"
|
sleep 5) | nc localhost $APISM_DIRECT_PORT)"
|
||||||
local trigger=""
|
local trigger=""
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
trigger="$(echo $json_response | jq -r .Fileupload.TRG)"
|
trigger="$(echo $json_response | jq -r .Fileupload.TRG)"
|
||||||
log_debug "$func:${LINENO}: apism_trigger=\"$trigger\""
|
log_info "$func:${LINENO}: apism_trigger=<$trigger>"
|
||||||
else
|
else
|
||||||
log_error "$func:${LINENO}: apism request failed"
|
log_error "$func:${LINENO}: apism request failed"
|
||||||
fi
|
fi
|
||||||
|
173
news_to_ismas
173
news_to_ismas
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
source ./log_helpers
|
source ./log_helpers
|
||||||
|
|
||||||
if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
if [ "${news_to_ismas_sourced:-1}" = "1" ]; then # include only once
|
||||||
|
readonly news_to_ismas_sourced=${BASH_SOURCE[0]}
|
||||||
|
|
||||||
readonly APISM_DB_PORT=7777
|
readonly APISM_DB_PORT=7777
|
||||||
readonly UPDATE_ISMAS_PROGRESS="U0010"
|
readonly UPDATE_ISMAS_PROGRESS="U0010"
|
||||||
@@ -24,43 +25,6 @@ if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
|||||||
|
|
||||||
PERCENT=1
|
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_ID\":\"0\",
|
|
||||||
\"EVENT\":\"${p[0]}\",
|
|
||||||
\"EVENTSTATE\":1,
|
|
||||||
\"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)
|
|
||||||
}
|
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
|
||||||
@@ -88,6 +52,7 @@ if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
|||||||
|
|
||||||
EXITCODE=$((EXITCODE+1))
|
EXITCODE=$((EXITCODE+1))
|
||||||
test $EXITCODE -gt 125 && EXITCODE=125
|
test $EXITCODE -gt 125 && EXITCODE=125
|
||||||
|
log_debug "${FUNCNAME[0]}:${LINENO}: EXITCODE=$EXITCODE"
|
||||||
return $EXITCODE
|
return $EXITCODE
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,6 +70,18 @@ if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
|||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
|
||||||
|
update_psa_clone_customer_repository () {
|
||||||
|
PERCENT=10
|
||||||
|
local params=("U0010" # event
|
||||||
|
$PERCENT # percent
|
||||||
|
$RC_SUCCESS # resultcode
|
||||||
|
"clone_customer_repository" # step
|
||||||
|
"git cloned $CUSTOMER_REPOSITORY_PATH" # step_result
|
||||||
|
"") # version
|
||||||
|
news_to_ismas ${params[*]}
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
update_psa_pull_customer_repository () {
|
update_psa_pull_customer_repository () {
|
||||||
PERCENT=10
|
PERCENT=10
|
||||||
@@ -130,6 +107,7 @@ if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
|||||||
|
|
||||||
EXITCODE=$((EXITCODE+1))
|
EXITCODE=$((EXITCODE+1))
|
||||||
test $EXITCODE -gt 125 && EXITCODE=125
|
test $EXITCODE -gt 125 && EXITCODE=125
|
||||||
|
log_debug "${FUNCNAME[0]}:${LINENO}: EXITCODE=$EXITCODE"
|
||||||
return $EXITCODE
|
return $EXITCODE
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,6 +123,7 @@ if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
|||||||
|
|
||||||
EXITCODE=$((EXITCODE+1))
|
EXITCODE=$((EXITCODE+1))
|
||||||
test $EXITCODE -gt 125 && EXITCODE=125
|
test $EXITCODE -gt 125 && EXITCODE=125
|
||||||
|
log_debug "${FUNCNAME[0]}:${LINENO}: EXITCODE=$EXITCODE"
|
||||||
return $EXITCODE
|
return $EXITCODE
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,6 +154,7 @@ if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
|||||||
|
|
||||||
EXITCODE=$((EXITCODE+1))
|
EXITCODE=$((EXITCODE+1))
|
||||||
test $EXITCODE -gt 125 && EXITCODE=125
|
test $EXITCODE -gt 125 && EXITCODE=125
|
||||||
|
log_debug "${FUNCNAME[0]}:${LINENO}: EXITCODE=$EXITCODE"
|
||||||
return $EXITCODE
|
return $EXITCODE
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,6 +189,7 @@ if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
|||||||
|
|
||||||
EXITCODE=$((EXITCODE+1))
|
EXITCODE=$((EXITCODE+1))
|
||||||
test $EXITCODE -gt 125 && EXITCODE=125
|
test $EXITCODE -gt 125 && EXITCODE=125
|
||||||
|
log_debug "${FUNCNAME[0]}:${LINENO}: EXITCODE=$EXITCODE"
|
||||||
return $EXITCODE
|
return $EXITCODE
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,6 +209,7 @@ if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
|||||||
|
|
||||||
EXITCODE=$((EXITCODE+1))
|
EXITCODE=$((EXITCODE+1))
|
||||||
test $EXITCODE -gt 125 && EXITCODE=125
|
test $EXITCODE -gt 125 && EXITCODE=125
|
||||||
|
log_debug "${FUNCNAME[0]}:${LINENO}: EXITCODE=$EXITCODE"
|
||||||
return $EXITCODE
|
return $EXITCODE
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,6 +230,7 @@ if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
|||||||
|
|
||||||
EXITCODE=$((EXITCODE+1))
|
EXITCODE=$((EXITCODE+1))
|
||||||
test $EXITCODE -gt 125 && EXITCODE=125
|
test $EXITCODE -gt 125 && EXITCODE=125
|
||||||
|
log_debug "${FUNCNAME[0]}:${LINENO}: EXITCODE=$EXITCODE"
|
||||||
return $EXITCODE
|
return $EXITCODE
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,6 +261,7 @@ if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
|||||||
|
|
||||||
EXITCODE=$((EXITCODE+1))
|
EXITCODE=$((EXITCODE+1))
|
||||||
test $EXITCODE -gt 125 && EXITCODE=125
|
test $EXITCODE -gt 125 && EXITCODE=125
|
||||||
|
log_debug "${FUNCNAME[0]}:${LINENO}: EXITCODE=$EXITCODE"
|
||||||
return $EXITCODE
|
return $EXITCODE
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,6 +281,7 @@ if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
|||||||
|
|
||||||
EXITCODE=$((EXITCODE+1))
|
EXITCODE=$((EXITCODE+1))
|
||||||
test $EXITCODE -gt 125 && EXITCODE=125
|
test $EXITCODE -gt 125 && EXITCODE=125
|
||||||
|
log_debug "${FUNCNAME[0]}:${LINENO}: EXITCODE=$EXITCODE"
|
||||||
return $EXITCODE
|
return $EXITCODE
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,6 +301,7 @@ if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
|||||||
|
|
||||||
EXITCODE=$((EXITCODE+1))
|
EXITCODE=$((EXITCODE+1))
|
||||||
test $EXITCODE -gt 125 && EXITCODE=125
|
test $EXITCODE -gt 125 && EXITCODE=125
|
||||||
|
log_debug "${FUNCNAME[0]}:${LINENO}: EXITCODE=$EXITCODE"
|
||||||
return $EXITCODE
|
return $EXITCODE
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,6 +321,7 @@ if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
|||||||
|
|
||||||
EXITCODE=$((EXITCODE+1))
|
EXITCODE=$((EXITCODE+1))
|
||||||
test $EXITCODE -gt 125 && EXITCODE=125
|
test $EXITCODE -gt 125 && EXITCODE=125
|
||||||
|
log_debug "${FUNCNAME[0]}:${LINENO}: EXITCODE=$EXITCODE"
|
||||||
return $EXITCODE
|
return $EXITCODE
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,4 +341,114 @@ if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
|||||||
reset_update_trigger
|
reset_update_trigger
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
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_ID\":\"0\",
|
||||||
|
\"EVENT\":\"${p[0]}\",
|
||||||
|
\"EVENTSTATE\":1,
|
||||||
|
\"PARAMETER\": {
|
||||||
|
\"PERCENT\" : ${p[1]},
|
||||||
|
\"RESULTCODE\" : ${p[2]},
|
||||||
|
\"STEP\" : \"update_psa_${p[3]}\",
|
||||||
|
\"STEP_RESULT\" : \"${p[4]}\",
|
||||||
|
\"VERSION\" : \"$VERSION\"
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
log_debug "$func:${LINENO}: data=$data"
|
||||||
|
echo $((echo "$data"; sleep 1) | nc localhost $APISM_DB_PORT)
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# send current psa setting to ismas at end of update procedure
|
||||||
|
#
|
||||||
|
current_settings_to_ismas () {
|
||||||
|
local func="${FUNCNAME[0]}"
|
||||||
|
local p=("$@")
|
||||||
|
|
||||||
|
local data="#M=APISM#C=CMD_SENDVERSION#J=
|
||||||
|
{
|
||||||
|
\"VERSION_INFO\" : {
|
||||||
|
\"CREATED\":\"$(date +%Y-%m-%dT%T)\",
|
||||||
|
\"HASH\":\"$(compute_hash)\"
|
||||||
|
},
|
||||||
|
\"TARIFF\" : {
|
||||||
|
},
|
||||||
|
\"HARDWARE\" : {
|
||||||
|
\"DEVICES\" : [
|
||||||
|
\"PTU5\", \"DC\", \"PRINTER\", \"BNA\"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
\"OS\" : {
|
||||||
|
\"$(uname)\": \"$(uname -a)\"
|
||||||
|
},
|
||||||
|
\"CONFIG\" : {
|
||||||
|
\"PTU5\" : {
|
||||||
|
\"CPU_SERIAL\" : \"$(cat /proc/cpuinfo |
|
||||||
|
grep Serial |
|
||||||
|
sed -E -e 's/.*:\s*(.*)/\1/g')\"
|
||||||
|
},
|
||||||
|
\"DC\" : {
|
||||||
|
\"VERSION\" : \"$(compute_hash ${DC_PSA_DC_FILE})\",
|
||||||
|
\"MD5SUM\" : \"\"
|
||||||
|
},
|
||||||
|
\"PRINTER\" : {
|
||||||
|
},
|
||||||
|
\"BNA\" : {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
\"SOFTWARE\": {
|
||||||
|
\"RAUC\" : \"$(rauc --version)\",
|
||||||
|
\"OPKG\" : \"$(opkg --version)\",
|
||||||
|
\"ATBQT\" : {
|
||||||
|
\"VERSION\" : \"$(/opt/app/ATBAPP/ATBQT -v |
|
||||||
|
grep Version |
|
||||||
|
sed -E -e 's/.*:\s*(.*)/\1/g')\",
|
||||||
|
\"GIT_DESCRIBE\" : \"$(/opt/app/ATBAPP/ATBQT -v |
|
||||||
|
grep git |
|
||||||
|
sed -E -e 's/.*:\s*(.*)/\1/g')\"
|
||||||
|
},
|
||||||
|
\"PLUGINS\" : {
|
||||||
|
$(get_plugins)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
|
||||||
|
log_debug "$func:${LINENO}: data=$data EXITCODE=$EXITCODE"
|
||||||
|
|
||||||
|
echo $((echo "$data"; sleep 1) | nc localhost $APISM_DB_PORT)
|
||||||
|
|
||||||
|
# if [ $EXITCODE -eq $RC_SUCCESS ]; then
|
||||||
|
update_psa_update_succeeded $UPDATE_SUCCEEDED \
|
||||||
|
$RC_SUCCESS "psa update succeeded" $VERSION
|
||||||
|
|
||||||
|
update_psa_update_succeeded $UPDATE_ACTIVATED \
|
||||||
|
$RC_SUCCESS "psa update activated" $VERSION
|
||||||
|
|
||||||
|
log_info "$func:${LINENO}: success"
|
||||||
|
# fi
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
|
572
read_config
572
read_config
@@ -2,9 +2,14 @@
|
|||||||
# set -x
|
# set -x
|
||||||
|
|
||||||
source ./log_helpers
|
source ./log_helpers
|
||||||
|
source ./general_utils
|
||||||
|
|
||||||
if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||||
readonly read_config_sourced=${BASH_SOURCE[0]}
|
readonly read_config_sourced=${BASH_SOURCE[0]}
|
||||||
|
|
||||||
|
readonly MAJOR="0"
|
||||||
|
readonly MINOR="1"
|
||||||
|
readonly PATCH="0"
|
||||||
|
|
||||||
readonly DATEFLAGS="+%Y.%m.%dT%H.%M.%S"
|
readonly DATEFLAGS="+%Y.%m.%dT%H.%M.%S"
|
||||||
readonly STRIPCOMMENTS='sed -e s/#.*$//g'
|
readonly STRIPCOMMENTS='sed -e s/#.*$//g'
|
||||||
@@ -17,73 +22,54 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
|||||||
readonly UPDATEPSABEGIN=./.updatepsa/begin
|
readonly UPDATEPSABEGIN=./.updatepsa/begin
|
||||||
readonly UPDATEPSAEND=./.updatepsa/end
|
readonly UPDATEPSAEND=./.updatepsa/end
|
||||||
|
|
||||||
readonly PROGRAM=`basename $0`
|
# name of file containing the logs following a 'git pull':
|
||||||
readonly VERSION="0.8.0"
|
# basically, there are two kinds of entries:
|
||||||
|
readonly GIT_UPDATE_LOG=/opt/app/tools/atbupdate/update_log.csv
|
||||||
|
|
||||||
|
readonly PROGRAM=`basename $0`
|
||||||
readonly WORKSPACE_DIR=workspace
|
readonly WORKSPACE_DIR=workspace
|
||||||
|
|
||||||
WORKING_DIRECTORY=${WORKING_DIRECTORY:-$UPDATEPSAHOME}
|
EXITCODE=$RC_SUCCESS
|
||||||
CONFIGFILENAME=${CONFIGFILENAME:-'update_psa.conf'}
|
INITIAL_CLONE=false
|
||||||
|
APISM_RUNNING=0
|
||||||
if ! [ -f "$CONFIGFILENAME" ]; then
|
|
||||||
log_fatal "$func:${LINENO}: $CONFIGFILENAME not found"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! [ -d "$WORKING_DIRECTORY" ]; then
|
|
||||||
log_fatal "$func:${LINENO}: $WORKING_DIRECTORY not found"
|
|
||||||
fi
|
|
||||||
|
|
||||||
EXITCODE=0
|
|
||||||
CLONE_CUSTOMER_REPOSITORY=false
|
|
||||||
|
|
||||||
# read config file (JSON syntax)
|
# read config file (JSON syntax)
|
||||||
read_config() {
|
read_config() {
|
||||||
local func="${FUNCNAME[0]}"
|
local func="${FUNCNAME[0]}"
|
||||||
|
|
||||||
|
CONFIGFILENAME=${CONFIGFILENAME:-'update_psa.conf'}
|
||||||
|
|
||||||
|
if ! [ -f "$CONFIGFILENAME" ]; then
|
||||||
|
log_fatal "$func:${LINENO}: $CONFIGFILENAME not found"
|
||||||
|
fi
|
||||||
|
|
||||||
log_debug "$func:${LINENO}: CONFIGFILENAME=$CONFIGFILENAME"
|
log_debug "$func:${LINENO}: CONFIGFILENAME=$CONFIGFILENAME"
|
||||||
log_debug "$func:${LINENO}: WORKING_DIRECTORY=$WORKING_DIRECTORY"
|
log_debug "$func:${LINENO}: WORKING_DIRECTORY=$WORKING_DIRECTORY"
|
||||||
|
|
||||||
local readonly cf="$CONFIGFILENAME"
|
local readonly cf="$CONFIGFILENAME"
|
||||||
|
|
||||||
if cd $WORKING_DIRECTORY ; then
|
|
||||||
log_debug "$func:${LINENO}: cd to $WORKING_DIRECTORY"
|
|
||||||
else
|
|
||||||
log_fatal "$func:${LINENO}: cannot cd to $WORKING_DIRECTORY"
|
|
||||||
fi
|
|
||||||
|
|
||||||
readonly GIT_SSL_NO_VERIFY="$(cat "$cf" | jq -r .GIT_SSL_NO_VERIFY)"
|
readonly GIT_SSL_NO_VERIFY="$(cat "$cf" | jq -r .GIT_SSL_NO_VERIFY)"
|
||||||
if [ -z "$GIT_SSL_NO_VERIFY" ]; then
|
assert_s GIT_SSL_NO_VERIFY
|
||||||
log_fatal "$func:${LINENO} GIT_SSL_NO_VERIFY not set in $cf"
|
|
||||||
fi
|
|
||||||
log_debug "$func:${LINENO}: GIT_SSL_NO_VERIFY=$GIT_SSL_NO_VERIFY"
|
|
||||||
log_debug "$func:${LINENO}: WORKSPACE_DIR=$WORKSPACE_DIR"
|
|
||||||
|
|
||||||
readonly CUSTOMER_LOCATION=$(cat "$cf" | jq -r .customer_location)
|
|
||||||
if [ -z "$CUSTOMER_LOCATION" ]; then
|
|
||||||
log_fatal "$func:${LINENO}: CUSTOMER_LOCATION not set in $cf"
|
|
||||||
fi
|
|
||||||
log_debug "$func:${LINENO}: customer-location=$CUSTOMER_LOCATION"
|
|
||||||
|
|
||||||
readonly CUST_ID="$(cat "$cf" | jq -r .customer_id)"
|
readonly CUSTOMER_LOCATION=$(cat "$cf" | jq -r .customer_location)
|
||||||
if [ -z "$CUST_ID" ]; then
|
assert_s CUSTOMER_LOCATION
|
||||||
log_fatal "$func:${LINENO} CUST_ID not set in $cf"
|
|
||||||
fi
|
readonly CUSTOMER_ID="$(cat "$cf" | jq -r .customer_id)"
|
||||||
readonly CUSTOMER_ID="customer_$CUST_ID"
|
assert_s CUSTOMER_ID
|
||||||
log_debug "$func:${LINENO}: CUSTOMER-ID=$CUSTOMER_ID"
|
|
||||||
|
|
||||||
local __r_path="$(cat "$cf" | jq -r .cust_repository_path)"
|
readonly CUSTOMER_REPOSITORY_PATH="$(cat "$cf" |
|
||||||
if [ -z "$__r_path" ]; then
|
jq -r .cust_repository_path)"
|
||||||
log_fatal "$func:${LINENO}: customer repository path not set in $cf"
|
assert_s CUSTOMER_REPOSITORY_PATH
|
||||||
fi
|
|
||||||
readonly CUSTOMER_REPOSITORY_PATH="${__r_path}/${CUSTOMER_ID}.git"
|
local __customer_id_base_dir="$WORKING_DIRECTORY/${WORKSPACE_DIR}"
|
||||||
log_debug "$func:${LINENO}: customer-r-path=$CUSTOMER_REPOSITORY_PATH"
|
readonly CUSTOMER_ID_BASE_DIR="${__customer_id_base_dir}/${CUSTOMER_ID}"
|
||||||
|
|
||||||
local __number_of_zone_groups=$(cat "$cf" |
|
local __number_of_zone_groups=$(cat "$cf" |
|
||||||
jq -r .zg[0] |
|
jq -r .zg[0] |
|
||||||
sed -E -e 's/[[:space:]]*//g')
|
sed -E -e 's/[[:space:]]*//g')
|
||||||
# TODO: was ist hier falsch
|
# TODO: was ist hier falsch
|
||||||
# __n_of_zgroups=$(echo "$__n_of_zgrps" | ${STRIPWHITESPACE} )
|
# __n_of_zgroups=$(echo "$__n_of_zgrps" | ${STRIPWHITESPACE} )
|
||||||
log_debug "$func:${LINENO}: #n of zone_groups: $__number_of_zone_groups"
|
# log_debug "$func:${LINENO}: #n of zone_groups: $__number_of_zone_groups"
|
||||||
|
|
||||||
local __zone_groups=($__number_of_zone_groups)
|
local __zone_groups=($__number_of_zone_groups)
|
||||||
for zg in `seq 1 $__number_of_zone_groups`; do
|
for zg in `seq 1 $__number_of_zone_groups`; do
|
||||||
@@ -94,241 +80,313 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
|||||||
done
|
done
|
||||||
|
|
||||||
readonly ZONE_GROUPS=(${__zone_groups[@]})
|
readonly ZONE_GROUPS=(${__zone_groups[@]})
|
||||||
log_debug "$func:${LINENO}: ZONE_GROUPS=${ZONE_GROUPS[@]}"
|
assert_a ZONE_GROUPS
|
||||||
|
|
||||||
log_debug "$func:${LINENO}: reading ${wd} done"
|
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
# TODO: falls mehrere gruppen/zonen auftauchen hier anpassen
|
||||||
|
# TODO
|
||||||
|
# Zone aus /etc/zone_nr auslesen
|
||||||
|
#
|
||||||
|
readonly ZONE_GROUP=1
|
||||||
|
local __zone=1
|
||||||
|
readonly ZONE_FILE="$(cat "$cf" | jq -r .zone)"
|
||||||
|
if [ -f "$ZONE_FILE" ]; then
|
||||||
|
__zone=$(cat "$ZONE_FILE")
|
||||||
|
__zone=$((__zone))
|
||||||
|
fi
|
||||||
|
|
||||||
|
readonly ZONE=$__zone
|
||||||
|
readonly LOCAL_BRANCH="$(cat "$cf" | jq -r .local_branches[$ZONE])"
|
||||||
|
|
||||||
|
if [ -z "$WORKING_DIRECTORY" ]; then
|
||||||
|
log_fatal "${func}:${LINENO}: empty WORKING_DIRECTORY"
|
||||||
|
fi
|
||||||
|
if ! cd "$WORKING_DIRECTORY"; then
|
||||||
|
log_fatal "${func}:${LINENO}: cannot cd to $WORKING_DIRECTORY"
|
||||||
|
fi
|
||||||
|
log_debug "${func}:${LINENO}: cd to $WORKING_DIRECTORY"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
###############################################################################
|
###############################################################################
|
||||||
########################## parsing with jq finished ###########################
|
########################## parsing with jq finished ###########################
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
compute_hash () {
|
||||||
|
if cd_customer_repository; then
|
||||||
|
local hash=""
|
||||||
|
if [[ -z "$1" ]]; then
|
||||||
|
hash=$(git log -n 1 --pretty=format:%H)
|
||||||
|
else
|
||||||
|
hash=$(git hash-object "$1")
|
||||||
|
fi
|
||||||
|
cd_home ; echo ${hash:0:10} # return the first 10 hex characters
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
compute_version () {
|
||||||
|
VERSION="$MAJOR.$MINOR.$PATCH+$CUSTOMER_LOCATION-$(compute_hash)"
|
||||||
|
cd_home; return 0
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
check_sanity_of_repository () {
|
check_sanity_of_repository () {
|
||||||
local func="${FUNCNAME[0]}"
|
local func="${FUNCNAME[0]}"
|
||||||
|
|
||||||
local __customer_id_base_dir="$WORKING_DIRECTORY/${WORKSPACE_DIR}"
|
if [ "$PWD" != "$WORKING_DIRECTORY" ]; then
|
||||||
readonly CUSTOMER_ID_BASE_DIR="${__customer_id_base_dir}/${CUSTOMER_ID}"
|
log_fatal "$func:${LINENO} PD != WD ($PWD != $WORKING_DIRECTORY)"
|
||||||
|
fi
|
||||||
log_debug "$func:${LINENO}: CUSTOMER_ID_BASE_DIR="
|
|
||||||
log_debug "$func:${LINENO}: $CUSTOMER_ID_BASE_DIR"
|
assert_d CUSTOMER_ID_BASE_DIR
|
||||||
|
|
||||||
CUSTOMER_LOCATION_DIR="${CUSTOMER_ID_BASE_DIR}/${CUSTOMER_LOCATION}"
|
CUSTOMER_LOCATION_DIR="$CUSTOMER_ID_BASE_DIR"
|
||||||
|
#CUSTOMER_LOCATION_DIR="${CUSTOMER_ID_BASE_DIR}/${CUSTOMER_LOCATION}"
|
||||||
log_debug "$func:${LINENO}: CUSTOMER_LOCATION_DIR="
|
#CUST_LOC_DIR=$CUSTOMER_LOCATION_DIR
|
||||||
log_debug "$func:${LINENO}: $CUSTOMER_LOCATION_DIR"
|
assert_d CUSTOMER_LOCATION_DIR
|
||||||
|
|
||||||
readonly UPDATE_CONF="${CUSTOMER_LOCATION_DIR}/update.conf"
|
|
||||||
log_debug "$func:${LINENO}: UPDATE.CONF="
|
|
||||||
log_debug "$func:${LINENO}: $UPDATE_CONF"
|
|
||||||
|
|
||||||
# readonly zone_groups=(${__zone_groups[@]})
|
# readonly zone_groups=(${__zone_groups[@]})
|
||||||
# by now (03.03.2023) there is only one zone group.
|
# by now (03.03.2023) there is only one zone group.
|
||||||
readonly local __zgroup=1
|
#readonly local __zgroup=1
|
||||||
local __number_of_zone_groups=${ZONE_GROUPS[0]}
|
#local __number_of_zone_groups=${ZONE_GROUPS[0]}
|
||||||
local __zindex=1
|
#local __zindex=1
|
||||||
local __customer_base_dirs=("placeholder")
|
#local __customer_base_dirs=("placeholder")
|
||||||
for __zg in `seq 1 $__number_of_zone_groups`; do
|
#for __zg in `seq 1 $__number_of_zone_groups`; do
|
||||||
local __n_of_zones=${ZONE_GROUPS[$__zindex]}
|
# local __n_of_zones=${ZONE_GROUPS[$__zindex]}
|
||||||
log_debug "$func:${LINENO}: zgroup $__zg has $__n_of_zones zones"
|
# log_debug "$func:${LINENO}: zgroup $__zg has $__n_of_zones zones"
|
||||||
for (( j=1; j<=$__n_of_zones; ++j)); do
|
# for (( j=1; j<=$__n_of_zones; ++j)); do
|
||||||
__customer_base_dirs+=("${CUSTOMER_LOCATION_DIR}/$__zgroup/$j")
|
# __customer_base_dirs+=("${CUSTOMER_LOCATION_DIR}/$__zgroup/$j")
|
||||||
log_debug "$func:${LINENO}: zone $j"
|
# log_debug "$func:${LINENO}: zone $j"
|
||||||
((++__zindex))
|
# ((++__zindex))
|
||||||
done
|
# done
|
||||||
done
|
#done
|
||||||
|
|
||||||
readonly CUSTOMER_BASE_DIRS=(${__customer_base_dirs[@]})
|
# for szeged:
|
||||||
|
# placeholder
|
||||||
if [ ${#CUSTOMER_BASE_DIRS[@]} -eq 0 ]; then
|
# /home/root/szeged/UpdateController/workspace/customer_281/szeged/1/1
|
||||||
log_fatal "$func:${LINENO}: CUSTOMER_BASE_DIRS empty"
|
# /home/root/szeged/UpdateController/workspace/customer_281/szeged/1/2
|
||||||
fi
|
# /home/root/szeged/UpdateController/workspace/customer_281/szeged/1/3
|
||||||
|
# readonly CUST_BASE_DIRS=(${__customer_base_dirs[@]})
|
||||||
# TODO
|
# assert_a CUST_BASE_DIRS
|
||||||
# TODO: falls mehrere gruppen/zonen auftauchen hier anpassen
|
|
||||||
# TODO
|
|
||||||
readonly local __zone=1
|
|
||||||
readonly CUSTOMER_BASE_DIR="${CUSTOMER_BASE_DIRS[$__zone]}"
|
|
||||||
if [ -d "$CUSTOMER_BASE_DIR" ]; then
|
|
||||||
log_debug "$func:${LINENO}: CUSTOMER-BASE-DIR="
|
|
||||||
log_debug "$func:${LINENO}: $CUSTOMER_BASE_DIR"
|
|
||||||
else
|
|
||||||
log_fatal "$func:${LINENO}: $CUSTOMER_BASE_DIR does not exist"
|
|
||||||
fi
|
|
||||||
|
|
||||||
readonly psa_config_dir="${CUSTOMER_BASE_DIR}/etc/psa_config"
|
readonly CUST_BASE_DIR="$CUSTOMER_ID_BASE_DIR"
|
||||||
if [ -d "$psa_config_dir" ]; then
|
#readonly CUST_BASE_DIR="${CUST_BASE_DIRS[$ZONE]}"
|
||||||
log_debug "$func:${LINENO}: psa_config_dir="
|
#assert_d CUST_BASE_DIR
|
||||||
log_debug "$func:${LINENO}: $psa_config_dir"
|
|
||||||
else
|
readonly ETC_SYS_DIR="/etc"
|
||||||
log_fatal "$func:${LINENO}: $psa_config_dir does not exist"
|
readonly ATB_SYS_DIR="/etc/atb"
|
||||||
fi
|
readonly DC_SYS_DIR="/etc/dc"
|
||||||
|
readonly TARIFF_SYS_DIR="/etc/psa_tariff"
|
||||||
readonly psa_update_dir="${CUSTOMER_BASE_DIR}/etc/psa_update"
|
readonly OPKG_SYS_DIR="/etc/psa_update"
|
||||||
if [ -d "$psa_update_dir" ]; then
|
readonly CONF_SYS_DIR="/etc/psa_config"
|
||||||
log_debug "$func:${LINENO}: psa_update_dir="
|
readonly OPT_SYS_DIR="/opt"
|
||||||
log_debug "$func:${LINENO}: $psa_update_dir"
|
readonly APP_SYS_DIR="/opt/app"
|
||||||
else
|
readonly SYSCONFIG_SYS_DIR="/opt/app/sysconfig"
|
||||||
log_fatal "$func:${LINENO}: $psa_update_dir does not exist"
|
readonly ATBAPP_SYS_DIR="/opt/app/ATBAPP"
|
||||||
fi
|
readonly ISMASMGR_SYS_DIR="/opt/app/ISMASMgr"
|
||||||
|
|
||||||
readonly psa_base_ini_dir="${CUSTOMER_BASE_DIR}/opt/app"
|
|
||||||
if [ -d "$psa_base_ini_dir" ]; then
|
|
||||||
log_debug "$func:${LINENO}: psa_base_ini_dir="
|
|
||||||
log_debug "$func:${LINENO}: $psa_base_ini_dir"
|
|
||||||
else
|
|
||||||
log_fatal "$func:${LINENO}: $psa_base_ini_dir does not exist"
|
|
||||||
fi
|
|
||||||
|
|
||||||
readonly SYSCONFIG_SYS_DIR="/opt/app/sysconfig"
|
readonly ETC_PSA_DIR=${CUST_BASE_DIR}${ETC_SYS_DIR}
|
||||||
readonly PSA_SYSCONFIG_DIR="$CUSTOMER_BASE_DIR$SYSCONFIG_SYS_DIR"
|
readonly ATB_PSA_DIR=${CUST_BASE_DIR}${ATB_SYS_DIR}
|
||||||
# if [ -d "$psa_syconfig_dir" ]; DOES NOT WORK !!!
|
readonly DC_PSA_DIR=${CUST_BASE_DIR}${DC_SYS_DIR}
|
||||||
if ls -al $PSA_SYSCONFIG_DIR > /dev/null; then
|
readonly TARIFF_PSA_DIR=${CUST_BASE_DIR}${TARIFF_SYS_DIR}
|
||||||
log_debug "$func:${LINENO}: PSA_SYSCONFIG_DIR="
|
readonly OPKG_PSA_DIR=${CUST_BASE_DIR}${OPKG_SYS_DIR}
|
||||||
log_debug "$func:${LINENO}: $PSA_SYSCONFIG_DIR"
|
readonly CONF_PSA_DIR=${CUST_BASE_DIR}${CONF_SYS_DIR}
|
||||||
else
|
readonly OPT_PSA_DIR=${CUST_BASE_DIR}${OPT_SYS_DIR}
|
||||||
log_error "$func:${LINENO}: $PSA_SYSCONFIG_DIR does not exist"
|
readonly APP_PSA_DIR=${CUST_BASE_DIR}${APP_SYS_DIR}
|
||||||
fi
|
readonly ATBAPP_PSA_DIR=${CUST_BASE_DIR}${ATBAPP_SYS_DIR}
|
||||||
|
readonly SYSCONFIG_PSA_DIR=${CUST_BASE_DIR}${SYSCONFIG_SYS_DIR}
|
||||||
readonly psa_ismasmgr_dir="${psa_base_ini_dir}/ISMASMgr"
|
readonly ISMASMGR_PSA_DIR=${CUST_BASE_DIR}${ISMASMGR_SYS_DIR}
|
||||||
if [ -d "$psa_ismasmgr_dir" ]; then
|
|
||||||
log_debug "$func:${LINENO}: psa_ismasmgr_dir="
|
|
||||||
log_debug "$func:${LINENO}: $psa_ismasmgr_dir"
|
|
||||||
else
|
|
||||||
log_fatal "$func:${LINENO}: $psa_ismasmgr_dir does not exist"
|
|
||||||
fi
|
|
||||||
|
|
||||||
readonly CONF_SYS_DIR="/etc/psa_config"
|
|
||||||
readonly OPKG_SYS_DIR="/etc/psa_update"
|
|
||||||
readonly ATBAPP_SYS_DIR="/opt/app/ATBAPP"
|
|
||||||
|
|
||||||
readonly psa_atbqt_dir="$CUSTOMER_BASE_DIR$ATBAPP_SYS_DIR"
|
readonly ATBQT_BIN="ATBQT"
|
||||||
if [ -d "$psa_atbqt_dir" ]; then
|
readonly ATBQT_INI="ATBQT.ini"
|
||||||
log_debug "$func:${LINENO}: psa_atbqt_dir="
|
readonly ISMASMGR_INI="ISMASMgr.ini"
|
||||||
log_debug "$func:${LINENO}: $psa_atbqt_dir"
|
readonly SYSCONF_INI="sysconfig.ini"
|
||||||
else
|
readonly SYSCTRL_INI="SystemControl.ini"
|
||||||
log_fatal "$func:${LINENO}: $psa_atbqt_dir does not exist"
|
readonly DC="dc2c.bin"
|
||||||
fi
|
|
||||||
|
|
||||||
readonly ATBQT_INI="ATBQT.ini"
|
|
||||||
readonly ATBQT_INI_FULL="${psa_atbqt_dir}/$ATBQT_INI"
|
|
||||||
if [ -f "$ATBQT_INI_FULL" ]; then
|
|
||||||
log_debug "$func:${LINENO}: ATBTQT.ini="
|
|
||||||
log_debug "$func:${LINENO}: $ATBQT_INI_FULL"
|
|
||||||
else
|
|
||||||
log_fatal "$func:${LINENO}: $ATBQT_INI_FULL does not exist"
|
|
||||||
fi
|
|
||||||
|
|
||||||
readonly ISMASMGR_INI="ISMASMgr.ini"
|
|
||||||
readonly ISMASMGR_SYS_DIR="/opt/app/ISMASMgr"
|
|
||||||
|
|
||||||
readonly ISMASMGR_ISMASMGR_INI_FULL="${psa_ismasmgr_dir}/$ISMASMGR_INI"
|
|
||||||
if [ -f "$ISMASMGR_ISMASMGR_INI_FULL" ]; then
|
|
||||||
log_debug "$func:${LINENO}: ismasmgr_ismasmgr.ini="
|
|
||||||
log_debug "$func:${LINENO}: $ISMASMGR_ISMASMGR_INI_FULL"
|
|
||||||
else
|
|
||||||
log_fatal "$func:${LINENO}: $ISMASMGR_ISMASMGR_INI_FULL "\
|
|
||||||
"does not exist"
|
|
||||||
fi
|
|
||||||
|
|
||||||
readonly SYSCONFIG_ISMASMGR_INI_FULL="${PSA_SYSCONFIG_DIR}/ISMASMgr.ini"
|
|
||||||
if [ -f "$SYSCONFIG_ISMASMGR_INI_FULL" ]; then
|
|
||||||
log_debug "$func:${LINENO}: sysconfig_ismasmgr.ini="
|
|
||||||
log_debug "$func:${LINENO}: $SYSCONFIG_ISMASMGR_INI_FULL"
|
|
||||||
else
|
|
||||||
log_fatal "$func:${LINENO}: $SYSCONFIG_ISMASMGR_INI_FULL "\
|
|
||||||
"does not exist"
|
|
||||||
fi
|
|
||||||
|
|
||||||
readonly SYS_CONFIG_INI="sysconfig.ini"
|
|
||||||
readonly __sysc_sysc_full="${PSA_SYSCONFIG_DIR}/$SYS_CONFIG_INI"
|
|
||||||
readonly SYSCONFIG_SYSCONFIG_INI_FULL="$__sysc_sysc_full"
|
|
||||||
if [ -f "$SYSCONFIG_SYSCONFIG_INI_FULL" ]; then
|
|
||||||
log_debug "$func:${LINENO}: sysconfig_sysconfig.ini="
|
|
||||||
log_debug "$func:${LINENO}: $SYSCONFIG_SYSCONFIG_INI_FULL"
|
|
||||||
else
|
|
||||||
log_fatal "$func:${LINENO}: "\
|
|
||||||
"$SYSCONFIG_SYSCONFIG_INI_FULL does not exist"
|
|
||||||
fi
|
|
||||||
|
|
||||||
readonly "SYSTEM_CONTROL_INI"="SystemControl.ini"
|
|
||||||
local __sysctrl_ini_full="${PSA_SYSCONFIG_DIR}/$SYSTEM_CONTROL_INI"
|
|
||||||
readonly SYSCONFIG_SYSCTRL_INI_FULL="$__sysctrl_ini_full"
|
|
||||||
if [ -f "$SYSCONFIG_SYSCTRL_INI_FULL" ]; then
|
|
||||||
log_debug "$func:${LINENO}: sysconfig_systemcontrol.ini="
|
|
||||||
log_debug "$func:${LINENO}: $SYSCONFIG_SYSCTRL_INI_FULL"
|
|
||||||
else
|
|
||||||
log_fatal "$func:${LINENO}: $SYSCONFIG_SYSCTRL_INI_FULL does not exist"
|
|
||||||
fi
|
|
||||||
|
|
||||||
readonly DC2C_SERIAL_JSON="${psa_config_dir}/DC2C_serial.json"
|
|
||||||
if [ -f "$DC2C_SERIAL_JSON" ]; then
|
|
||||||
log_debug "$func:${LINENO}: DC2C_SERIAL_JSON="
|
|
||||||
log_debug "$func:${LINENO}: $DC2C_SERIAL_JSON"
|
|
||||||
else
|
|
||||||
log_fatal "$func:${LINENO}: $DC2C_SERIAL_JSON does not exist"
|
|
||||||
fi
|
|
||||||
|
|
||||||
readonly DC2C_CASH_JSON="${psa_config_dir}/DC2C_cash.json"
|
|
||||||
if [ -f "$DC2C_CASH_JSON" ]; then
|
|
||||||
log_debug "$func:${LINENO}: DC2C_CASH_JSON="
|
|
||||||
log_debug "$func:${LINENO}: $DC2C_CASH_JSON"
|
|
||||||
else
|
|
||||||
log_debug "$func:${LINENO}: $DC2C_CASH_JSON does not exist"
|
|
||||||
fi
|
|
||||||
|
|
||||||
readonly DC2C_CONF_JSON="${psa_config_dir}/DC2C_conf.json"
|
readonly DC_SYS_DC_FILE="${DC_SYS_DIR}/$DC"
|
||||||
if [ -f "$DC2C_CONF_JSON" ]; then
|
readonly ATBQT_ATB_SYS_BIN_FILE="${ATBAPP_SYS_DIR}/$ATBQT_BIN"
|
||||||
log_debug "$func:${LINENO}: DC2C_CONF_JSON="
|
readonly ATBQT_ATB_SYS_INI_FILE="${ATB_SYS_DIR}/$ATBQT_INI"
|
||||||
log_debug "$func:${LINENO}: $DC2C_CONF_JSON"
|
readonly ATBQT_APP_SYS_INI_FILE="${ATBAPP_SYS_DIR}/$ATBQT_INI"
|
||||||
else
|
readonly ATBQT_ETC_SYS_INI_FILE="${ETC_SYS_DIR}/$ATBQT_INI"
|
||||||
log_fatal "$func:${LINENO}: $DC2C_CONF_JSON does not exist"
|
readonly ISMASMGRATB_SYS_INI_FILE="${ATB_SYS_DIR}/$ISMASMGR_INI"
|
||||||
fi
|
readonly ISMASMGRAPP_SYS_INI_FILE="${ISMASMGR_SYS_DIR}/$ISMASMGR_INI"
|
||||||
|
readonly ISMASMGRETC_SYS_INI_FILE="${ETC_SYS_DIR}/$ISMASMGR_INI"
|
||||||
|
readonly ISMASMGRSCF_SYS_INI_FILE="${SYSCONFIG_SYS_DIR}/$ISMASMGR_INI"
|
||||||
|
readonly SYSCONF_ETC_SYS_INI_FILE="${ETC_SYS_DIR}/$SYSCONF_INI"
|
||||||
|
readonly SYSCONF_ATB_SYS_INI_FILE="${ATB_SYS_DIR}/$SYSCONF_INI"
|
||||||
|
readonly SYSCONF_SCF_SYS_INI_FILE="${SYSCONFIG_SYS_DIR}/$SYSCONF_INI"
|
||||||
|
readonly SYSCTRL_ETC_SYS_INI_FILE="${ETC_SYS_DIR}/$SYSCTRL_INI"
|
||||||
|
readonly SYSCTRL_ATB_SYS_INI_FILE="${ATB_SYS_DIR}/$SYSCTRL_INI"
|
||||||
|
readonly SYSCTRL_SCF_SYS_INI_FILE="${SYSCONFIG_SYS_DIR}/$SYSCTRL_INI"
|
||||||
|
# readonly ZONE_FILE="$ETC_SYS_DIR/zone_nr"
|
||||||
|
readonly CUST_ID_FILE="$ETC_SYS_DIR/cust_nr"
|
||||||
|
readonly OPKG_CMDS_SYS_FILE="${OPKG_SYS_DIR}/opkg_commands"
|
||||||
|
readonly DC2C_SYS_SERIAL_JSON="${CONF_SYS_DIR}/DC2C_serial.json"
|
||||||
|
readonly DC2C_SYS_CASH_JSON="${CONF_SYS_DIR}/DC2C_cash.json"
|
||||||
|
readonly DC2C_SYS_CONF_JSON="${CONF_SYS_DIR}/DC2C_conf.json"
|
||||||
|
readonly DC_PSA_DC_FILE="${DC_PSA_DIR}/$DC"
|
||||||
|
|
||||||
|
readonly ATBQT_ATB_PSA_INI_FILE="${ATB_PSA_DIR}/$ATBQT_INI"
|
||||||
|
readonly ATBQT_APP_PSA_INI_FILE="${ATBAPP_PSA_DIR}/$ATBQT_INI"
|
||||||
|
readonly ATBQT_ETC_PSA_INI_FILE="${ETC_PSA_DIR}/$ATBQT_INI"
|
||||||
|
readonly ISMASMGRATB_PSA_INI_FILE="${ATB_PSA_DIR}/$ISMASMGR_INI"
|
||||||
|
readonly ISMASMGRAPP_PSA_INI_FILE="${ISMASMGR_PSA_DIR}/$ISMASMGR_INI"
|
||||||
|
readonly ISMASMGRETC_PSA_INI_FILE="${ETC_PSA_DIR}/$ISMASMGR_INI"
|
||||||
|
readonly ISMASMGRSCF_PSA_INI_FILE="${SYSCONFIG_PSA_DIR}/$ISMASMGR_INI"
|
||||||
|
readonly SYSCONF_ETC_PSA_INI_FILE="${ETC_PSA_DIR}/$SYSCONF_INI"
|
||||||
|
readonly SYSCONF_ATB_PSA_INI_FILE="${ATB_PSA_DIR}/$SYSCONF_INI"
|
||||||
|
readonly SYSCONF_SCF_PSA_INI_FILE="${SYSCONFIG_PSA_DIR}/$SYSCONF_INI"
|
||||||
|
readonly SYSCTRL_ETC_PSA_INI_FILE="${ETC_PSA_DIR}/$SYSCTRL_INI"
|
||||||
|
readonly SYSCTRL_ATB_PSA_INI_FILE="${ATB_PSA_DIR}/$SYSCTRL_INI"
|
||||||
|
readonly SYSCTRL_SCF_PSA_INI_FILE="${SYSCONFIG_PSA_DIR}/$SYSCTRL_INI"
|
||||||
|
readonly OPKG_CMDS_PSA_FILE="${OPKG_PSA_DIR}/opkg_commands"
|
||||||
|
# readonly PSA_UPDATE_CONF="${CUSTOMER_LOCATION_DIR}/update.conf"
|
||||||
|
readonly DC2C_PSA_SERIAL_JSON="${CONF_PSA_DIR}/DC2C_serial.json"
|
||||||
|
readonly DC2C_PSA_CASH_JSON="${CONF_PSA_DIR}/DC2C_cash.json"
|
||||||
|
readonly DC2C_PSA_CONF_JSON="${CONF_PSA_DIR}/DC2C_conf.json"
|
||||||
|
|
||||||
|
assert_d ETC_SYS_DIR
|
||||||
|
assert_d ATB_SYS_DIR
|
||||||
|
assert_d DC_SYS_DIR
|
||||||
|
assert_d TARIFF_SYS_DIR
|
||||||
|
assert_d OPKG_SYS_DIR
|
||||||
|
assert_d CONF_SYS_DIR
|
||||||
|
assert_d OPT_SYS_DIR
|
||||||
|
assert_d APP_SYS_DIR
|
||||||
|
assert_d ATBAPP_SYS_DIR
|
||||||
|
assert_d SYSCONFIG_SYS_DIR
|
||||||
|
assert_d ISMASMGR_SYS_DIR
|
||||||
|
|
||||||
|
assert_d ETC_PSA_DIR
|
||||||
|
assert_d ATB_PSA_DIR
|
||||||
|
assert_d DC_PSA_DIR
|
||||||
|
assert_d TARIFF_PSA_DIR
|
||||||
|
assert_d OPKG_PSA_DIR
|
||||||
|
assert_d CONF_PSA_DIR
|
||||||
|
assert_d OPT_PSA_DIR
|
||||||
|
assert_d APP_PSA_DIR
|
||||||
|
assert_d ATBAPP_PSA_DIR
|
||||||
|
assert_d SYSCONFIG_PSA_DIR
|
||||||
|
assert_d ISMASMGR_PSA_DIR
|
||||||
|
|
||||||
|
assert_f DC_SYS_DC_FILE
|
||||||
|
assert_f ZONE_FILE
|
||||||
|
assert_f CUST_ID_FILE
|
||||||
|
assert_f ATBQT_ATB_SYS_BIN_FILE
|
||||||
|
assert_f ATBQT_ATB_SYS_INI_FILE
|
||||||
|
assert_f ATBQT_APP_SYS_INI_FILE
|
||||||
|
assert_f ATBQT_ETC_SYS_INI_FILE
|
||||||
|
assert_f ISMASMGRATB_SYS_INI_FILE
|
||||||
|
assert_f ISMASMGRAPP_SYS_INI_FILE
|
||||||
|
assert_f ISMASMGRETC_SYS_INI_FILE
|
||||||
|
assert_f ISMASMGRSCF_SYS_INI_FILE
|
||||||
|
assert_f SYSCONF_ETC_SYS_INI_FILE
|
||||||
|
assert_f SYSCONF_ATB_SYS_INI_FILE
|
||||||
|
assert_f SYSCONF_SCF_SYS_INI_FILE
|
||||||
|
assert_f SYSCTRL_ETC_SYS_INI_FILE
|
||||||
|
assert_f SYSCTRL_ATB_SYS_INI_FILE
|
||||||
|
assert_f SYSCTRL_SCF_SYS_INI_FILE
|
||||||
|
assert_f OPKG_CMDS_SYS_FILE
|
||||||
|
assert_f DC2C_SYS_CONF_JSON
|
||||||
|
assert_f DC2C_SYS_SERIAL_JSON
|
||||||
|
assert_f DC2C_SYS_CASH_JSON
|
||||||
|
|
||||||
|
assert_f DC_PSA_DC_FILE
|
||||||
|
assert_f ATBQT_ATB_PSA_INI_FILE
|
||||||
|
assert_f ATBQT_APP_PSA_INI_FILE
|
||||||
|
assert_f ATBQT_ETC_PSA_INI_FILE
|
||||||
|
assert_f ISMASMGRATB_PSA_INI_FILE
|
||||||
|
assert_f ISMASMGRAPP_PSA_INI_FILE
|
||||||
|
assert_f ISMASMGRETC_PSA_INI_FILE
|
||||||
|
assert_f ISMASMGRSCF_PSA_INI_FILE
|
||||||
|
assert_f SYSCONF_ETC_PSA_INI_FILE
|
||||||
|
assert_f SYSCONF_ATB_PSA_INI_FILE
|
||||||
|
assert_f SYSCONF_SCF_PSA_INI_FILE
|
||||||
|
assert_f SYSCTRL_ETC_PSA_INI_FILE
|
||||||
|
assert_f SYSCTRL_ATB_PSA_INI_FILE
|
||||||
|
assert_f SYSCTRL_SCF_PSA_INI_FILE
|
||||||
|
# assert_f PSA_UPDATE_CONF
|
||||||
|
assert_f OPKG_CMDS_PSA_FILE
|
||||||
|
assert_f DC2C_PSA_CONF_JSON
|
||||||
|
assert_f DC2C_PSA_SERIAL_JSON
|
||||||
|
assert_f DC2C_PSA_CASH_JSON
|
||||||
|
assert_f OPKG_CMDS_PSA_FILE
|
||||||
|
|
||||||
|
readonly KNOWN_SYS_DIRS=($ETC_SYS_DIR
|
||||||
|
$ATB_SYS_DIR
|
||||||
|
$DC_SYS_DIR
|
||||||
|
$TARIFF_SYS_DIR
|
||||||
|
$OPKG_SYS_DIR
|
||||||
|
$CONF_SYS_DIR
|
||||||
|
$OPT_SYS_DIR
|
||||||
|
$APP_SYS_DIR
|
||||||
|
$ATBAPP_SYS_DIR
|
||||||
|
$SYSCONFIG_SYS_DIR)
|
||||||
|
|
||||||
|
readonly KNOWN_PSA_DIRS=($ETC_PSA_DIR
|
||||||
|
$ATB_PSA_DIR
|
||||||
|
$DC_PSA_DIR
|
||||||
|
$TARIFF_PSA_DIR
|
||||||
|
$OPKG_PSA_DIR
|
||||||
|
$CONF_PSA_DIR
|
||||||
|
$OPT_PSA_DIR
|
||||||
|
$APP_PSA_DIR
|
||||||
|
$ATBAPP_PSA_DIR
|
||||||
|
$SYSCONFIG_PSA_DIR)
|
||||||
|
|
||||||
local DC2C_PRINT_JSON=()
|
local DC2C_PRINT_JSON=()
|
||||||
for i in {1..32}; do # up to 32 print-json-files
|
for i in {1..32}; do # up to 32 print-json-files
|
||||||
local __f=${psa_config_dir}/DC2C_print$(printf "%02d" $i).json
|
local __f=${CONF_PSA_DIR}/DC2C_print$(printf "%02d" $i).json
|
||||||
readonly DC2C_PRINT$(printf "%02d" $i)_JSON=$__f
|
readonly DC2C_PRINT$(printf "%02d" $i)_JSON=$__f
|
||||||
# local __g=$(eval echo '$'DC2C_PRINT$(printf "%02d" $i)_JSON)
|
assert_f DC2C_PRINT$(printf "%02d" $i)_JSON
|
||||||
if [ -f $__f ]; then
|
DC2C_PRINT_JSON+=($__f)
|
||||||
log_debug "$func:${LINENO}: DC2C_PRINT$(printf "%02d" $i)_JSON="
|
|
||||||
log_debug "$func:${LINENO}: $__f"
|
|
||||||
else
|
|
||||||
log_fatal "$func:${LINENO}: $__f does not exist"
|
|
||||||
fi
|
|
||||||
DC2C_PRINT_JSON+=($__f)
|
|
||||||
done
|
done
|
||||||
|
|
||||||
readonly opkg_cmds_file="${psa_update_dir}/opkg_commands"
|
|
||||||
if [ -f "$opkg_cmds_file" ]; then
|
|
||||||
log_debug "$func:${LINENO}: opkg_commands="
|
|
||||||
log_debug "$func:${LINENO}: $opkg_cmds_file"
|
|
||||||
else
|
|
||||||
log_fatal "$func:${LINENO}: $opkg_cmds_file does not exist"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# TODO: anpassen, da z.B. fuer szeged mehrere zonen vorhanden sind
|
|
||||||
readonly KNOWN_CONF_FILES=(${CUSTOMER_LOCATION}/update.conf \
|
|
||||||
${DC2C_PRINT_JSON[@]##*${CUSTOMER_ID}/} \
|
|
||||||
${DC2C_CONF_JSON##*${CUSTOMER_ID}/} \
|
|
||||||
${DC2C_CASH_JSON##*${CUSTOMER_ID}/} \
|
|
||||||
${DC2C_SERIAL_JSON##*${CUSTOMER_ID}/})
|
|
||||||
|
|
||||||
readonly KNOWN_INI_FILES=(${ATBQT_INI_FULL##*${CUSTOMER_ID}/} \
|
|
||||||
${ISMASMGR_ISMASMGR_INI_FULL##*${CUSTOMER_ID}/} \
|
|
||||||
${SYSCONFIG_ISMASMGR_INI_FULL##*${CUSTOMER_ID}/} \
|
|
||||||
${SYSCONFIG_SYSCONFIG_INI_FULL##*${CUSTOMER_ID}/} \
|
|
||||||
${SYSCONFIG_SYSCTRL_INI_FULL##*${CUSTOMER_ID}/})
|
|
||||||
|
|
||||||
readonly KNOWN_FILES=(${KNOWN_CONF_FILES[@]} \
|
local TARIFF_FILES_JSON=()
|
||||||
${KNOWN_INI_FILES[@]} \
|
for i in {1..32}; do # up to 32 tariff-json-files
|
||||||
${opkg_cmds_file##*${CUSTOMER_ID}/})
|
local __f=${TARIFF_PSA_DIR}/tariff$(printf "%02d" $i).json
|
||||||
|
readonly TARIFF$(printf "%02d" $i)_JSON=$__f
|
||||||
log_debug "$func:${LINENO}: known conf/ini_files ->"
|
assert_f TARIFF$(printf "%02d" $i)_JSON
|
||||||
for (( i=0; i < ${#KNOWN_FILES[@]}; ++i )); do
|
TARIFF_FILES_JSON+=($__f)
|
||||||
tab=$'\t'
|
|
||||||
log_debug "$func:${LINENO}: $tab$tab ${KNOWN_FILES[$i]}"
|
|
||||||
done
|
done
|
||||||
log_debug "$func:${LINENO}: sanity of ${CUSTOMER_REPOSITORY_PATH} OK"
|
|
||||||
|
readonly KNOWN_CONF_FILES=(${DC2C_PRINT_JSON[@]##*${CUSTOMER_ID}/} \
|
||||||
|
${DC2C_PSA_CONF_JSON##*${CUSTOMER_ID}/} \
|
||||||
|
${DC2C_PSA_CASH_JSON##*${CUSTOMER_ID}/} \
|
||||||
|
${DC2C_PSA_SERIAL_JSON##*${CUSTOMER_ID}/})
|
||||||
|
|
||||||
|
readonly KNOWN_TARIFF_FILES=(${TARIFF_FILES_JSON[@]##*${CUSTOMER_ID}/})
|
||||||
|
|
||||||
|
readonly KNOWN_INI_FILES=(${ATBAPP_PSA_INI_FILE##*${CUSTOMER_ID}/} \
|
||||||
|
${ISMASMGRATB_PSA_INI_FILE##*${CUSTOMER_ID}/} \
|
||||||
|
${ISMASMGRAPP_PSA_INI_FILE##*${CUSTOMER_ID}/} \
|
||||||
|
${ISMASMGRETC_PSA_INI_FILE##*${CUSTOMER_ID}/} \
|
||||||
|
${ISMASMGRSCF_PSA_INI_FILE##*${CUSTOMER_ID}/} \
|
||||||
|
${SYSCONF_ETC_PSA_INI_FILE##*${CUSTOMER_ID}/} \
|
||||||
|
${SYSCONF_ATB_PSA_INI_FILE##*${CUSTOMER_ID}/} \
|
||||||
|
${SYSCONF_SCF_PSA_INI_FILE##*${CUSTOMER_ID}/} \
|
||||||
|
${SYSCTRL_ETC_PSA_INI_FILE##*${CUSTOMER_ID}/} \
|
||||||
|
${SYSCTRL_ATB_PSA_INI_FILE##*${CUSTOMER_ID}/} \
|
||||||
|
${SYSCTRL_SCF_PSA_INI_FILE##*${CUSTOMER_ID}/} \
|
||||||
|
${ATBQT_ATB_PSA_INI_FILE##*${CUSTOMER_ID}/} \
|
||||||
|
${ATBQT_APP_PSA_INI_FILE##*${CUSTOMER_ID}/} \
|
||||||
|
${ATBQT_ETC_PSA_INI_FILE##*${CUSTOMER_ID}/})
|
||||||
|
|
||||||
|
readonly KNOWN_FILES=(${KNOWN_CONF_FILES[@]} \
|
||||||
|
${KNOWN_INI_FILES[@]} \
|
||||||
|
${KNOWN_TARIFF_FILES[@]} \
|
||||||
|
${DC_PSA_DC_FILE##*${CUSTOMER_ID}/} \
|
||||||
|
${OPKG_CMDS_PSA_FILE##*${CUSTOMER_ID}/})
|
||||||
|
|
||||||
|
# log_debug "known json/ini/hex_files ->"
|
||||||
|
# for (( i=0; i < ${#KNOWN_FILES[@]}; ++i )); do
|
||||||
|
# tab=$'\t'
|
||||||
|
# log_debug "$tab$tab ${KNOWN_FILES[$i]}"
|
||||||
|
# done
|
||||||
|
log_debug "sanity of ${CUSTOMER_REPOSITORY_PATH} OK"
|
||||||
|
|
||||||
|
# compute version string for current (i.e. previous) version
|
||||||
|
compute_version
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
57
update_psa
57
update_psa
@@ -5,6 +5,7 @@
|
|||||||
# UPDATE PSA
|
# UPDATE PSA
|
||||||
# Usage:
|
# Usage:
|
||||||
# update_psa [ --? ]
|
# update_psa [ --? ]
|
||||||
|
# [ -m ]
|
||||||
# [ --help ]
|
# [ --help ]
|
||||||
# [ --wdir "working_directory" ]
|
# [ --wdir "working_directory" ]
|
||||||
# [ --file "config_file" ]
|
# [ --file "config_file" ]
|
||||||
@@ -14,25 +15,39 @@
|
|||||||
# ./update_psa --file $PWD/update_psa.conf --wdir $PWD
|
# ./update_psa --file $PWD/update_psa.conf --wdir $PWD
|
||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
if [ $# -eq 0 ]; then
|
# if [ $# -eq 0 ]; then
|
||||||
# no parameters given -> nothing to do
|
# no parameters given -> nothing to do
|
||||||
exit 0
|
# exit 0
|
||||||
fi
|
#fi
|
||||||
|
|
||||||
if [ -z $IFS ]; then
|
if [ -z $IFS ]; then
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
MAINTENANCE="NO"
|
||||||
|
WORKING_DIRECTORY=${PWD}
|
||||||
|
|
||||||
# parse commandline parameters
|
# parse commandline parameters
|
||||||
while test $# -gt 0; do
|
while test $# -gt 0; do
|
||||||
case $1 in
|
case $1 in
|
||||||
|
--maintenance | -m )
|
||||||
|
MAINTENANCE="YES"
|
||||||
|
;;
|
||||||
--file | --fil | --fi | --f | -file | -fil | -fi | -f )
|
--file | --fil | --fi | --f | -file | -fil | -fi | -f )
|
||||||
shift
|
shift
|
||||||
CONFIGFILENAME="$1"
|
CONFIGFILENAME="$1"
|
||||||
;;
|
;;
|
||||||
|
--zone | --zon | --zo | --z | -zone | -zon | -zo | -z )
|
||||||
|
shift
|
||||||
|
ZONE="$1"
|
||||||
|
;;
|
||||||
--wdir | --wdi | --wd | --w | -wdir | -wdi | -wd | -w )
|
--wdir | --wdi | --wd | --w | -wdir | -wdi | -wd | -w )
|
||||||
shift
|
shift
|
||||||
WORKING_DIRECTORY="$1"
|
if [ "$1" = "." ]; then
|
||||||
|
WORKING_DIRECTORY="$PWD"
|
||||||
|
else
|
||||||
|
WORKING_DIRECTORY="$1"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
--help | -hel | --he | --h | '--?' | -help | -hel | -he | -h | '-?' )
|
--help | -hel | --he | --h | '--?' | -help | -hel | -he | -h | '-?' )
|
||||||
usage_and_exit 0
|
usage_and_exit 0
|
||||||
@@ -43,6 +58,7 @@ while test $# -gt 0; do
|
|||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
--dbg | --db | --d | -dbg | -db | -d )
|
--dbg | --db | --d | -dbg | -db | -d )
|
||||||
|
shift
|
||||||
set_dbg_level $DEBUG
|
set_dbg_level $DEBUG
|
||||||
;;
|
;;
|
||||||
-*)
|
-*)
|
||||||
@@ -54,25 +70,24 @@ while test $# -gt 0; do
|
|||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ -z "$WORKING_DIRECTORY" ]; then
|
||||||
|
echo "WORKING_DIRECTORY empty. exiting..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "$WORKING_DIRECTORY" ]; then
|
||||||
|
echo "WORKING_DIRECTORY $WORKING_DIRECTORY does not exist! exiting..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "$WORKING_DIRECTORY"
|
||||||
|
|
||||||
source ./update_psa_impl
|
source ./update_psa_impl
|
||||||
|
|
||||||
if read_config
|
if read_config; then
|
||||||
then
|
update_psa
|
||||||
if clone_customer_repository $CUSTOMER_REPOSITORY_PATH
|
exit 0
|
||||||
then
|
|
||||||
check_sanity_of_repository
|
|
||||||
|
|
||||||
#set_updates_available
|
|
||||||
#while :
|
|
||||||
#do
|
|
||||||
# sleep 5
|
|
||||||
# updates_available && break
|
|
||||||
#done
|
|
||||||
|
|
||||||
update_psa
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
exit 1
|
||||||
exit $EXIT_CODE
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@@ -6,15 +6,28 @@
|
|||||||
"customer_location" : "szeged",
|
"customer_location" : "szeged",
|
||||||
|
|
||||||
"" : "unique customer identifier",
|
"" : "unique customer identifier",
|
||||||
"customer_id" : "281",
|
"customer_id" : "customer_281",
|
||||||
|
|
||||||
|
"" : "zone file for PSA",
|
||||||
|
"zone" : "/etc/zone_nr",
|
||||||
|
|
||||||
|
"" : "local branches",
|
||||||
|
"local_branches" : ["master",
|
||||||
|
"zg1/zone1", "zg1/zone2", "zg1/zone3", "zg1/zone4"],
|
||||||
|
|
||||||
|
"" : "customer number of PSA",
|
||||||
|
"customer_id_" : "/etc/cust_nr",
|
||||||
|
|
||||||
|
"" : "machine id of PSA",
|
||||||
|
"machine_nr" : "/etc/machine_nr",
|
||||||
|
|
||||||
"" : "each location can have multiple",
|
"" : "each location can have multiple",
|
||||||
"" : "zone-groups and/or zones",
|
"" : "zone-groups and/or zones",
|
||||||
"" : "0-index used as size of following array",
|
"" : "0-index used as size of following array",
|
||||||
"" : ".zg[0]: #n of zones_groups",
|
"" : ".zg[0]: #n of zones_groups",
|
||||||
"" : ".zg[1].z[0]: #n of zones in zg[1]",
|
"" : ".zg[1].z[0]: #n of zones in zg[1]",
|
||||||
"zg" : [ 1, { "z" : [ 3, 1, 2, 3] } ],
|
"zg" : [ 1, { "z" : [ 4, 1, 2, 4] } ],
|
||||||
|
|
||||||
"" : "url of customer repository",
|
"" : "url of customer repository",
|
||||||
"cust_repository_path" : "https://git.mimbach49.de/GerhardHoffmann"
|
"cust_repository_path" : "https://git.mimbach49.de/GerhardHoffmann/customer_281.git"
|
||||||
}
|
}
|
||||||
|
@@ -24,9 +24,12 @@ 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() {
|
||||||
if ! pull_customer_repository $1; then
|
local func="${FUNCNAME[0]}"
|
||||||
|
if ! pull_customer_repository; then
|
||||||
|
log_warn "$func:${LINENO} NO pull_customer_repository"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
log_debug "$func:${LINENO} pull_customer_repository SUCCESS"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,57 +44,91 @@ copy () {
|
|||||||
if [[ "$f" =~ .*update[.]conf.* ]]; then
|
if [[ "$f" =~ .*update[.]conf.* ]]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# TODO: szeged darf nicht sein
|
||||||
|
# local readonlt __cl=$CUSTOMER_LOCATION
|
||||||
|
# local readonly __q="'"
|
||||||
|
# xxx='$('"echo $f | sed -E -e ${__q}s=(.*$__cl/[0-9]/[0-9])(.*)(/.*)=\2=g$__q"')'
|
||||||
|
# echo $xxx
|
||||||
|
# eval "echo $xxx"
|
||||||
|
|
||||||
|
local readonly __sysdir=$(echo $f |
|
||||||
|
sed -E -e s'=(.*szeged/[0-9]/[0-9])(.*)(/.*)=\2=g')
|
||||||
|
|
||||||
|
# TODO: kuerzen
|
||||||
|
|
||||||
copy_necessary=1
|
copy_necessary=1
|
||||||
|
|
||||||
PERCENT=$((PERCENT+1))
|
PERCENT=$((PERCENT+1))
|
||||||
test $PERCENT -gt 100 && PERCENT=100
|
test $PERCENT -gt 100 && PERCENT=100
|
||||||
|
|
||||||
local __f=${f##*/}
|
local readonly __f=${f##*/}
|
||||||
local __m=""
|
local readonly __m="${CUSTOMER_ID_BASE_DIR}/${f}"
|
||||||
local __copy_error=0
|
local __p="${__sysdir}/${__f}"
|
||||||
|
|
||||||
if grep -qE "^.*[.]json\s*$" <<< ${f}; then
|
# echo "TEST -> $sysdir/$__f"
|
||||||
__m="cp ${CUSTOMER_ID_BASE_DIR}/${f} to ${CONF_SYS_DIR}/${__f}"
|
|
||||||
cp "${CUSTOMER_ID_BASE_DIR}/${f}" "${CONF_SYS_DIR}/${__f}"
|
# TODO: das kopieren in die system-verzeichnisse muss noch getestet
|
||||||
__copy_error=$?
|
# werden. stimmt noch nicht so ganz.
|
||||||
elif grep -qE "^.*[.]ini\s*$" <<< ${f}; then
|
|
||||||
if [ "$__f" = "$ATBQT_INI" ]; then
|
#if grep -qE "^.*$DC\s*$" <<< ${f}; then
|
||||||
__m="cp ${CUSTOMER_ID_BASE_DIR}/${f} $ATBAPP_SYS_DIR/${__f}"
|
# __p="${DC_SYS_DIR}/${__f}"
|
||||||
cp "${CUSTOMER_ID_BASE_DIR}/${f}" $ATBAPP_SYS_DIR/${__f}
|
# log_debug "$func:${LINENO}: __m=$__m"
|
||||||
__copy_error=$?
|
#elif grep -qE "^.*tariff[0-9][0-9][.]json\s*$" <<< ${f}; then
|
||||||
elif [ "$__f" = "$SYSTEM_CONTROL_INI" ]; then
|
# __p="${TARIFF_SYS_DIR}/${__f}"
|
||||||
__m="cp ${CUSTOMER_ID_BASE_DIR}/${f} $SYSCONFIG_SYS_DIR/${__f}"
|
#elif grep -qE "^.*[.]json\s*$" <<< ${f}; then
|
||||||
cp "${CUSTOMER_ID_BASE_DIR}/${f}" $SYSCONFIG_SYS_DIR/${__f}
|
# __p="${CONF_SYS_DIR}/${__f}"
|
||||||
__copy_error=$?
|
# log_debug "$func:${LINENO}: __m=$__m"
|
||||||
elif [ "$__f" = "$SYS_CONFIG_INI" ]; then
|
#elif grep -qE "^.*[.]ini\s*$" <<< ${f}; then
|
||||||
__m="cp ${CUSTOMER_ID_BASE_DIR}/${f} $SYSCONFIG_SYS_DIR/${__f}"
|
# if [ "$__f" = "$ATBQT_INI" ]; then
|
||||||
cp "${CUSTOMER_ID_BASE_DIR}/${f}" $SYSCONFIG_SYS_DIR/${__f}
|
# log_debug "$func:${LINENO}: __m=$__m $ATB_SYS_DIR/$__f ${f%/*}"
|
||||||
__copy_error=$?
|
# if grep -qE "$ATB_SYS_DIR" <<< "${f%/*}"; then
|
||||||
elif [ "$__f" = "$ISMASMGR_INI" ]; then
|
# __p="$ATB_SYS_DIR/${__f}"
|
||||||
if grep -qE "$ISMASMGR_SYS_DIR" <<< "${f%/*}"; then
|
# else
|
||||||
__m="cp ${CUSTOMER_ID_BASE_DIR}/${f}"
|
# __p="$ATBAPP_SYS_DIR/${__f}"
|
||||||
__m="$__m $ISMASMGR_SYS_DIR/${__f}"
|
# fi
|
||||||
cp "${CUSTOMER_ID_BASE_DIR}/${f}" $ISMASMGR_SYS_DIR/${__f}
|
# elif [ "$__f" = "$SYSTEM_CONTROL_INI" ]; then
|
||||||
__copy_error=$?
|
# if grep -qE "$ATB_SYS_DIR" <<< "${f%/*}"; then
|
||||||
else
|
# __p="$ATB_SYS_DIR/${__f}"
|
||||||
__m="cp ${CUSTOMER_ID_BASE_DIR}/${f}"
|
# else
|
||||||
__m="$__m $SYSCONFIG_SYS_DIR/${__f}"
|
# __p="$SYSCONFIG_SYS_DIR/${__f}"
|
||||||
cp "${CUSTOMER_ID_BASE_DIR}/${f}" $SYSCONFIG_SYS_DIR/${__f}
|
# fi
|
||||||
__copy_error=$?
|
# elif [ "$__f" = "$SYS_CONFIG_INI" ]; then
|
||||||
fi
|
# if grep -qE "$ATB_SYS_DIR" <<< "${f%/*}"; then
|
||||||
|
# __p="$ATB_SYS_DIR/${__f}"
|
||||||
|
# else
|
||||||
|
# __p="$SYSCONFIG_SYS_DIR/${__f}"
|
||||||
|
# fi
|
||||||
|
# elif [ "$__f" = "$ISMASMGR_INI" ]; then
|
||||||
|
# if grep -qE "$ISMASMGR_SYS_DIR" <<< "${f%/*}"; then
|
||||||
|
# __p="$ISMASMGR_SYS_DIR/${__f}"
|
||||||
|
# elif grep -qE "$ATB_SYS_DIR" <<< "${f%/*}"; then
|
||||||
|
# __p="$ATB_SYS_DIR/${__f}"
|
||||||
|
# else
|
||||||
|
# __p="$SYSCONFIG_SYS_DIR/${__f}"
|
||||||
|
# fi
|
||||||
|
# fi
|
||||||
|
#fi
|
||||||
|
|
||||||
|
echo "XXX-- __p=$__p"
|
||||||
|
|
||||||
|
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
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
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
|
else
|
||||||
log_info "$func:${LINENO}: $__m ok"
|
log_error "$func:${LINENO}: __p still empty"
|
||||||
update_psa_copy_conf_and_ini_files $UPDATE_ISMAS_PROGRESS \
|
update_psa_copy_conf_and_ini_files \
|
||||||
$RC_SUCCESS "$__m ok"
|
$UPDATE_ISMAS_ERROR $RC_COPY_ERROR "__p still empty"
|
||||||
|
EXITCODE=$((EXITCODE+1))
|
||||||
|
return $EXITCODE
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -102,17 +139,18 @@ copy () {
|
|||||||
else
|
else
|
||||||
log_debug "$func:${LINENO}: copied *conf/*ini-files to system-dirs"
|
log_debug "$func:${LINENO}: copied *conf/*ini-files to system-dirs"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
filter_json_ini_files () {
|
filter_changed_files () {
|
||||||
local func="${FUNCNAME[0]}"
|
local func="${FUNCNAME[0]}"
|
||||||
log_debug "$func:${LINENO} $1"
|
log_debug "$func:${LINENO} $1"
|
||||||
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"
|
log_debug "$func:${LINENO} $f"
|
||||||
if grep -qE "^.*[.](json|ini)\s*$" <<< $f; then
|
if grep -qE "^.*[.]($2)\s*$" <<< $f; then
|
||||||
if [ -z $__system_files ]; then
|
if [ -z $__system_files ]; then
|
||||||
__system_files="${f}"
|
__system_files="${f}"
|
||||||
else
|
else
|
||||||
@@ -142,52 +180,28 @@ check_md5_for_changed_json_and_ini_files () {
|
|||||||
log_debug "$func:${LINENO} files=$1"
|
log_debug "$func:${LINENO} files=$1"
|
||||||
if ! [ -z $1 ]; then
|
if ! [ -z $1 ]; then
|
||||||
readarray -td' ' files <<< "$1"
|
readarray -td' ' files <<< "$1"
|
||||||
|
local readonly __cl=$CUSTOMER_LOCATION
|
||||||
for file in ${files[@]}; do
|
for file in ${files[@]}; do
|
||||||
|
# .../szeged/1/1...
|
||||||
log_debug "$func:${LINENO} checking file=${file}..."
|
log_debug "$func:${LINENO} checking file=${file}..."
|
||||||
local __fsuffix=${file##*.}
|
local __fs=${file##*.}
|
||||||
local __bn=$(basename $file .$__fsuffix)
|
|
||||||
if [[ "$file" =~ .*cash[.]json.* ]]; then
|
|
||||||
js_key=".conf.szeged.zg[1].z[1].etc.psa_config.$__bn"
|
|
||||||
md5sum_update_conf=$(cat $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=".conf.szeged.zg[1].z[1].etc.psa_config.$__bn"
|
|
||||||
|
|
||||||
echo "$js_key"
|
js_key=""
|
||||||
|
|
||||||
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
|
case $file in
|
||||||
md5sum_repository="$(md5_of $CUSTOMER_ID_BASE_DIR/$file)"
|
*.ini | *.json | *.hex)
|
||||||
elif [[ "$file" =~ .*conf[.]json.* ]]; then
|
local __key_suffix=$(echo $file |
|
||||||
js_key=".conf.szeged.zg[1].z[1].etc.psa_config.DC2C_conf"
|
sed -E -e 's=(.*[0-9]/[0-9])([^.]+)(.*)=\2=g' -e 's=/=.=g')
|
||||||
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
|
js_key=".$__fs.$__cl.zg[$ZONE_GROUP].z[$ZONE]$__key_suffix"
|
||||||
md5sum_repository="$(md5_of $CUSTOMER_ID_BASE_DIR/$file)"
|
md5sum_update_conf=$(cat $PSA_UPDATE_CONF | jq -r $js_key)
|
||||||
elif [[ "$file" =~ .*serial[.]json.* ]]; then
|
md5sum_repository="$(md5_of $CUSTOMER_ID_BASE_DIR/$file)"
|
||||||
js_key=".conf.szeged.zg[1].z[1].etc.psa_config.DC2C_serial"
|
;;
|
||||||
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
|
*)
|
||||||
md5sum_repository="$(md5_of $CUSTOMER_ID_BASE_DIR/$file)"
|
log_crit "$func:${LINENO} unknown file=${file}"
|
||||||
elif [[ "$file" =~ .*ATBQT[.]ini.* ]]; then
|
;;
|
||||||
js_key=".ini.szeged.zg[1].z[1].opt.app.ATBAPP.ATBQT"
|
esac
|
||||||
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
|
|
||||||
md5sum_repository="$(md5_of $ATBQT_INI_FULL)"
|
test -z $js_key && continue
|
||||||
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_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_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_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_FULL)
|
|
||||||
else
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
PERCENT=$((PERCENT+1))
|
PERCENT=$((PERCENT+1))
|
||||||
test $PERCENT -gt 100 && PERCENT=100
|
test $PERCENT -gt 100 && PERCENT=100
|
||||||
@@ -362,7 +376,63 @@ cleanup_previous_version() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
check_for_apism () {
|
check_for_running_apism () {
|
||||||
nc localhost 7778
|
local func="${FUNCNAME[0]}"
|
||||||
|
if nc localhost 7777
|
||||||
|
then
|
||||||
|
APISM_RUNNING=1
|
||||||
|
log_info "$func:${LINENO}: APISM is running..."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
log_fatal "$func:${LINENO}: !!! APISM NOT RUNNING !!!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_default_route () {
|
||||||
|
local func="${FUNCNAME[0]}"
|
||||||
|
if ip route | head -n 1 | grep -q '^default'
|
||||||
|
then
|
||||||
|
log_info "$func:${LINENO}: default route set"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
log_fatal "$func:${LINENO}: !!! NO DEFAULT ROUTE SET !!!"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_route_to_repository () {
|
||||||
|
local func="${FUNCNAME[0]}"
|
||||||
|
# ip_address=$1, e.g. git.mimbach.de (185.191.219.134)
|
||||||
|
# 185.191.219.134 via 192.168.5.254 ...
|
||||||
|
if test "$#" -eq 1 && ip route get "$1" | head -n 1 | grep -q "^$1"
|
||||||
|
then
|
||||||
|
log_info "$func:${LINENO}: route to repository available"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
log_fatal "$func:${LINENO}: !!! NO ROUTE TO REPO SET !!!"
|
||||||
|
}
|
||||||
|
|
||||||
|
get_customer_id () {
|
||||||
|
echo $(cat CUST_ID_FILE)
|
||||||
|
}
|
||||||
|
|
||||||
|
get_zone_nr () {
|
||||||
|
echo $(cat ZONE_FILE)
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
217
update_psa_impl
217
update_psa_impl
@@ -12,176 +12,81 @@ trap collect_current_configuration EXIT
|
|||||||
|
|
||||||
collect_current_configuration () {
|
collect_current_configuration () {
|
||||||
local func="${FUNCNAME[0]}"
|
local func="${FUNCNAME[0]}"
|
||||||
echo $func
|
|
||||||
|
|
||||||
return 0
|
$FATAL_FAILURE && return 1
|
||||||
|
|
||||||
for line in $(cat $UPDATE_CONF |\
|
# TODO: eventuell muss die version neu berechnet werden
|
||||||
jq -r .conf.szeged.zg[1].z[1].etc.psa_config)
|
current_settings_to_ismas
|
||||||
do
|
|
||||||
conf_file="$(echo $line |
|
#for line in $(cat $PSA_UPDATE_CONF |\
|
||||||
sed -E -ne 's/^[^{}]\s+\"(DC2C_[[:alnum:]]+)\".*$/\1/gp')"
|
# jq -r .conf.szeged.zg[$ZONE_GROUP].z[$ZONE].etc.psa_config)
|
||||||
if ! [ -z $conf_file ]; then
|
#do
|
||||||
local v=$(cat "$psa_config_dir/${conf_file}.json" | jq -r .version)
|
# conf_file="$(echo $line |
|
||||||
echo "$conf_file.json version=$v"
|
# sed -E -ne 's/^[^{}]\s+\"(DC2C_[[:alnum:]]+)\".*$/\1/gp')"
|
||||||
fi
|
# if ! [ -z $conf_file ]; then
|
||||||
done
|
# local v=$(cat "$psa_config_dir/${conf_file}.json" | jq -r .version)
|
||||||
|
# echo "$conf_file.json version=$v"
|
||||||
|
# fi
|
||||||
|
#done
|
||||||
}
|
}
|
||||||
|
|
||||||
update_psa() {
|
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
|
update_psa_activated # message to ISMAS
|
||||||
|
|
||||||
local try_update_count=0
|
|
||||||
local func="${FUNCNAME[0]}"
|
local func="${FUNCNAME[0]}"
|
||||||
|
|
||||||
log_debug "$func:${LINENO}: fetch/merge updates..."
|
|
||||||
|
|
||||||
# Fetch new updates (using git)
|
|
||||||
while :
|
|
||||||
do
|
|
||||||
local repository_is_already_up_to_date=""
|
|
||||||
if ! fetch_customer_updates repository_is_already_up_to_date; then
|
|
||||||
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"
|
|
||||||
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"
|
|
||||||
update_psa_pull_error # message to ISMAS
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
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
|
|
||||||
update_psa_backup_error # message to ISMAS
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
update_psa_backup # message to ISMAS
|
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
|
||||||
|
|
||||||
# TODO: use CLONE_CUSTOMER_REPOSITORY=true
|
# an initial clone of the customer-repository (e.g. customer_281) is
|
||||||
# d.h. wird das rep geklont, also neu angelegt, dann sind eigentlich alle
|
# always possible, even without a ISMAS-WAIT-button
|
||||||
# dateinen zu ueberpruefen
|
clone_customer_repository ${CUSTOMER_REPOSITORY_PATH}
|
||||||
|
check_sanity_of_repository
|
||||||
|
$INITIAL_CLONE && return 0
|
||||||
|
|
||||||
local changed_files=$(changed_file_names)
|
local ismas_requests=0
|
||||||
local json_ini_files=$(filter_json_ini_files "$changed_files")
|
|
||||||
|
|
||||||
update_psa_report_changed_file_names $changed_files # message to ISMAS
|
if [ "$MAINTENANCE" = "NO" ]; then
|
||||||
|
log_info "${func}:${LINENO}: MAINTENANCE OFF. Checking for updates..."
|
||||||
# check if *.conf and/or *.ini-files have to md5-sum as denoted
|
# someone must have activated the WAIT-button in ISMAS.
|
||||||
# in update.conf
|
# Request the status of this button in updates_available().
|
||||||
if ! check_md5_for_changed_json_and_ini_files "$json_ini_files" ; then
|
while [ $ismas_requests -le 3 ]; do
|
||||||
local __r=$?
|
ismas_requests=$(( $ismas_requests + 1 ))
|
||||||
log_error "$func:${LINENO}: new customer files wrong"
|
updates_available && break
|
||||||
revert_customer_repository
|
update_psa_false_alarm "update requested, but no WAIT state detected <$ismas_requests>"
|
||||||
exit $__r
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! check_hardware_compatibility "$json_ini_files" ; then
|
|
||||||
local __r=$?
|
|
||||||
log_error "$func:${LINENO}: json/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 $json_ini_files; then
|
|
||||||
local __r=$?
|
|
||||||
log_error "$func:${LINENO}: copy operation failed"
|
|
||||||
revert_customer_repository
|
|
||||||
exit $__r
|
|
||||||
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_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
|
done
|
||||||
|
if [ $ismas_requests -gt 3 ]; then
|
||||||
|
log_fatal "update_psa:${LINENO}: update requested, but no WAIT state detected !!!"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
log_info "$func:${LINENO}: no opkg commands to execute"
|
log_info "${func}:${LINENO}: MAINTENANCE ON. Emulate ISMAS updates..."
|
||||||
update_psa_install_opkg_packages $UPDATE_ISMAS_PROGRESS \
|
# simulate an activated WAIT-button in ISMAS
|
||||||
$RC_SUCCESS "no opkg commands to execute"
|
set_updates_available
|
||||||
fi
|
while [ $ismas_requests -le 10 ]; do
|
||||||
|
sleep 5
|
||||||
# Cleanup.
|
updates_available && break
|
||||||
if ! cleanup_previous_version; then
|
ismas_requests=$(( $ismas_requests + 1 ))
|
||||||
log_error "$func:${LINENO}: cleanup_previous_version failed"
|
log_info "${func}:${LINENO}: updates_requested <$ismas_requests>"
|
||||||
|
done
|
||||||
|
if [ $ismas_requests -gt 10 ]; then
|
||||||
|
log_fatal "${func}:${LINENO}: NO ISMAS UPDATES AVAILABLE"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# TODO: nach (erfolgreichem) abschluss sollte man immer das aktuelle setting
|
log_debug "$func:${LINENO}: before fetch/merge updates..."
|
||||||
# ans ISMAS schicken. ISMAS sollte immer wissen, was gerade auf dem
|
|
||||||
# Automaten steht.
|
# Fetch new updates (using git). but only when repository has already been
|
||||||
|
# cloned.
|
||||||
update_psa_cleanup $UPDATE_ISMAS_PROGRESS \
|
if ! fetch_customer_updates; then
|
||||||
$RC_SUCCESS "cleanup after psa update"
|
update_psa_false_alarm \
|
||||||
|
"update request, but no change in $CUSTOMER_REPOSITORY_PATH"
|
||||||
update_psa_update_succeeded $UPDATE_SUCCEEDED \
|
log_fatal "$func:${LINENO}: fetch no data for $customer_id"\
|
||||||
$RC_SUCCESS "psa update succeeded"
|
"-> no files to update -> no psa update"
|
||||||
|
else
|
||||||
update_psa_update_succeeded $UPDATE_ACTIVATED \
|
log_debug "$func:${LINENO}: after successful fetch_customer_repository..."
|
||||||
$RC_SUCCESS "psa update activated"
|
fi
|
||||||
|
|
||||||
log_info "$func:${LINENO}: success"
|
update_psa_pull_customer_repository # message to ISMAS
|
||||||
exit 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user