Compare commits
4 Commits
bc4977bf7f
...
24ead237cc
Author | SHA1 | Date | |
---|---|---|---|
24ead237cc | |||
cb7cb51b24 | |||
cb0586fb6b | |||
094580e294 |
13
git_helpers
13
git_helpers
@ -238,13 +238,20 @@ changed_file_names () {
|
||||
git_res=${git_res//[$'\r\n\t']/ }
|
||||
log_debug "$func:${LINENO}: git_res=$git_res"
|
||||
local file_names=""
|
||||
for f in 'update.conf' 'opkg_commands' ; do
|
||||
if grep -qE ".*${f}.*?" <<< $git_res; then
|
||||
local known_files=(update.conf current.conf emp.conf)
|
||||
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"
|
||||
else
|
||||
file_names="$f"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
cd_home ; printf "$file_names"
|
||||
cd_home; log_debug "$func:${LINENO}: file_names=$file_names" ;
|
||||
printf '%s' "$file_names"
|
||||
else
|
||||
log_crit "$func:${LINENO}: cannot cd to $customer_repository "\
|
||||
"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"
|
||||
|
||||
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"
|
||||
|
||||
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
|
||||
}
|
||||
# read_config UpdateController.conf
|
||||
|
@ -89,9 +89,9 @@ update() {
|
||||
revert_customer_repository ; exit 1
|
||||
fi
|
||||
|
||||
# TODO: implementieren, opkg pakete ausschliessen
|
||||
files=$(changed_file_names)
|
||||
if ! check_md5_for_changed_customer_files $files ; then
|
||||
local files=$(changed_file_names)
|
||||
|
||||
if ! check_md5_for_changed_conf_and_ini_files "$files" ; then
|
||||
log_error "$func:${LINENO}: new customer files wrong"
|
||||
revert_customer_repository ; exit 1
|
||||
fi
|
||||
@ -125,7 +125,7 @@ update() {
|
||||
fi
|
||||
|
||||
# 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}: "\
|
||||
"opkg --noaction $opkg_c failed"
|
||||
fi
|
||||
|
@ -34,14 +34,44 @@ fetch_customer_updates() {
|
||||
# Check if the fetched/merged files have the correct md5 and are
|
||||
# valid for the PSA.
|
||||
#
|
||||
check_md5_for_changed_customer_files () {
|
||||
check_md5_for_changed_conf_and_ini_files () {
|
||||
local func="${FUNCNAME[0]}"
|
||||
#for file in ($1); do
|
||||
# Check the updates for correct MD5
|
||||
# log_error "$func:${LINENO}: new customer files wrong"
|
||||
# revert_customer_repository ; exit 1
|
||||
# fi
|
||||
#done
|
||||
local json_key=""
|
||||
local md5sum_update_conf=""
|
||||
local md5sum_repository=""
|
||||
log_debug "$func:${LINENO} files=$1"
|
||||
if ! [ -z $1 ]; then
|
||||
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
|
||||
}
|
||||
|
||||
@ -137,11 +167,19 @@ exec_opkg_info () {
|
||||
# Try to install new opkg-packages (in case the are some
|
||||
# in the new git-checkout).
|
||||
#
|
||||
exec_opkg_no_action() {
|
||||
exec_opkg_noaction() {
|
||||
local func="${FUNCNAME[0]}"
|
||||
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
|
||||
fi
|
||||
|
||||
log_error "$func:${LINENO}: error executing opkg --noaction $1"
|
||||
return 1
|
||||
}
|
||||
|
||||
# Install the new packages using opkg.
|
||||
|
Loading…
x
Reference in New Issue
Block a user