Compare commits
No commits in common. "7713e7e39de074efcc6a407227f5b0067e45abd5" and "27f1a62323cfd6fa242bc19a82595b69bde6d2da" have entirely different histories.
7713e7e39d
...
27f1a62323
@ -1,26 +1,10 @@
|
||||
{
|
||||
"c1" : "use git without certificates",
|
||||
"GIT_SSL_NO_VERIFY" : 1,
|
||||
|
||||
"c2" : "start in working_directory",
|
||||
"GIT_SSL_NO_VERIFY" : true,
|
||||
"working_directory" : "/home/root/szeged/UpdateController",
|
||||
|
||||
"c3" : "directory for customer repository",
|
||||
"workspace_dir" : "workspace",
|
||||
|
||||
"c4" : "explicit location of customer-project",
|
||||
"customer_location" : "szeged",
|
||||
|
||||
"c5" : "unique customer identifier",
|
||||
"customer_id" : "281",
|
||||
|
||||
"c6" : "each location can have multiple",
|
||||
"c7" : "zone-groups and/or zones",
|
||||
"c8" : "0-index used as size of following array",
|
||||
"c9" : ".zone_group[0]: #n of zones_groups",
|
||||
"c10" : ".zone_group[1].zone[0]: #n of zones in zg[1]",
|
||||
"zone_group" : [ 1, { "zone" : [ 1, "1"] } ],
|
||||
|
||||
"c11" : "url of customer repository",
|
||||
"cust_repository_path" : "https://git.mimbach49.de/GerhardHoffmann"
|
||||
"zone_group" : "1",
|
||||
"zone" : "1",
|
||||
"repository_path" : "https://git.mimbach49.de/GerhardHoffmann"
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ source ./general_utils
|
||||
# if [ ${git_helpers_sourced:-1} = "1" ]; then
|
||||
# readonly git_helpers_sourced=${BASH_SOURCE[0]}
|
||||
|
||||
|
||||
|
||||
readonly GIT_SSL_NO_VERIFY=true
|
||||
readonly repository_already_up_to_date=2
|
||||
|
||||
#
|
||||
|
120
read_config
120
read_config
@ -11,113 +11,79 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
||||
read_config() {
|
||||
local func="${FUNCNAME[0]}"
|
||||
|
||||
readonly GIT_SSL_NO_VERIFY="$(cat "$1" | jq -r .GIT_SSL_NO_VERIFY)"
|
||||
if [ -z "$GIT_SSL_NO_VERIFY" ]; then
|
||||
log_fatal "$func:${LINENO} GIT_SSL_NO_VERIFY not set in $1"
|
||||
# check customer_id
|
||||
__customer_id="$(cat "$1" | jq -r .customer_id)"
|
||||
if [ -z "$__customer_id" ]; then
|
||||
log_fatal "$func:${LINENO} customer_id not set in $1"
|
||||
fi
|
||||
log_debug "$func:${LINENO}: GIT_SSL_NO_VERIFY=$GIT_SSL_NO_VERIFY"
|
||||
readonly customer_id="customer_${__customer_id}"
|
||||
log_info "$func:${LINENO}: customer-id is $customer_id"
|
||||
|
||||
readonly working_directory="$(cat "$1" | jq -r .working_directory)"
|
||||
if [ -z "$working_directory" ]; then
|
||||
log_fatal "$func:${LINENO}: working_directory not set in $1"
|
||||
# check customer_repository
|
||||
__repository_path="$(cat "$1" | jq -r .repository_path)"
|
||||
if [ -z "$__repository_path" ]; then
|
||||
log_fatal "$func:${LINENO}: repository path not set in $1"
|
||||
fi
|
||||
log_debug "$func:${LINENO}: working_directory=$working_directory"
|
||||
readonly repository_path="${__repository_path}/${customer_id}.git"
|
||||
log_info "$func:${LINENO}: repository path is $repository_path"
|
||||
|
||||
readonly workspace_dir="$(cat "$1" | jq -r .workspace_dir)"
|
||||
if [ -z "$workspace_dir" ]; then
|
||||
log_fatal "$func:${LINENO}: workspace_dir not set in $1"
|
||||
# check zone_group
|
||||
local zone_group="$(cat "$1" | jq -r .zone_group)"
|
||||
if [ -z "$zone_group" ]; then
|
||||
log_fatal "$func:${LINENO}: zone_group not set in $1"
|
||||
fi
|
||||
log_debug "$func:${LINENO}: workspace_dir=$working_dir"
|
||||
|
||||
# check zone
|
||||
local zone="$(cat "$1" | jq -r .zone)"
|
||||
if [ -z "$zone" ]; then
|
||||
log_fatal "$func:${LINENO}: zone not set in $1"
|
||||
fi
|
||||
|
||||
# check customer_location
|
||||
local customer_location=$(cat "$1" | jq -r .customer_location)
|
||||
if [ -z "$customer_location" ]; then
|
||||
log_fatal "$func:${LINENO}: customer_location not set in $1"
|
||||
fi
|
||||
log_debug "$func:${LINENO}: customer-location=$customer_location"
|
||||
|
||||
readonly customer_id="customer_$(cat "$1" | jq -r .customer_id)"
|
||||
if [ -z "$customer_id" ]; then
|
||||
log_fatal "$func:${LINENO} customer_id not set in $1"
|
||||
fi
|
||||
log_debug "$func:${LINENO}: customer-id=$customer_id"
|
||||
readonly working_directory="$(cat "$1" | jq -r .working_directory)"
|
||||
|
||||
local __r_path="$(cat "$1" | jq -r .cust_repository_path)"
|
||||
if [ -z "$__r_path" ]; then
|
||||
log_fatal "$func:${LINENO}: customer repository path not set in $1"
|
||||
fi
|
||||
readonly customer_repository_path="${__r_path}/${customer_id}.git"
|
||||
log_debug "$func:${LINENO}: customer r-path=$customer_repository_path"
|
||||
log_info "$func:${LINENO}: working_directory is $working_directory"
|
||||
|
||||
readonly number_of_zone_groups="$(cat "$1" | jq -r .zone_group[0])"
|
||||
log_debug "$func:${LINENO}: $number_of_zone_groups zone_group(s)"
|
||||
|
||||
local __zone_groups=(0)
|
||||
for zg in `seq 1 $number_of_zone_groups`; do
|
||||
local __n_zones="$(cat "$1" | jq -r .zone_group[$zg].zone[0])"
|
||||
__zone_groups[$zg]=$__n_zones
|
||||
done
|
||||
|
||||
###############################################################################
|
||||
########################## parsing with jq finished ###########################
|
||||
###############################################################################
|
||||
readonly workspace_dir="$(cat "$1" | jq -r .workspace_dir)"
|
||||
|
||||
local __customer_base_dir="$working_directory/${workspace_dir}"
|
||||
__customer_base_dir="${__customer_base_dir}/${customer_id}"
|
||||
__customer_base_dir="${__customer_base_dir}/${customer_location}"
|
||||
|
||||
readonly customer_location_dir="$__customer_base_dir"
|
||||
log_debug "$func:${LINENO}: customer_location_dir="
|
||||
log_debug "$func:${LINENO}: $customer_location_dir"
|
||||
|
||||
log_info "$func:${LINENO}: customer-location-dir is $customer_location_dir"
|
||||
|
||||
readonly update_conf="${customer_location_dir}/update.conf"
|
||||
log_debug "$func:${LINENO}: update.conf="
|
||||
log_debug "$func:${LINENO}: $update_conf"
|
||||
log_info "$func:${LINENO}: update.conf at $update_conf"
|
||||
|
||||
readonly current_conf="${customer_location_dir}/current.conf"
|
||||
log_debug "$func:${LINENO}: current.conf="
|
||||
log_debug "$func:${LINENO}: $current_conf"
|
||||
log_info "$func:${LINENO}: current.conf at $current_conf"
|
||||
|
||||
# readonly zone_groups=(${__zone_groups[@]})
|
||||
# for (( j=0; j<${#zone_groups[@]}; ++j)); do
|
||||
# log_debug "$func:${LINENO}: zgroup[$j]: ${zone_groups[$j]} zones"
|
||||
# done
|
||||
readonly customer_base_dir="${__customer_base_dir}/${zone_group}/${zone}"
|
||||
log_info "$func:${LINENO}: customer-base-dir is $customer_base_dir"
|
||||
|
||||
# TODO: falls mehrere gruppen/zonen auftauchen hier anpassen
|
||||
readonly zgroup=1
|
||||
readonly zone=1
|
||||
readonly customer_base_dir="${__customer_base_dir}/${zgroup}/${zone}"
|
||||
log_debug "$func:${LINENO}: customer-base-dir="
|
||||
log_debug "$func:${LINENO}: $customer_base_dir"
|
||||
readonly psa_config="${customer_base_dir}/etc/psa_config"
|
||||
readonly psa_update="${customer_base_dir}/etc/psa_update"
|
||||
readonly psa_ini="${customer_base_dir}/etc/psa_ini"
|
||||
|
||||
readonly psa_config_dir="${customer_base_dir}/etc/psa_config"
|
||||
log_debug "$func:${LINENO}: psa_config_dir="
|
||||
log_debug "$func:${LINENO}: $psa_config_dir"
|
||||
readonly emp_conf="${psa_config}/emp.conf"
|
||||
log_info "$func:${LINENO}: emp.conf at $emp_conf"
|
||||
|
||||
readonly psa_update_dir="${customer_base_dir}/etc/psa_update"
|
||||
log_debug "$func:${LINENO}: psa_update_dir="
|
||||
log_debug "$func:${LINENO}: $psa_update_dir"
|
||||
readonly device_conf="${psa_config}/device.conf"
|
||||
log_info "$func:${LINENO}: device.conf at $device_conf"
|
||||
|
||||
readonly psa_base_ini_dir="${customer_base_dir}/opt/app"
|
||||
log_debug "$func:${LINENO}: psa_base_ini_dir="
|
||||
log_debug "$func:${LINENO}: $psa_base_ini_dir"
|
||||
readonly printer_conf="${psa_config}/printer.conf"
|
||||
log_info "$func:${LINENO}: device.conf at $printer_conf"
|
||||
|
||||
readonly emp_conf="${psa_config_dir}/emp.conf"
|
||||
log_debug "$func:${LINENO}: emp.conf="
|
||||
log_debug "$func:${LINENO}: $emp_conf"
|
||||
readonly opkg_cmds_file="${psa_update}/opkg_commands"
|
||||
log_info "$func:${LINENO}: opkg_cmds_file at $opkg_cmds_file"
|
||||
|
||||
readonly device_conf="${psa_config_dir}/device.conf"
|
||||
log_debug "$func:${LINENO}: device.conf="
|
||||
log_debug "$func:${LINENO}: $device_conf"
|
||||
|
||||
readonly printer_conf="${psa_config_dir}/printer.conf"
|
||||
log_debug "$func:${LINENO}: printer.conf="
|
||||
log_debug "$func:${LINENO}: $printer_conf"
|
||||
|
||||
readonly opkg_cmds_file="${psa_update_dir}/opkg_commands"
|
||||
log_debug "$func:${LINENO}: opkg_commands="
|
||||
log_debug "$func:${LINENO}: $opkg_cmds_file"
|
||||
|
||||
# FIXME: die "ini"-files fehlen noch
|
||||
return 0
|
||||
}
|
||||
# read_config UpdateController.conf
|
||||
|
@ -90,22 +90,18 @@ update() {
|
||||
fi
|
||||
|
||||
local files=$(changed_file_names)
|
||||
local system_files=$(filter_system_files "$files") # conf/ini-files
|
||||
local system_files=$(filter_system_files "$files") # conf/ini-files
|
||||
|
||||
# check if *.conf and/or *.ini-files have to md5-sum as denoted
|
||||
# in update.conf
|
||||
if ! check_md5_for_changed_conf_and_ini_files "$system_files" ; then
|
||||
log_error "$func:${LINENO}: new customer files wrong"
|
||||
revert_customer_repository ; exit 1
|
||||
fi
|
||||
|
||||
# copy *.conf and/or *.ini-files to their corresponding system-directories
|
||||
if ! copy $system_files; then
|
||||
log_error "$func:${LINENO}: copy operation failed"
|
||||
revert_customer_repository ; exit 1
|
||||
fi
|
||||
|
||||
# check if the opkg-command-file has been changed during 'git pull'
|
||||
if grep -qE ".*opkg_commands.*?" <<< $files; then
|
||||
# read opkg_cmds: each line respresents an opkg-command
|
||||
readarray opkg_commands < <(cat $opkg_cmds_file)
|
||||
@ -172,7 +168,7 @@ else
|
||||
|
||||
if read_config "$1" ; then
|
||||
# set -x
|
||||
if clone_customer_repository $customer_repository_path ; then
|
||||
if clone_customer_repository $repository_path ; then
|
||||
update
|
||||
fi
|
||||
fi
|
||||
|
@ -37,7 +37,7 @@ copy () {
|
||||
readarray -td' ' files <<< "$1"
|
||||
for f in ${files[@]}; do
|
||||
if grep -qE "^.*[.]conf.*$" <<< ${f}; then
|
||||
local __f="${psa_config_dir}/${f}"
|
||||
local __f="${psa_config}/${f}"
|
||||
if ! cp ${__f} /etc/psa_config; then
|
||||
log_error "$func:${LINENO}: cannot cp ${__f} /etc/psa_config"
|
||||
return 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user