Compare commits
45 Commits
7e0eccc8d0
...
szeged_pre
Author | SHA1 | Date | |
---|---|---|---|
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 |
@@ -82,33 +82,37 @@ if [ "${general_utils_sourced:-1}" = "1" ]; then # include only once
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert_s () {
|
assert_s () {
|
||||||
if [ -z ${!1} ]; then
|
# if [ -z ${!1} ]; then
|
||||||
log_fatal "$1 not set"
|
# log_fatal "$1 not set"
|
||||||
fi
|
# fi
|
||||||
log_debug "$1=${!1}"
|
# log_debug "$1=${!1}"
|
||||||
|
:
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_d () {
|
assert_d () {
|
||||||
if [ ! -d ${!1} ]; then
|
# if [ ! -d ${!1} ]; then
|
||||||
log_fatal "$1 does not exist"
|
# log_fatal "$1 does not exist"
|
||||||
fi
|
# fi
|
||||||
log_debug "$1=${!1}"
|
# log_debug "$1=${!1}"
|
||||||
|
:
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_f () {
|
assert_f () {
|
||||||
if [ ! -f ${!1} ]; then
|
# if [ ! -f ${!1} ]; then
|
||||||
log_fatal "$1 does not exist"
|
# log_fatal "$1 does not exist"
|
||||||
fi
|
# fi
|
||||||
log_debug "$1=${!1}"
|
#log_debug "$1=${!1}"
|
||||||
|
:
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_a () {
|
assert_a () {
|
||||||
local readonly __m="${1}[@]"
|
local readonly __m="${1}[@]"
|
||||||
local readonly __n=(${!__m})
|
local readonly __n=(${!__m})
|
||||||
local __len=${#__n[@]}
|
local __len=${#__n[@]}
|
||||||
if [ $__len -eq 0 ]; then
|
# if [ $__len -eq 0 ]; then
|
||||||
log_fatal "$1 not set"
|
# log_fatal "$1 not set"
|
||||||
fi
|
# fi
|
||||||
log_debug "$1=$__n"
|
# log_debug "$1=$__n"
|
||||||
|
:
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
160
git_helpers
160
git_helpers
@@ -71,9 +71,7 @@ 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
|
mkdir -p "./$WORKSPACE_DIR"
|
||||||
{ mkdir -p ./$WORKSPACE_DIR; }
|
|
||||||
fi
|
|
||||||
# check if the directory is empty. If so, clone the
|
# check if the directory is empty. If so, clone the
|
||||||
# customer repository
|
# customer repository
|
||||||
if ! find ./$WORKSPACE_DIR -mindepth 1 -maxdepth 1 | read; then
|
if ! find ./$WORKSPACE_DIR -mindepth 1 -maxdepth 1 | read; then
|
||||||
@@ -82,11 +80,44 @@ clone_customer_repository () {
|
|||||||
then
|
then
|
||||||
$(exec_git_command git clone "$1")
|
$(exec_git_command git clone "$1")
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
CLONE_CUSTOMER_REPOSITORY=true
|
|
||||||
log_debug "$func:${LINENO} cloning ${1} done"
|
log_debug "$func:${LINENO} cloning ${1} done"
|
||||||
cd - ; return 0
|
GIT_CLONE_EXECUTED=1
|
||||||
|
rm -f $GIT_PULL_TMP
|
||||||
|
rm -f $OPKG_CMDS_TMP
|
||||||
|
# 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.
|
||||||
|
if cd ${CUSTOMER_ID_BASE_DIR}; then
|
||||||
|
# local res=$(exec_git_command git --git-dir=.git --work-tree=/ init)
|
||||||
|
exec_git_command git checkout "$LOCAL_BRANCH"
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
log_debug "$func:${LINENO} checked out local branch $LOCAL_BRANCH"
|
||||||
|
exec_git_command git config core.worktree "/"
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
log_debug "$func:${LINENO} configured worktree"
|
||||||
|
exec_git_command git fetch --all
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
log_debug "$func:${LINENO} fetch repository"
|
||||||
|
exec_git_command git reset --hard "$LOCAL_BRANCH"
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
log_debug "$func:${LINENO} reset --hard $LOCAL_BRANCH"
|
||||||
|
# re-initialized. copy post-merge (a hook called
|
||||||
|
# when 'git pull' is executed and changed data
|
||||||
|
# are received).
|
||||||
|
if cp ".githooks/post-merge" ".git/hooks"; then
|
||||||
|
log_debug "$func:${LINENO} copied post-merge to .git/hooks"
|
||||||
|
CLONE_CUSTOMER_REPOSITORY=true
|
||||||
|
log_debug "$func:${LINENO} re-init of ${1} done"
|
||||||
|
cd_home; return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
cd -
|
cd_home; return 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# the directory is not empty, so we assume the
|
# the directory is not empty, so we assume the
|
||||||
@@ -111,6 +142,7 @@ clone_customer_repository () {
|
|||||||
cd_customer_repository () {
|
cd_customer_repository () {
|
||||||
local func="${FUNCNAME[0]}"
|
local func="${FUNCNAME[0]}"
|
||||||
# has to be called in WORKING_DIRECTORY
|
# has to be called in WORKING_DIRECTORY
|
||||||
|
cd "$WORKING_DIRECTORY"
|
||||||
if [ "$PWD" = "${WORKING_DIRECTORY}" ]; then
|
if [ "$PWD" = "${WORKING_DIRECTORY}" ]; then
|
||||||
repository_dir="./$WORKSPACE_DIR/$CUSTOMER_ID"
|
repository_dir="./$WORKSPACE_DIR/$CUSTOMER_ID"
|
||||||
if ! [[ -d "$repository_dir" ]]; then
|
if ! [[ -d "$repository_dir" ]]; then
|
||||||
@@ -143,109 +175,27 @@ pull_customer_repository () {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local commit_before_pull=$(latest_commit)
|
#local commit_before_pull=$(latest_commit)
|
||||||
if [ -z $commit_before_pull ]; then
|
#if [ -z $commit_before_pull ]; then
|
||||||
log_warn "$func:${LINENO}: commit_before_pull empty"
|
# log_warn "$func:${LINENO}: commit_before_pull empty"
|
||||||
cd_home ; return 1
|
# cd_home ; return 1
|
||||||
fi
|
#fi
|
||||||
log_debug "$func:${LINENO}: commit_before_pull=$commit_before_pull"
|
#log_debug "$func:${LINENO}: commit_before_pull=$commit_before_pull"
|
||||||
|
|
||||||
|
rm -f "$OPKG_CMDS_TMP"
|
||||||
|
rm -f "$GIT_PULL_TMP"
|
||||||
|
|
||||||
log_debug "$func:${LINENO}: executing 'git pull'..."
|
log_debug "$func:${LINENO}: executing 'git pull'..."
|
||||||
|
exec_git_command 'git pull'
|
||||||
|
|
||||||
local git_result=$(exec_git_command 'git pull')
|
# GIT_PULL_TMP created by hook post-merge. it contains the names of the
|
||||||
|
# changed files.
|
||||||
if [ -z "$git_result" ]; then
|
if [[ -f $GIT_PULL_TMP ]]; then
|
||||||
log_warn "$func:${LINENO}: git result empty" ; cd_home;
|
cd_home; return 0
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# see https://www.gnu.org/
|
log_warn "$func:${LINENO}: no data fetched form repository"
|
||||||
# software/bash/manual/html_node/Shell-Parameter-Expansion.html
|
cd_home; return 1
|
||||||
# [...]
|
|
||||||
#
|
|
||||||
# ${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
|
||||||
|
|
||||||
|
16
log_helpers
16
log_helpers
@@ -1,6 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# set -x
|
# set -x
|
||||||
|
|
||||||
|
RED='\e[0;31m'
|
||||||
|
GREEN='\e[0;32m'
|
||||||
|
NC='\e[0m' # No Color
|
||||||
|
|
||||||
if [ "${log_helpers_sourced:-1}" = "1" ]; then # include only once
|
if [ "${log_helpers_sourced:-1}" = "1" ]; then # include only once
|
||||||
readonly log_helpers_sourced=${BASH_SOURCE[0]}
|
readonly log_helpers_sourced=${BASH_SOURCE[0]}
|
||||||
|
|
||||||
@@ -47,32 +51,32 @@ if [ "${log_helpers_sourced:-1}" = "1" ]; then # include only once
|
|||||||
|
|
||||||
log_info() {
|
log_info() {
|
||||||
if [ $log_level -le $INFO ]; then
|
if [ $log_level -le $INFO ]; then
|
||||||
log "INFO $*"
|
log "${GREEN}INFO $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
log_warn() {
|
log_warn() {
|
||||||
if [ $log_level -le $WARN ]; then
|
if [ $log_level -le $WARN ]; then
|
||||||
log "WARN $*"
|
log "${RED}WARN $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
log_crit() {
|
log_crit() {
|
||||||
if [ $log_level -le $CRIT ]; then
|
if [ $log_level -le $CRIT ]; then
|
||||||
log "CRIT $*"
|
log "${RED}CRIT $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
log_error() {
|
log_error() {
|
||||||
if [ $log_level -le $ERROR ]; then
|
if [ $log_level -le $ERROR ]; then
|
||||||
log "ERROR $*"
|
log "${RED}ERROR $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
log_fatal() {
|
log_fatal() {
|
||||||
if [ $log_level -le $FATAL ]; then
|
if [ $log_level -le $FATAL ]; then
|
||||||
log "FATAL $*"
|
log "${RED}FATAL $*"
|
||||||
log "exiting ..."
|
log "${RED}exiting ..."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@@ -375,6 +375,7 @@ if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
|||||||
current_settings_to_ismas () {
|
current_settings_to_ismas () {
|
||||||
local func="${FUNCNAME[0]}"
|
local func="${FUNCNAME[0]}"
|
||||||
local p=("$@")
|
local p=("$@")
|
||||||
|
|
||||||
local data="#M=APISM#C=CMD_SENDVERSION#J=
|
local data="#M=APISM#C=CMD_SENDVERSION#J=
|
||||||
{
|
{
|
||||||
\"VERSION_INFO\" : {
|
\"VERSION_INFO\" : {
|
||||||
@@ -382,7 +383,7 @@ if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
|||||||
\"HASH\":\"$(compute_hash)\"
|
\"HASH\":\"$(compute_hash)\"
|
||||||
},
|
},
|
||||||
\"TARIFF\": {
|
\"TARIFF\": {
|
||||||
$(<$TARIFF_CURRENT_FULL)
|
$(<$TC_PSA_TC_FILE)
|
||||||
},
|
},
|
||||||
\"HARDWARE\" : {
|
\"HARDWARE\" : {
|
||||||
\"DEVICES\" : [
|
\"DEVICES\" : [
|
||||||
@@ -399,8 +400,8 @@ if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
|||||||
sed -E -e 's/.*:\s*(.*)/\1/g')\"
|
sed -E -e 's/.*:\s*(.*)/\1/g')\"
|
||||||
},
|
},
|
||||||
\"DC\" : {
|
\"DC\" : {
|
||||||
\"VERSION\" : \"$(cat $UPDATE_CONF | jq -r .dc.version)\",
|
\"VERSION\" : \"$(compute_hash ${DC_PSA_DC_FILE})\",
|
||||||
\"MD5SUM\" : \"$(cat $UPDATE_CONF | jq -r .dc.dc2c)\"
|
\"MD5SUM\" : \"\"
|
||||||
},
|
},
|
||||||
\"PRINTER\" : {
|
\"PRINTER\" : {
|
||||||
},
|
},
|
||||||
@@ -411,11 +412,11 @@ if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
|
|||||||
\"RAUC\" : \"$(rauc --version)\",
|
\"RAUC\" : \"$(rauc --version)\",
|
||||||
\"OPKG\" : \"$(opkg --version)\",
|
\"OPKG\" : \"$(opkg --version)\",
|
||||||
\"ATBQT\" : {
|
\"ATBQT\" : {
|
||||||
\"VERSION\" : \"$($ATBQT_SYS_FULL -v |
|
\"VERSION\" : \"$($ATBQT_ATB_SYS_BIN_FILE -v |
|
||||||
grep Version |
|
grep Version |
|
||||||
sed -E -e 's/.*:\s*(.*)/\1/g')\",
|
sed -E -e 's/.*:\s*(.*)/\1/g')\",
|
||||||
\"GIT_DESCRIBE\" : \"$($ATBQT_SYS_FULL -v |
|
\"GIT_DESCRIBE\" : \"$($ATBQT_ATB_SYS_BIN_FILE -v |
|
||||||
grep git |
|
grep git |
|
||||||
sed -E -e 's/.*:\s*(.*)/\1/g')\"
|
sed -E -e 's/.*:\s*(.*)/\1/g')\"
|
||||||
},
|
},
|
||||||
\"PLUGINS\" : {
|
\"PLUGINS\" : {
|
||||||
|
424
read_config
424
read_config
@@ -22,19 +22,13 @@ 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 OPKG_CMDS_TMP=/tmp/opkg_commands
|
||||||
|
readonly GIT_PULL_TMP=/tmp/git_pull
|
||||||
|
|
||||||
readonly PROGRAM=`basename $0`
|
readonly PROGRAM=`basename $0`
|
||||||
readonly WORKSPACE_DIR=workspace
|
readonly WORKSPACE_DIR=workspace
|
||||||
|
|
||||||
WORKING_DIRECTORY=${WORKING_DIRECTORY:-$UPDATEPSAHOME}
|
GIT_CLONE_EXECUTED=0
|
||||||
CONFIGFILENAME=${CONFIGFILENAME:-'update_psa.conf'}
|
|
||||||
|
|
||||||
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=$RC_SUCCESS
|
EXITCODE=$RC_SUCCESS
|
||||||
CLONE_CUSTOMER_REPOSITORY=false
|
CLONE_CUSTOMER_REPOSITORY=false
|
||||||
@@ -43,6 +37,13 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
|||||||
read_config() {
|
read_config() {
|
||||||
local func="${FUNCNAME[0]}"
|
local func="${FUNCNAME[0]}"
|
||||||
|
|
||||||
|
WORKING_DIRECTORY=${PWD}
|
||||||
|
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"
|
||||||
|
|
||||||
@@ -68,12 +69,15 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
|||||||
jq -r .cust_repository_path)"
|
jq -r .cust_repository_path)"
|
||||||
assert_s CUSTOMER_REPOSITORY_PATH
|
assert_s CUSTOMER_REPOSITORY_PATH
|
||||||
|
|
||||||
|
local __customer_id_base_dir="$WORKING_DIRECTORY/${WORKSPACE_DIR}"
|
||||||
|
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
|
||||||
@@ -86,6 +90,15 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
|||||||
readonly ZONE_GROUPS=(${__zone_groups[@]})
|
readonly ZONE_GROUPS=(${__zone_groups[@]})
|
||||||
assert_a ZONE_GROUPS
|
assert_a ZONE_GROUPS
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
# TODO: falls mehrere gruppen/zonen auftauchen hier anpassen
|
||||||
|
# TODO
|
||||||
|
# Zone aus /etc/zone_nr auslesen
|
||||||
|
#
|
||||||
|
readonly ZONE_GROUP=1
|
||||||
|
readonly ZONE=1
|
||||||
|
|
||||||
|
readonly LOCAL_BRANCH="$(cat "$cf" | jq -r .local_branches[$ZONE])"
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@@ -93,193 +106,284 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
|||||||
########################## parsing with jq finished ###########################
|
########################## parsing with jq finished ###########################
|
||||||
###############################################################################
|
###############################################################################
|
||||||
compute_hash () {
|
compute_hash () {
|
||||||
# TODO: wie genau soll der hash-wert berechnet werden ?
|
if cd_customer_repository; then
|
||||||
HASH="1234-abcd"
|
local hash=""
|
||||||
# HASH_="67890def"
|
if [[ -z "$1" ]]; then
|
||||||
echo $HASH
|
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 () {
|
compute_version () {
|
||||||
VERSION="$MAJOR.$MINOR.$PATCH+$CUSTOMER_LOCATION-$(compute_hash)"
|
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}"
|
|
||||||
readonly CUSTOMER_ID_BASE_DIR="${__customer_id_base_dir}/${CUSTOMER_ID}"
|
|
||||||
assert_d 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}"
|
||||||
|
#CUST_LOC_DIR=$CUSTOMER_LOCATION_DIR
|
||||||
assert_d CUSTOMER_LOCATION_DIR
|
assert_d CUSTOMER_LOCATION_DIR
|
||||||
|
|
||||||
readonly UPDATE_CONF="${CUSTOMER_LOCATION_DIR}/update.conf"
|
|
||||||
assert_f UPDATE_CONF
|
|
||||||
|
|
||||||
readonly DC="dc2c.hex"
|
|
||||||
readonly DC_SYS_DIR="/etc/dc"
|
|
||||||
readonly DC_SYS_DC_FULL="${DC_SYS_DIR}/$DC"
|
|
||||||
assert_d DC_SYS_DIR
|
|
||||||
assert_f DC_SYS_DC_FULL
|
|
||||||
|
|
||||||
readonly DC_DIR="${CUSTOMER_LOCATION_DIR}/dc"
|
|
||||||
readonly DC_FULL="${DC_DIR}/$DC"
|
|
||||||
assert_d DC_DIR
|
|
||||||
assert_f DC_FULL
|
|
||||||
|
|
||||||
# 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:
|
||||||
assert_a CUSTOMER_BASE_DIRS
|
# placeholder
|
||||||
|
# /home/root/szeged/UpdateController/workspace/customer_281/szeged/1/1
|
||||||
|
# /home/root/szeged/UpdateController/workspace/customer_281/szeged/1/2
|
||||||
|
# /home/root/szeged/UpdateController/workspace/customer_281/szeged/1/3
|
||||||
|
# readonly CUST_BASE_DIRS=(${__customer_base_dirs[@]})
|
||||||
|
# assert_a CUST_BASE_DIRS
|
||||||
|
|
||||||
# TODO
|
|
||||||
# TODO: falls mehrere gruppen/zonen auftauchen hier anpassen
|
|
||||||
# TODO
|
|
||||||
readonly ZONE=1
|
|
||||||
readonly CUSTOMER_BASE_DIR="${CUSTOMER_BASE_DIRS[$ZONE]}"
|
|
||||||
assert_d CUSTOMER_BASE_DIR
|
|
||||||
|
|
||||||
readonly PSA_CONFIG_DIR="${CUSTOMER_BASE_DIR}/etc/psa_config"
|
readonly CUST_BASE_DIR="$CUSTOMER_ID_BASE_DIR"
|
||||||
assert_d PSA_CONFIG_DIR
|
#readonly CUST_BASE_DIR="${CUST_BASE_DIRS[$ZONE]}"
|
||||||
|
#assert_d CUST_BASE_DIR
|
||||||
|
|
||||||
readonly PSA_UPDATE_DIR="${CUSTOMER_BASE_DIR}/etc/psa_update"
|
readonly ETC_SYS_DIR="/etc"
|
||||||
assert_d PSA_UPDATE_DIR
|
readonly ATB_SYS_DIR="/etc/atb"
|
||||||
|
readonly DC_SYS_DIR="/etc/dc"
|
||||||
|
readonly TARIFF_SYS_DIR="/etc/psa_tariff"
|
||||||
|
readonly OPKG_SYS_DIR="/etc/psa_update"
|
||||||
|
readonly CONF_SYS_DIR="/etc/psa_config"
|
||||||
|
readonly OPT_SYS_DIR="/opt"
|
||||||
|
readonly APP_SYS_DIR="/opt/app"
|
||||||
|
readonly SYSCONFIG_SYS_DIR="/opt/app/sysconfig"
|
||||||
|
readonly ATBAPP_SYS_DIR="/opt/app/ATBAPP"
|
||||||
|
readonly ISMASMGR_SYS_DIR="/opt/app/ISMASMgr"
|
||||||
|
|
||||||
readonly ATB_SYS_DIR="/etc/atb"
|
readonly ETC_PSA_DIR=${CUST_BASE_DIR}${ETC_SYS_DIR}
|
||||||
|
readonly ATB_PSA_DIR=${CUST_BASE_DIR}${ATB_SYS_DIR}
|
||||||
|
readonly DC_PSA_DIR=${CUST_BASE_DIR}${DC_SYS_DIR}
|
||||||
|
readonly TARIFF_PSA_DIR=${CUST_BASE_DIR}${TARIFF_SYS_DIR}
|
||||||
|
readonly OPKG_PSA_DIR=${CUST_BASE_DIR}${OPKG_SYS_DIR}
|
||||||
|
readonly CONF_PSA_DIR=${CUST_BASE_DIR}${CONF_SYS_DIR}
|
||||||
|
readonly OPT_PSA_DIR=${CUST_BASE_DIR}${OPT_SYS_DIR}
|
||||||
|
readonly APP_PSA_DIR=${CUST_BASE_DIR}${APP_SYS_DIR}
|
||||||
|
readonly ATBAPP_PSA_DIR=${CUST_BASE_DIR}${ATBAPP_SYS_DIR}
|
||||||
|
readonly SYSCONFIG_PSA_DIR=${CUST_BASE_DIR}${SYSCONFIG_SYS_DIR}
|
||||||
|
readonly ISMASMGR_PSA_DIR=${CUST_BASE_DIR}${ISMASMGR_SYS_DIR}
|
||||||
|
|
||||||
|
readonly ATBQT_BIN="ATBQT"
|
||||||
|
readonly ATBQT_INI="ATBQT.ini"
|
||||||
|
readonly ISMASMGR_INI="ISMASMgr.ini"
|
||||||
|
readonly SYSCONF_INI="sysconfig.ini"
|
||||||
|
readonly SYSCTRL_INI="SystemControl.ini"
|
||||||
|
readonly TARIFF_CURRENT="tariff.current"
|
||||||
|
readonly DC="dc2c.hex"
|
||||||
|
readonly TARIFF_SUMMER="summer_tariff.json"
|
||||||
|
readonly TARIFF_WINTER="winter_tariff.json"
|
||||||
|
|
||||||
|
readonly DC_SYS_DC_FILE="${DC_SYS_DIR}/$DC"
|
||||||
|
readonly ATBQT_ATB_SYS_BIN_FILE="${ATBAPP_SYS_DIR}/$ATBQT_BIN"
|
||||||
|
readonly ATBQT_ATB_SYS_INI_FILE="${ATB_SYS_DIR}/$ATBQT_INI"
|
||||||
|
readonly ATBQT_APP_SYS_INI_FILE="${ATBAPP_SYS_DIR}/$ATBQT_INI"
|
||||||
|
readonly ATBQT_ETC_SYS_INI_FILE="${ETC_SYS_DIR}/$ATBQT_INI"
|
||||||
|
readonly ISMASMGRATB_SYS_INI_FILE="${ATB_SYS_DIR}/$ISMASMGR_INI"
|
||||||
|
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 TC_SYS_TC_FILE="${ATBAPP_SYS_DIR}/$TARIFF_CURRENT"
|
||||||
|
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 TARIFF_SYS_SUMMER="${TARIFF_SYS_DIR}${TARIFF_SUMMER}"
|
||||||
|
readonly TARIFF_SYS_WINTER="${TARIFF_SYS_DIR}${TARIFF_WINTER}"
|
||||||
|
|
||||||
|
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 TC_PSA_TC_FILE="${ATBAPP_PSA_DIR}/$TARIFF_CURRENT"
|
||||||
|
# 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 ATB_SYS_DIR
|
||||||
|
assert_d DC_SYS_DIR
|
||||||
readonly PSA_ATB_SYS_DIR="${CUSTOMER_BASE_DIR}${ATB_SYS_DIR}"
|
assert_d TARIFF_SYS_DIR
|
||||||
assert_d PSA_ATB_SYS_DIR
|
|
||||||
|
|
||||||
readonly PSA_BASE_INI_DIR="${CUSTOMER_BASE_DIR}/opt/app"
|
|
||||||
assert_d PSA_BASE_INI_DIR
|
|
||||||
|
|
||||||
readonly SYSCONFIG_SYS_DIR="/opt/app/sysconfig"
|
|
||||||
assert_d SYSCONFIG_SYS_DIR
|
|
||||||
|
|
||||||
readonly PSA_SYSCONFIG_DIR="${CUSTOMER_BASE_DIR}${SYSCONFIG_SYS_DIR}"
|
|
||||||
assert_d PSA_SYSCONFIG_DIR
|
|
||||||
|
|
||||||
readonly PSA_ISMASMGR_DIR="${PSA_BASE_INI_DIR}/ISMASMgr"
|
|
||||||
assert_d PSA_ISMASMGR_DIR
|
|
||||||
|
|
||||||
readonly CONF_SYS_DIR="/etc/psa_config"
|
|
||||||
assert_d CONF_SYS_DIR
|
|
||||||
|
|
||||||
readonly OPKG_SYS_DIR="/etc/psa_update"
|
|
||||||
assert_d OPKG_SYS_DIR
|
assert_d OPKG_SYS_DIR
|
||||||
|
assert_d CONF_SYS_DIR
|
||||||
readonly ATBAPP_SYS_DIR="/opt/app/ATBAPP"
|
assert_d OPT_SYS_DIR
|
||||||
|
assert_d APP_SYS_DIR
|
||||||
assert_d ATBAPP_SYS_DIR
|
assert_d ATBAPP_SYS_DIR
|
||||||
|
assert_d SYSCONFIG_SYS_DIR
|
||||||
readonly PSA_ATBQT_DIR="$CUSTOMER_BASE_DIR$ATBAPP_SYS_DIR"
|
|
||||||
assert_d PSA_ATBQT_DIR
|
|
||||||
|
|
||||||
readonly TARIFF_CURRENT="tariff.current"
|
|
||||||
readonly TARIFF_CURRENT_FULL="${PSA_ATBQT_DIR}/$TARIFF_CURRENT"
|
|
||||||
assert_f TARIFF_CURRENT_FULL
|
|
||||||
|
|
||||||
readonly ATBQT_INI="ATBQT.ini"
|
|
||||||
readonly ATBQT_INI_FULL="${PSA_ATBQT_DIR}/$ATBQT_INI"
|
|
||||||
assert_f ATBQT_INI_FULL
|
|
||||||
|
|
||||||
readonly ATBQT="ATBQT"
|
|
||||||
readonly ATBQT_SYS_FULL="${ATBAPP_SYS_DIR}/$ATBQT"
|
|
||||||
assert_f ATBQT_SYS_FULL
|
|
||||||
|
|
||||||
readonly ISMASMGR_INI="ISMASMgr.ini"
|
|
||||||
readonly ISMASMGR_SYS_DIR="/opt/app/ISMASMgr"
|
|
||||||
assert_d ISMASMGR_SYS_DIR
|
assert_d ISMASMGR_SYS_DIR
|
||||||
|
|
||||||
readonly ISMASMGR_ISMASMGR_INI_FULL="${PSA_ISMASMGR_DIR}/$ISMASMGR_INI"
|
assert_d ETC_PSA_DIR
|
||||||
assert_f ISMASMGR_ISMASMGR_INI_FULL
|
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
|
||||||
|
|
||||||
readonly SYSCONFIG_ISMASMGR_INI_FULL="${PSA_SYSCONFIG_DIR}/ISMASMgr.ini"
|
assert_f DC_SYS_DC_FILE
|
||||||
assert_f SYSCONFIG_ISMASMGR_INI_FULL
|
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 TC_SYS_TC_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
|
||||||
|
|
||||||
readonly ATB_ISMASMGR_INI_FULL="${PSA_ATB_SYS_DIR}/$ISMASMGR_INI"
|
assert_f DC_PSA_DC_FILE
|
||||||
assert_f ATB_ISMASMGR_INI_FULL
|
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 TC_PSA_TC_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 SYS_CONFIG_INI="sysconfig.ini"
|
readonly KNOWN_SYS_DIRS=($ETC_SYS_DIR
|
||||||
readonly __sysc_sysc_full="${PSA_SYSCONFIG_DIR}/$SYS_CONFIG_INI"
|
$ATB_SYS_DIR
|
||||||
readonly SYSCONFIG_SYSCONFIG_INI_FULL="$__sysc_sysc_full"
|
$DC_SYS_DIR
|
||||||
assert_f SYSCONFIG_SYSCONFIG_INI_FULL
|
$TARIFF_SYS_DIR
|
||||||
|
$OPKG_SYS_DIR
|
||||||
|
$CONF_SYS_DIR
|
||||||
|
$OPT_SYS_DIR
|
||||||
|
$APP_SYS_DIR
|
||||||
|
$ATBAPP_SYS_DIR
|
||||||
|
$SYSCONFIG_SYS_DIR)
|
||||||
|
|
||||||
readonly ATB_SYSCONFIG_INI_FULL="${PSA_ATB_SYS_DIR}/$SYS_CONFIG_INI"
|
readonly KNOWN_PSA_DIRS=($ETC_PSA_DIR
|
||||||
assert_f ATB_SYSCONFIG_INI_FULL
|
$ATB_PSA_DIR
|
||||||
|
$DC_PSA_DIR
|
||||||
readonly "SYSTEM_CONTROL_INI"="SystemControl.ini"
|
$TARIFF_PSA_DIR
|
||||||
local __sysctrl_ini_full="${PSA_SYSCONFIG_DIR}/$SYSTEM_CONTROL_INI"
|
$OPKG_PSA_DIR
|
||||||
readonly SYSCONFIG_SYSCTRL_INI_FULL="$__sysctrl_ini_full"
|
$CONF_PSA_DIR
|
||||||
assert_f SYSCONFIG_SYSCTRL_INI_FULL
|
$OPT_PSA_DIR
|
||||||
|
$APP_PSA_DIR
|
||||||
readonly ATB_SYSCTRL_INI_FULL="${PSA_ATB_SYS_DIR}/$SYSTEM_CONTROL_INI"
|
$ATBAPP_PSA_DIR
|
||||||
assert_f ATB_SYSCTRL_INI_FULL
|
$SYSCONFIG_PSA_DIR)
|
||||||
|
|
||||||
readonly ATB_ATBQT_INI_FULL="${PSA_ATB_SYS_DIR}/$ATBQT_INI"
|
|
||||||
assert_f ATB_ATBQT_INI_FULL
|
|
||||||
|
|
||||||
readonly DC2C_SERIAL_JSON="${PSA_CONFIG_DIR}/DC2C_serial.json"
|
|
||||||
assert_f DC2C_SERIAL_JSON
|
|
||||||
|
|
||||||
readonly DC2C_CASH_JSON="${PSA_CONFIG_DIR}/DC2C_cash.json"
|
|
||||||
assert_f DC2C_CASH_JSON
|
|
||||||
|
|
||||||
readonly DC2C_CONF_JSON="${PSA_CONFIG_DIR}/DC2C_conf.json"
|
|
||||||
assert_f DC2C_CONF_JSON
|
|
||||||
|
|
||||||
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
|
assert_f DC2C_PRINT$(printf "%02d" $i)_JSON
|
||||||
DC2C_PRINT_JSON+=($__f)
|
DC2C_PRINT_JSON+=($__f)
|
||||||
done
|
done
|
||||||
|
|
||||||
readonly OPKG_CMDS_FILE="${PSA_UPDATE_DIR}/opkg_commands"
|
local TARIFF_FILES_JSON=()
|
||||||
assert_f OPKG_CMDS_FILE
|
for i in {1..32}; do # up to 32 tariff-json-files
|
||||||
|
local __f=${TARIFF_PSA_DIR}/tariff$(printf "%02d" $i).json
|
||||||
# TODO: anpassen, da z.B. fuer szeged mehrere zonen vorhanden sind
|
readonly TARIFF$(printf "%02d" $i)_JSON=$__f
|
||||||
readonly KNOWN_CONF_FILES=(${CUSTOMER_LOCATION}/update.conf \
|
assert_f TARIFF$(printf "%02d" $i)_JSON
|
||||||
${DC2C_PRINT_JSON[@]##*${CUSTOMER_ID}/} \
|
TARIFF_FILES_JSON+=($__f)
|
||||||
${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}/} \
|
|
||||||
${ATB_ISMASMGR_INI_FULL##*${CUSTOMER_ID}/} \
|
|
||||||
${ATB_SYSCONFIG_INI_FULL##*${CUSTOMER_ID}/} \
|
|
||||||
${ATB_SYSCTRL_INI_FULL##*${CUSTOMER_ID}/} \
|
|
||||||
${ATB_ATBQT_INI_FULL##*${CUSTOMER_ID}/})
|
|
||||||
|
|
||||||
readonly KNOWN_FILES=(${KNOWN_CONF_FILES[@]} \
|
|
||||||
${KNOWN_INI_FILES[@]} \
|
|
||||||
${OPKG_CMDS_FILE##*${CUSTOMER_ID}/})
|
|
||||||
|
|
||||||
log_debug "known conf/ini_files ->"
|
|
||||||
for (( i=0; i < ${#KNOWN_FILES[@]}; ++i )); do
|
|
||||||
tab=$'\t'
|
|
||||||
log_debug "$tab$tab ${KNOWN_FILES[$i]}"
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
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"
|
log_debug "sanity of ${CUSTOMER_REPOSITORY_PATH} OK"
|
||||||
|
|
||||||
# compute version string for current (i.e. previous) version
|
# compute version string for current (i.e. previous) version
|
||||||
|
36
update_psa
36
update_psa
@@ -14,10 +14,10 @@
|
|||||||
# ./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'
|
||||||
@@ -59,24 +59,28 @@ while test $# -gt 0; do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
source ./update_psa_impl
|
if cd "$WORKING_DIRECTORY"; then
|
||||||
|
source ./update_psa_impl
|
||||||
|
|
||||||
if read_config
|
if read_config
|
||||||
then
|
|
||||||
if clone_customer_repository $CUSTOMER_REPOSITORY_PATH
|
|
||||||
then
|
then
|
||||||
check_sanity_of_repository
|
if clone_customer_repository ${CUSTOMER_REPOSITORY_PATH}
|
||||||
|
then
|
||||||
|
check_sanity_of_repository
|
||||||
|
|
||||||
#set_updates_available
|
#set_updates_available
|
||||||
#while :
|
#while :
|
||||||
#do
|
#do
|
||||||
# sleep 5
|
# sleep 5
|
||||||
# updates_available && break
|
# updates_available && break
|
||||||
#done
|
#done
|
||||||
|
|
||||||
update_psa
|
# update_psa "testing"
|
||||||
|
update_psa
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit $EXIT_CODE
|
exit -1
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@@ -11,6 +11,10 @@
|
|||||||
"" : "zone file for PSA",
|
"" : "zone file for PSA",
|
||||||
"zone" : "/etc/zone_nr",
|
"zone" : "/etc/zone_nr",
|
||||||
|
|
||||||
|
"" : "local branches",
|
||||||
|
"local_branches" : ["master",
|
||||||
|
"zg1/zone1", "zg1/zone2", "zg1/zone3"],
|
||||||
|
|
||||||
"" : "customer number of PSA",
|
"" : "customer number of PSA",
|
||||||
"customer_id_" : "/etc/cust_nr",
|
"customer_id_" : "/etc/cust_nr",
|
||||||
|
|
||||||
@@ -25,5 +29,5 @@
|
|||||||
"zg" : [ 1, { "z" : [ 3, 1, 2, 3] } ],
|
"zg" : [ 1, { "z" : [ 3, 1, 2, 3] } ],
|
||||||
|
|
||||||
"" : "url of customer repository",
|
"" : "url of customer repository",
|
||||||
"cust_repository_path" : "https://git.mimbach49.de/GerhardHoffmann/customer_281"
|
"cust_repository_path" : "https://git.mimbach49.de/GerhardHoffmann/customer_281.git"
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ 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
|
if ! pull_customer_repository; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
@@ -42,6 +42,18 @@ copy () {
|
|||||||
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))
|
||||||
@@ -49,44 +61,53 @@ copy () {
|
|||||||
|
|
||||||
local readonly __f=${f##*/}
|
local readonly __f=${f##*/}
|
||||||
local readonly __m="${CUSTOMER_ID_BASE_DIR}/${f}"
|
local readonly __m="${CUSTOMER_ID_BASE_DIR}/${f}"
|
||||||
local __p=""
|
local __p="${__sysdir}/${__f}"
|
||||||
|
|
||||||
if grep -qE "^.*$DC\s*$" <<< ${f}; then
|
# echo "TEST -> $sysdir/$__f"
|
||||||
__p=" ${DC_SYS_DIR}/${__f}"
|
|
||||||
log_debug "$func:${LINENO}: __m=$__m"
|
# TODO: das kopieren in die system-verzeichnisse muss noch getestet
|
||||||
elif grep -qE "^.*[.]json\s*$" <<< ${f}; then
|
# werden. stimmt noch nicht so ganz.
|
||||||
__p=" ${CONF_SYS_DIR}/${__f}"
|
|
||||||
log_debug "$func:${LINENO}: __m=$__m"
|
#if grep -qE "^.*$DC\s*$" <<< ${f}; then
|
||||||
elif grep -qE "^.*[.]ini\s*$" <<< ${f}; then
|
# __p="${DC_SYS_DIR}/${__f}"
|
||||||
if [ "$__f" = "$ATBQT_INI" ]; then
|
# log_debug "$func:${LINENO}: __m=$__m"
|
||||||
log_debug "$func:${LINENO}: __m=$__m $ATB_SYS_DIR/$__f ${f%/*}"
|
#elif grep -qE "^.*tariff[0-9][0-9][.]json\s*$" <<< ${f}; then
|
||||||
if grep -qE "$ATB_SYS_DIR" <<< "${f%/*}"; then
|
# __p="${TARIFF_SYS_DIR}/${__f}"
|
||||||
__p="$ATB_SYS_DIR/${__f}"
|
#elif grep -qE "^.*[.]json\s*$" <<< ${f}; then
|
||||||
else
|
# __p="${CONF_SYS_DIR}/${__f}"
|
||||||
__p="$ATBAPP_SYS_DIR/${__f}"
|
# log_debug "$func:${LINENO}: __m=$__m"
|
||||||
fi
|
#elif grep -qE "^.*[.]ini\s*$" <<< ${f}; then
|
||||||
elif [ "$__f" = "$SYSTEM_CONTROL_INI" ]; then
|
# if [ "$__f" = "$ATBQT_INI" ]; then
|
||||||
if grep -qE "$ATB_SYS_DIR" <<< "${f%/*}"; then
|
# log_debug "$func:${LINENO}: __m=$__m $ATB_SYS_DIR/$__f ${f%/*}"
|
||||||
__p="$ATB_SYS_DIR/${__f}"
|
# if grep -qE "$ATB_SYS_DIR" <<< "${f%/*}"; then
|
||||||
else
|
# __p="$ATB_SYS_DIR/${__f}"
|
||||||
__p="$SYSCONFIG_SYS_DIR/${__f}"
|
# else
|
||||||
fi
|
# __p="$ATBAPP_SYS_DIR/${__f}"
|
||||||
elif [ "$__f" = "$SYS_CONFIG_INI" ]; then
|
# fi
|
||||||
if grep -qE "$ATB_SYS_DIR" <<< "${f%/*}"; then
|
# elif [ "$__f" = "$SYSTEM_CONTROL_INI" ]; then
|
||||||
__p="$ATB_SYS_DIR/${__f}"
|
# if grep -qE "$ATB_SYS_DIR" <<< "${f%/*}"; then
|
||||||
else
|
# __p="$ATB_SYS_DIR/${__f}"
|
||||||
__p="$SYSCONFIG_SYS_DIR/${__f}"
|
# else
|
||||||
fi
|
# __p="$SYSCONFIG_SYS_DIR/${__f}"
|
||||||
elif [ "$__f" = "$ISMASMGR_INI" ]; then
|
# fi
|
||||||
if grep -qE "$ISMASMGR_SYS_DIR" <<< "${f%/*}"; then
|
# elif [ "$__f" = "$SYS_CONFIG_INI" ]; then
|
||||||
__p="$ISMASMGR_SYS_DIR/${__f}"
|
# if grep -qE "$ATB_SYS_DIR" <<< "${f%/*}"; then
|
||||||
elif grep -qE "$ATB_SYS_DIR" <<< "${f%/*}"; then
|
# __p="$ATB_SYS_DIR/${__f}"
|
||||||
__p="$ATB_SYS_DIR/${__f}"
|
# else
|
||||||
else
|
# __p="$SYSCONFIG_SYS_DIR/${__f}"
|
||||||
__p="$SYSCONFIG_SYS_DIR/${__f}"
|
# fi
|
||||||
fi
|
# elif [ "$__f" = "$ISMASMGR_INI" ]; then
|
||||||
fi
|
# if grep -qE "$ISMASMGR_SYS_DIR" <<< "${f%/*}"; then
|
||||||
fi
|
# __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 [ ! -z "$__p" ]; then
|
||||||
if cp "$__m" "$__p"; then
|
if cp "$__m" "$__p"; then
|
||||||
@@ -158,68 +179,26 @@ check_md5_for_changed_json_and_ini_files () {
|
|||||||
readarray -td' ' files <<< "$1"
|
readarray -td' ' files <<< "$1"
|
||||||
local readonly __cl=$CUSTOMER_LOCATION
|
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" =~ .*dc2c.hex.* ]]; then
|
js_key=""
|
||||||
js_key=".dc.dc2c.$__bn"
|
|
||||||
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" =~ .*cash[.]json.* ]]; then
|
local __key_suffix=$(echo $file |
|
||||||
js_key=".conf.$__cl.zg[1].z[1].etc.psa_config.$__bn"
|
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" =~ .*print[0-9][0-9][.]json.* ]]; then
|
md5sum_repository="$(md5_of $CUSTOMER_ID_BASE_DIR/$file)"
|
||||||
js_key=".conf.$__cl.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)"
|
log_crit "$func:${LINENO} unknown file=${file}"
|
||||||
elif [[ "$file" =~ .*conf[.]json.* ]]; then
|
;;
|
||||||
js_key=".conf.$__cl.zg[1].z[1].etc.psa_config.DC2C_conf"
|
esac
|
||||||
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
|
|
||||||
md5sum_repository="$(md5_of $CUSTOMER_ID_BASE_DIR/$file)"
|
test -z $js_key && continue
|
||||||
elif [[ "$file" =~ .*serial[.]json.* ]]; then
|
|
||||||
js_key=".conf.$__cl.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)"
|
|
||||||
elif [[ "$file" =~ .*atb/ATBQT[.]ini.* ]]; then
|
|
||||||
js_key=".ini.$__cl.zg[1].z[1].etc.atb.ATBQT"
|
|
||||||
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
|
|
||||||
md5sum_repository="$(md5_of $ATB_ATBQT_INI_FULL)"
|
|
||||||
elif [[ "$file" =~ .*ATBQT[.]ini.* ]]; then
|
|
||||||
js_key=".ini.$__cl.zg[1].z[1].opt.app.ATBAPP.ATBQT"
|
|
||||||
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
|
|
||||||
md5sum_repository="$(md5_of $ATBQT_INI_FULL)"
|
|
||||||
elif [[ "$file" =~ .*atb/sysconfig[.]ini.* ]]; then
|
|
||||||
js_key=".ini.$__cl.zg[1].z[1].etc.atb.sysconfig"
|
|
||||||
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
|
|
||||||
md5sum_repository="$(md5_of $ATB_SYSCONFIG_INI_FULL)"
|
|
||||||
elif [[ "$file" =~ .*sysconfig[.]ini.* ]]; then
|
|
||||||
js_key=".ini.$__cl.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" =~ .*atb/SystemControl[.]ini.* ]]; then
|
|
||||||
js_key=".ini.$__cl.zg[1].z[1].etc.atb.SystemControl"
|
|
||||||
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
|
|
||||||
md5sum_repository="$(md5_of $ATB_SYSCTRL_INI_FULL)"
|
|
||||||
elif [[ "$file" =~ .*SystemControl[.]ini.* ]]; then
|
|
||||||
js_key=".ini.$__cl.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" =~ .*atb/ISMASMgr[.]ini.* ]]; then
|
|
||||||
js_key=".ini.$__cl.zg[1].z[1].etc.atb.ISMASMgr"
|
|
||||||
md5sum_update_conf=$(cat $UPDATE_CONF | jq -r $js_key)
|
|
||||||
md5sum_repository="$(md5_of $ATB_ISMASMGR_INI_FULL)"
|
|
||||||
elif [[ "$file" =~ .*ISMASMgr/ISMASMgr[.]ini.* ]]; then
|
|
||||||
js_key=".ini.$__cl.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.$__cl.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
|
||||||
@@ -398,6 +377,14 @@ check_for_apism () {
|
|||||||
nc localhost 7778
|
nc localhost 7778
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_customer_id () {
|
||||||
|
echo $(cat CUST_ID_FILE)
|
||||||
|
}
|
||||||
|
|
||||||
|
get_zone_nr () {
|
||||||
|
echo $(cat ZONE_FILE)
|
||||||
|
}
|
||||||
|
|
||||||
get_plugins () {
|
get_plugins () {
|
||||||
local __plugins=""
|
local __plugins=""
|
||||||
for __f in /opt/app/ATBAPP/plugins/*; do
|
for __f in /opt/app/ATBAPP/plugins/*; do
|
||||||
|
208
update_psa_impl
208
update_psa_impl
@@ -16,8 +16,8 @@ collect_current_configuration () {
|
|||||||
# TODO: eventuell muss die version neu berechnet werden
|
# TODO: eventuell muss die version neu berechnet werden
|
||||||
current_settings_to_ismas
|
current_settings_to_ismas
|
||||||
|
|
||||||
#for line in $(cat $UPDATE_CONF |\
|
#for line in $(cat $PSA_UPDATE_CONF |\
|
||||||
# jq -r .conf.szeged.zg[1].z[1].etc.psa_config)
|
# jq -r .conf.szeged.zg[$ZONE_GROUP].z[$ZONE].etc.psa_config)
|
||||||
#do
|
#do
|
||||||
# conf_file="$(echo $line |
|
# conf_file="$(echo $line |
|
||||||
# sed -E -ne 's/^[^{}]\s+\"(DC2C_[[:alnum:]]+)\".*$/\1/gp')"
|
# sed -E -ne 's/^[^{}]\s+\"(DC2C_[[:alnum:]]+)\".*$/\1/gp')"
|
||||||
@@ -28,145 +28,112 @@ collect_current_configuration () {
|
|||||||
#done
|
#done
|
||||||
}
|
}
|
||||||
|
|
||||||
update_psa() {
|
update_psa() { # calling with a parameter is used for testing
|
||||||
|
|
||||||
if ! updates_available; then # check for false alarm
|
if [ $# -eq 0 ]; then
|
||||||
update_psa_false_alarm "update requested, but no WAIT state detected"
|
if ! updates_available; then # check for false alarm
|
||||||
exit $?
|
update_psa_false_alarm "update requested, but no WAIT state detected"
|
||||||
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
fi
|
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..."
|
log_debug "$func:${LINENO}: fetch/merge updates..."
|
||||||
|
|
||||||
# Fetch new updates (using git)
|
# Fetch new updates (using git). but only when repository has already been
|
||||||
while :
|
# cloned.
|
||||||
do
|
if [ $GIT_CLONE_EXECUTED -eq 0 ]; then
|
||||||
local repository_is_already_up_to_date=""
|
if ! fetch_customer_updates; then
|
||||||
if ! fetch_customer_updates repository_is_already_up_to_date; then
|
log_error "$func:${LINENO}: fetch no data for $customer_id"\
|
||||||
if [ "$repository_is_already_up_to_date" = "yes" ]; then
|
"-> no files to update -> no psa update"
|
||||||
log_error "$func:${LINENO}: $customer_id is up-to-date"\
|
update_psa_false_alarm \
|
||||||
"-> no files to update -> no psa update"
|
"update request, but no change in $CUSTOMER_REPOSITORY_PATH"
|
||||||
update_psa_false_alarm \
|
# TODO
|
||||||
"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
|
fi
|
||||||
done
|
fi
|
||||||
|
|
||||||
update_psa_pull_customer_repository # message to ISMAS
|
update_psa_pull_customer_repository # message to ISMAS
|
||||||
|
|
||||||
# TODO: backup implementieren
|
# no backup necessary as saved in git-repo
|
||||||
# Backup before any updates in case some previous test was wrong
|
|
||||||
if ! backup_previous_version; then
|
# local changed_files=$(changed_file_names)
|
||||||
log_error "$func:${LINENO}: backup failed"
|
|
||||||
revert_customer_repository
|
if [[ -f "$GIT_PULL_TMP" ]]; then
|
||||||
update_psa_backup_error # message to ISMAS
|
# TODO
|
||||||
exit $?
|
if ! check_hardware_compatibility "$files_to_copy" ; then
|
||||||
|
local __r=$?
|
||||||
|
log_error "$func:${LINENO}: json/ini-files not fit for PSA"
|
||||||
|
revert_customer_repository
|
||||||
|
exit $__r
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
update_psa_backup # message to ISMAS
|
if [[ -f "$OPKG_CMDS_TMP" ]]; then
|
||||||
|
local commands="$(cat ${OPKG_CMDS_TMP} | tr '\n' '; ')"
|
||||||
# TODO: use CLONE_CUSTOMER_REPOSITORY=true
|
log_info "$func:${LINENO}: executed opkg commands"
|
||||||
# d.h. wird das rep geklont, also neu angelegt, dann sind eigentlich alle
|
update_psa_install_opkg_packages $UPDATE_ISMAS_PROGRESS \
|
||||||
# dateinen zu ueberpruefen
|
$RC_SUCCESS "$commands"
|
||||||
|
|
||||||
local changed_files=$(changed_file_names)
|
|
||||||
local files_to_copy=$(filter_changed_files "$changed_files" 'json|ini|hex')
|
|
||||||
|
|
||||||
update_psa_report_changed_file_names $changed_files # message to ISMAS
|
|
||||||
|
|
||||||
# check if *.conf and/or *.ini-files have to md5-sum as denoted
|
|
||||||
# in update.conf
|
|
||||||
if ! check_md5_for_changed_json_and_ini_files "$files_to_copy" ; then
|
|
||||||
local __r=$?
|
|
||||||
log_error "$func:${LINENO}: new customer files wrong"
|
|
||||||
revert_customer_repository
|
|
||||||
exit $__r
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! check_hardware_compatibility "$files_to_copy" ; then
|
|
||||||
local __r=$?
|
|
||||||
log_error "$func:${LINENO}: json/ini-files not fit for PSA"
|
|
||||||
revert_customer_repository
|
|
||||||
exit $__r
|
|
||||||
fi
|
|
||||||
|
|
||||||
# copy *.conf and/or *.ini-files to their corresponding system-directories
|
|
||||||
if ! copy $files_to_copy; 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
|
|
||||||
else
|
else
|
||||||
log_info "$func:${LINENO}: no opkg commands to execute"
|
log_info "$func:${LINENO}: no opkg commands to execute"
|
||||||
update_psa_install_opkg_packages $UPDATE_ISMAS_PROGRESS \
|
update_psa_install_opkg_packages $UPDATE_ISMAS_PROGRESS \
|
||||||
$RC_SUCCESS "no opkg commands to execute"
|
$RC_SUCCESS "no opkg commands to execute"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# check if the opkg-command-file has been changed during 'git pull'
|
||||||
|
#if grep -qE ".*opkg_commands.*?" <<< $changed_files; then
|
||||||
|
# # read opkg_cmds: each line respresents an opkg-command
|
||||||
|
# readarray opkg_commands < <(cat $OPKG_CMDS_PSA_FILE)
|
||||||
|
# for opkg_c in "${opkg_commands[@]}"; do
|
||||||
|
# if grep -qE "^\s*[#]+.*$" <<< $opkg_c; then
|
||||||
|
# continue # found comment line
|
||||||
|
# fi
|
||||||
|
|
||||||
|
# # package manipulation commands without package:
|
||||||
|
# local cwp="update|upgrade|clean"
|
||||||
|
# # informational commands without package:
|
||||||
|
# cwp="${cwp}|list|list-installed|list-upgradable"
|
||||||
|
|
||||||
|
# if grep -qE "^.*\s+($cwp)\s+.*$" <<< $opkg_c; then
|
||||||
|
# local p=$(printf '%s' "$opkg_c" | awk '{ print $NF }')
|
||||||
|
# local opkg_output=()
|
||||||
|
# if ! exec_opkg_info "$p" opkg_output; then
|
||||||
|
# log_error "$func:${LINENO}: opkg info $opkg_c failed"
|
||||||
|
# revert_customer_repository ; exit 1
|
||||||
|
# fi
|
||||||
|
|
||||||
|
# if ! check_md5_for_opkg_packages opkg_output; then
|
||||||
|
# log_error "$func:${LINENO}: "\
|
||||||
|
# "wrong md5sum for opkg packages"
|
||||||
|
# revert_customer_repository ; exit 1
|
||||||
|
# fi
|
||||||
|
# fi
|
||||||
|
#
|
||||||
|
# # perform a dry-run and check if everything might work as expected.
|
||||||
|
# if ! exec_opkg_noaction $opkg_c; then
|
||||||
|
# log_error "$func:${LINENO}: "\
|
||||||
|
# "opkg --noaction $opkg_c failed"
|
||||||
|
# fi
|
||||||
|
|
||||||
|
# # Actually execute the opkg command
|
||||||
|
# if ! exec_opkg $opkg_c; then
|
||||||
|
# log_error "$func:${LINENO}: exec_opkg $opkg_c failed"
|
||||||
|
# fallback_to_previous_version
|
||||||
|
# revert_customer_repository ; exit 1
|
||||||
|
# fi
|
||||||
|
# done
|
||||||
|
#else
|
||||||
|
# log_info "$func:${LINENO}: no opkg commands to execute"
|
||||||
|
# update_psa_install_opkg_packages $UPDATE_ISMAS_PROGRESS \
|
||||||
|
# $RC_SUCCESS "no opkg commands to execute"
|
||||||
|
#fi
|
||||||
|
|
||||||
# Cleanup.
|
# Cleanup.
|
||||||
if ! cleanup_previous_version; then
|
#if ! cleanup_previous_version; then
|
||||||
log_error "$func:${LINENO}: cleanup_previous_version failed"
|
# log_error "$func:${LINENO}: cleanup_previous_version failed"
|
||||||
fi
|
#fi
|
||||||
|
|
||||||
# compute version string for current (i.e. new) version
|
# compute version string for current (i.e. new) version
|
||||||
compute_version
|
compute_version
|
||||||
@@ -174,6 +141,7 @@ update_psa() {
|
|||||||
update_psa_cleanup $UPDATE_ISMAS_PROGRESS \
|
update_psa_cleanup $UPDATE_ISMAS_PROGRESS \
|
||||||
$RC_SUCCESS "cleanup after psa update"
|
$RC_SUCCESS "cleanup after psa update"
|
||||||
|
|
||||||
|
# TODO
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user