From bfa0f9a0c70de14cb70a286b2a48cd6942ab2f74 Mon Sep 17 00:00:00 2001 From: Didier Date: Wed, 23 Aug 2023 06:36:14 +0200 Subject: [PATCH] feat: add some utils like tracking --- skip_steps.sh | 7 +++++++ sync.sh | 27 ++++++++++++++++++++------- unlink.sh | 2 +- 3 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 skip_steps.sh diff --git a/skip_steps.sh b/skip_steps.sh new file mode 100644 index 0000000..b6e9ee1 --- /dev/null +++ b/skip_steps.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +mkdir .dotfiles &>/dev/null + +for item in ${@:-update install_package_list run_system_scripts run_user_scripts link_home overlay}; do + echo "executed_step:$item" >> .dotfiles/pending_sync +done \ No newline at end of file diff --git a/sync.sh b/sync.sh index 593f38a..4b8f01a 100644 --- a/sync.sh +++ b/sync.sh @@ -99,21 +99,34 @@ __step_link_home() { for item in $(find ./home -type f); do path=$(echo $item | sed "s/\.\/home//") [ -z "$path" ] && continue + grep -q "$path" $trackingfile &> /dev/null && continue path="$HOME$path" mkdir -p $(dirname $path) &> /dev/null ln $item $path && echo "$path" >> $trackingfile done } +step() { + if ! grep -q "executed_step:$1" .dotfiles/pending_sync &> /dev/null; then + $(printf "__step_%s" "$1") + echo "executed_step:$1" >> .dotfiles/pending_sync + fi +} + mkdir -p .dotfiles &> /dev/null +touch .dotfiles/pending_sync if [ -n "$1" ]; then - $(printf "__step_%s" "$1") + step $1 else - __step_update - __step_install_package_list - __step_run_system_scripts - __step_run_user_scripts - __step_link_home - __step_overlay + echo "started_sync:$(date)" >> .dotfiles/log + step update + step install_package_list + step run_system_scripts + step run_user_scripts + step link_home + step overlay + echo "finished_sync:$(date)" >> .dotfiles/log fi + +unlink .dotfiles/pending_sync diff --git a/unlink.sh b/unlink.sh index 3650aa8..44e593c 100644 --- a/unlink.sh +++ b/unlink.sh @@ -1,6 +1,6 @@ #!/bin/sh -for linkfile in $@; do +for linkfile in ${@:-$(find .dotfiles -type f -name *-links)}; do echo "# processing linkfile $linkfile..." for link in $(cat $linkfile); do echo "# unlinking $link..."