home.sh update.

This commit is contained in:
Johannes Findeisen 2025-09-10 00:32:22 +02:00
commit 04e4d59435

View file

@ -34,6 +34,7 @@ function home() {
;; ;;
up) up)
cd ~ cd ~
if test -f .lastupdate; then
last_update=$(stat -c %Y .lastupdate) last_update=$(stat -c %Y .lastupdate)
echo "Last configuration update: $last_update" echo "Last configuration update: $last_update"
current_date=$(date +%s) current_date=$(date +%s)
@ -41,14 +42,21 @@ function home() {
time_diff=$(($current_date-$last_update)) time_diff=$(($current_date-$last_update))
echo "Time difference: $time_diff" echo "Time difference: $time_diff"
if (( time_diff > 86400 )) || [ "$2" = "f" ]; then if (( time_diff > 86400 )) || [ "$2" = "f" ]; then
echo "Doing home up..." echo "Updating home configuration..."
git pull if git pull; then
git submodule update --init --recursive if git submodule update --init --recursive; then
touch .lastupdate touch .lastupdate
fi
fi
else else
echo "/home/hanez was already updated in the last 24 hours." echo "/home/hanez was already updated in the last 24 hours."
echo "Run this to force updating: home up f" echo "Run this to force updating: home up f"
fi fi
else
echo "~/.lastupdate does not exist!"
echo "Running: home up f now..."
touch .lastupdate
fi
cd $OLDPWD cd $OLDPWD
;; ;;
*) *)