tori/check

44 lines
817 B
Text
Raw Normal View History

2024-06-26 14:33:34 +02:00
#! /usr/bin/env sh
# user-configured settings
TORI_ROOT="$HOME/.config/tori"
2024-06-26 15:47:20 +02:00
# global state
files=
base_files=
bkp_files=
2024-06-26 15:47:20 +02:00
2024-06-26 14:33:34 +02:00
# application logic
log() {
local level="$1" # unimplemented
local message="$2"
2024-06-26 15:47:20 +02:00
if [ -n "$DEBUG" ] && [ $level = debug ]; then
printf "$(date "+%H:%M:%N") $message\n"
fi
2024-06-26 14:33:34 +02:00
}
scan_directory() {
2024-06-26 14:33:34 +02:00
local target="$1"
local files=
local escaped_config_root="$(echo $TORI_ROOT | sed 's/\//\\\//g')"
2024-06-26 14:33:34 +02:00
2024-06-26 15:47:20 +02:00
if [ -d "$target" ]; then
scan="$(find "$target" -type f)"
for line in $scan; do
line="$(echo $line | sed "s/$escaped_config_root\///")"
files="$line\n$files"
done
2024-06-26 14:33:34 +02:00
fi
2024-06-26 15:47:20 +02:00
echo "$files"
2024-06-26 14:33:34 +02:00
}
base_files="$(scan_directory "$TORI_ROOT/base")"
bkp_files="$(scan_directory "$TORI_ROOT/bkp")"
log debug "collected base files:\n$base_files"
log debug "collected bkp files:\n$bkp_files"