feat: add some utils like tracking

This commit is contained in:
Strix 2023-10-14 22:38:11 +02:00
parent 8ba156a62b
commit c2eedb304e
No known key found for this signature in database
GPG key ID: 49B2E37B8915B774
3 changed files with 28 additions and 8 deletions

7
skip_steps.sh Normal file
View file

@ -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

27
sync.sh
View file

@ -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

View file

@ -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..."