Compare commits
4 Commits
bc4977bf7f
...
24ead237cc
Author | SHA1 | Date | |
---|---|---|---|
24ead237cc | |||
cb7cb51b24 | |||
cb0586fb6b | |||
094580e294 |
15
git_helpers
15
git_helpers
@ -87,7 +87,7 @@ clone_customer_repository () {
|
|||||||
log_fatal "$func:${LINENO} "\
|
log_fatal "$func:${LINENO} "\
|
||||||
"wrong repository: $(ls -d './${workspace_dir}/*')"
|
"wrong repository: $(ls -d './${workspace_dir}/*')"
|
||||||
else
|
else
|
||||||
local __m= "./${workspace_dir}/$customer_id exists"
|
local __m="./${workspace_dir}/$customer_id exists"
|
||||||
log_debug "$func:${LINENO} $__m"
|
log_debug "$func:${LINENO} $__m"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@ -238,13 +238,20 @@ changed_file_names () {
|
|||||||
git_res=${git_res//[$'\r\n\t']/ }
|
git_res=${git_res//[$'\r\n\t']/ }
|
||||||
log_debug "$func:${LINENO}: git_res=$git_res"
|
log_debug "$func:${LINENO}: git_res=$git_res"
|
||||||
local file_names=""
|
local file_names=""
|
||||||
for f in 'update.conf' 'opkg_commands' ; do
|
local known_files=(update.conf current.conf emp.conf)
|
||||||
if grep -qE ".*${f}.*?" <<< $git_res; then
|
known_files=(${known_files[@]} device.conf printer.conf opkg_commands)
|
||||||
|
for f in ${known_files[@]} ; do
|
||||||
|
if grep -qE ".*/${f}\s+.*" <<< $git_res; then
|
||||||
|
if ! [ -z $file_names ]; then
|
||||||
file_names="$f $file_names"
|
file_names="$f $file_names"
|
||||||
|
else
|
||||||
|
file_names="$f"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
cd_home ; printf "$file_names"
|
cd_home; log_debug "$func:${LINENO}: file_names=$file_names" ;
|
||||||
|
printf '%s' "$file_names"
|
||||||
else
|
else
|
||||||
log_crit "$func:${LINENO}: cannot cd to $customer_repository "\
|
log_crit "$func:${LINENO}: cannot cd to $customer_repository "\
|
||||||
"while in $PWD"
|
"while in $PWD"
|
||||||
|
20
read_config
20
read_config
@ -59,13 +59,27 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
|||||||
|
|
||||||
log_info "$func:${LINENO}: customer-location-dir is $customer_location_dir"
|
log_info "$func:${LINENO}: customer-location-dir is $customer_location_dir"
|
||||||
|
|
||||||
readonly customer_base_dir="${__customer_base_dir}/${zone_group}/${zone}"
|
readonly update_conf="${customer_location_dir}/update.conf"
|
||||||
|
log_info "$func:${LINENO}: update.conf at $update_conf"
|
||||||
|
|
||||||
|
readonly current_conf="${customer_location_dir}/current.conf"
|
||||||
|
log_info "$func:${LINENO}: current.conf at $current_conf"
|
||||||
|
|
||||||
|
readonly customer_base_dir="${__customer_base_dir}/${zone_group}/${zone}"
|
||||||
log_info "$func:${LINENO}: customer-base-dir is $customer_base_dir"
|
log_info "$func:${LINENO}: customer-base-dir is $customer_base_dir"
|
||||||
|
|
||||||
readonly opkg_cmds_file="${customer_base_dir}/etc/psa_update/opkg_commands"
|
readonly emp_conf="${customer_base_dir}/etc/psa_config/emp.conf"
|
||||||
|
log_info "$func:${LINENO}: emp.conf at $emp_conf"
|
||||||
|
|
||||||
|
readonly device_conf="${customer_base_dir}/etc/psa_config/device.conf"
|
||||||
|
log_info "$func:${LINENO}: device.conf at $device_conf"
|
||||||
|
|
||||||
|
readonly printer_conf="${customer_base_dir}/etc/psa_config/printer.conf"
|
||||||
|
log_info "$func:${LINENO}: device.conf at $printer_conf"
|
||||||
|
|
||||||
|
readonly opkg_cmds_file="${customer_base_dir}/etc/psa_update/opkg_commands"
|
||||||
|
log_info "$func:${LINENO}: opkg_cmds_file at $opkg_cmds_file"
|
||||||
|
|
||||||
log_info "$func:${LINENO}: opkg_cmds_file is $opkg_cmds_file"
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
# read_config UpdateController.conf
|
# read_config UpdateController.conf
|
||||||
|
@ -89,9 +89,9 @@ update() {
|
|||||||
revert_customer_repository ; exit 1
|
revert_customer_repository ; exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# TODO: implementieren, opkg pakete ausschliessen
|
local files=$(changed_file_names)
|
||||||
files=$(changed_file_names)
|
|
||||||
if ! check_md5_for_changed_customer_files $files ; then
|
if ! check_md5_for_changed_conf_and_ini_files "$files" ; then
|
||||||
log_error "$func:${LINENO}: new customer files wrong"
|
log_error "$func:${LINENO}: new customer files wrong"
|
||||||
revert_customer_repository ; exit 1
|
revert_customer_repository ; exit 1
|
||||||
fi
|
fi
|
||||||
@ -125,7 +125,7 @@ update() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# perform a dry-run and check if everything might work as expected.
|
# perform a dry-run and check if everything might work as expected.
|
||||||
if ! exec_opkg_no_action $opkg_c; then
|
if ! exec_opkg_noaction $opkg_c; then
|
||||||
log_error "$func:${LINENO}: "\
|
log_error "$func:${LINENO}: "\
|
||||||
"opkg --noaction $opkg_c failed"
|
"opkg --noaction $opkg_c failed"
|
||||||
fi
|
fi
|
||||||
|
@ -34,14 +34,44 @@ fetch_customer_updates() {
|
|||||||
# Check if the fetched/merged files have the correct md5 and are
|
# Check if the fetched/merged files have the correct md5 and are
|
||||||
# valid for the PSA.
|
# valid for the PSA.
|
||||||
#
|
#
|
||||||
check_md5_for_changed_customer_files () {
|
check_md5_for_changed_conf_and_ini_files () {
|
||||||
local func="${FUNCNAME[0]}"
|
local func="${FUNCNAME[0]}"
|
||||||
#for file in ($1); do
|
local json_key=""
|
||||||
# Check the updates for correct MD5
|
local md5sum_update_conf=""
|
||||||
# log_error "$func:${LINENO}: new customer files wrong"
|
local md5sum_repository=""
|
||||||
# revert_customer_repository ; exit 1
|
log_debug "$func:${LINENO} files=$1"
|
||||||
# fi
|
if ! [ -z $1 ]; then
|
||||||
#done
|
readarray -td' ' files <<< "$1"
|
||||||
|
for file in ${files[@]}; do
|
||||||
|
if [ "$file" = "emp.conf" ]; then
|
||||||
|
json_key=".conf.szeged.zg1.z1.etc.psa_config.emp"
|
||||||
|
md5sum_update_conf=$(cat $update_conf | jq -r $json_key)
|
||||||
|
md5sum_repository="$(md5sum $emp_conf | awk '{ print $1}')"
|
||||||
|
elif [ "$file" = "printer.conf" ]; then
|
||||||
|
json_key=".conf.szeged.zg1.z1.etc.psa_config.printer"
|
||||||
|
md5sum_update_conf=$(cat $update_conf | jq -r $json_key)
|
||||||
|
md5sum_repository="$(md5sum $printer_conf | awk '{ print $1}')"
|
||||||
|
elif [ "$file" = "device.conf" ]; then
|
||||||
|
json_key=".conf.szeged.zg1.z1.etc.psa_config.device"
|
||||||
|
md5sum_update_conf=$(cat $update_conf | jq -r $json_key)
|
||||||
|
md5sum_repository="$(md5sum $device_conf | awk '{ print $1}')"
|
||||||
|
else
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$md5sum_repository" = "$md5sum_update_conf" ]; then
|
||||||
|
log_info "$func:${LINENO}: md5sum for $file ok"
|
||||||
|
else
|
||||||
|
local __r="repository: $md5sum_repository"
|
||||||
|
local __u="update.conf=$md5sum_update_conf"
|
||||||
|
local __m="$__r != $__u"
|
||||||
|
log_error "$func:${LINENO}: md5sum for $file wrong: $__m"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
log_debug "$func:${LINENO} no changed conf-/ini-files"
|
||||||
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +112,7 @@ check_md5_for_opkg_packages () {
|
|||||||
# In case the new checked-out files are not correct, revert the git
|
# In case the new checked-out files are not correct, revert the git
|
||||||
# repository to its previous state.
|
# repository to its previous state.
|
||||||
#
|
#
|
||||||
revert_customer_repository() {
|
revert_customer_repository () {
|
||||||
local func="${FUNCNAME[0]}"
|
local func="${FUNCNAME[0]}"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -137,11 +167,19 @@ exec_opkg_info () {
|
|||||||
# Try to install new opkg-packages (in case the are some
|
# Try to install new opkg-packages (in case the are some
|
||||||
# in the new git-checkout).
|
# in the new git-checkout).
|
||||||
#
|
#
|
||||||
exec_opkg_no_action() {
|
exec_opkg_noaction() {
|
||||||
local func="${FUNCNAME[0]}"
|
local func="${FUNCNAME[0]}"
|
||||||
local opkg_command_no_action="opkg --noaction $1"
|
local opkg_command_no_action="opkg --noaction $1"
|
||||||
log_info "$func:${LINENO}: executing $opkg_command_no_action"
|
log_debug "$func:${LINENO}: executing $opkg_command_no_action"
|
||||||
|
|
||||||
|
local __opkg_result=$(exec_opkg_command "opkg --noaction $1")
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
log_info "$func:${LINENO}: opkg_result=$__opkg_result"
|
||||||
return 0
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
log_error "$func:${LINENO}: error executing opkg --noaction $1"
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install the new packages using opkg.
|
# Install the new packages using opkg.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user