Compare commits
2 commits
915b0db08b
...
91c4f6be4c
Author | SHA1 | Date | |
---|---|---|---|
91c4f6be4c | |||
21b5f8ff2d |
5 changed files with 59 additions and 3 deletions
|
@ -6,4 +6,5 @@ check() {
|
||||||
log debug "collected bkp files:\n$bkp_files"
|
log debug "collected bkp files:\n$bkp_files"
|
||||||
|
|
||||||
scan_packages
|
scan_packages
|
||||||
|
merge_base "$base_files"
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ scan_directory() {
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$files"
|
printf "%b" "$files"
|
||||||
}
|
}
|
||||||
|
|
||||||
scan_packages() {
|
scan_packages() {
|
||||||
|
|
20
src/file/merge_base.sh
Normal file
20
src/file/merge_base.sh
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
merge_base() {
|
||||||
|
local base_files="$1"
|
||||||
|
local strategy=
|
||||||
|
|
||||||
|
for file in $base_files; do
|
||||||
|
log debug "[merge-base] Processing $file"
|
||||||
|
local absolute_path="$(echo "$file" | sed 's/^base//')"
|
||||||
|
log debug "[merge-base] Absolute path: $absolute_path"
|
||||||
|
local config_path="$CONFIG_ROOT/$file"
|
||||||
|
log debug "[merge-base] Config path: $config_path"
|
||||||
|
|
||||||
|
if diff "$absolute_path" "$config_path" > /dev/null; then
|
||||||
|
log debug "[merge-base] Files match"
|
||||||
|
else
|
||||||
|
log debug "[merge-base] Files differ"
|
||||||
|
strategy="$(ask "Configuration and system files differ" "Overwrite system,Overwrite config,Show difference")"
|
||||||
|
log debug "[merge-base] Chosen strategy: $strategy"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
|
@ -9,3 +9,5 @@
|
||||||
. "$TORI_ROOT/src/package/validate_input_packages.sh"
|
. "$TORI_ROOT/src/package/validate_input_packages.sh"
|
||||||
. "$TORI_ROOT/src/package/package_conflict_input_parser.sh"
|
. "$TORI_ROOT/src/package/package_conflict_input_parser.sh"
|
||||||
. "$TORI_ROOT/src/package/update_package_cache.sh"
|
. "$TORI_ROOT/src/package/update_package_cache.sh"
|
||||||
|
|
||||||
|
. "$TORI_ROOT/src/file/merge_base.sh"
|
||||||
|
|
|
@ -5,11 +5,11 @@ log() {
|
||||||
local message="$2"
|
local message="$2"
|
||||||
|
|
||||||
print_user_message() {
|
print_user_message() {
|
||||||
echo "[tori] $(date "+%H:%M:%S"): $1" 1>&2
|
printf "%b\n" "[tori] $(date "+%H:%M:%S"): $1" 1>&2
|
||||||
}
|
}
|
||||||
|
|
||||||
print_debug_message() {
|
print_debug_message() {
|
||||||
echo "$(date "+%H:%M:%N") $1" 1>&2
|
printf "%b\n" "$(date "+%H:%M:%N") $1" 1>&2
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -z "$DEBUG" ]; then
|
if [ -z "$DEBUG" ]; then
|
||||||
|
@ -43,6 +43,39 @@ log() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
confirm() {
|
||||||
|
local question="$1"
|
||||||
|
local answer=
|
||||||
|
read -rp "$question [y/N] " answer
|
||||||
|
|
||||||
|
if [ "$answer" == y ] || [ "$answer" == Y ]; then
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
ask() {
|
||||||
|
local question="$1"
|
||||||
|
local options="$2"
|
||||||
|
local answer=
|
||||||
|
local options_count=0
|
||||||
|
local dialog_options=
|
||||||
|
|
||||||
|
local IFS=,
|
||||||
|
for option in $options; do
|
||||||
|
_=$((options_count+=1))
|
||||||
|
dialog_options="$dialog_options\n [$options_count] $option"
|
||||||
|
done;
|
||||||
|
IFS=
|
||||||
|
|
||||||
|
printf "%s" "$question" >&2
|
||||||
|
printf "%b" "$dialog_options" >&2
|
||||||
|
printf "\n%s" "Choose an option [1-$options_count] " >&2
|
||||||
|
read -r answer
|
||||||
|
echo "$answer"
|
||||||
|
}
|
||||||
|
|
||||||
set_opts() {
|
set_opts() {
|
||||||
local target="$1"
|
local target="$1"
|
||||||
local sign=
|
local sign=
|
||||||
|
|
Loading…
Reference in a new issue