home.sh update.
This commit is contained in:
parent
08cffcb17f
commit
04e4d59435
1 changed files with 21 additions and 13 deletions
|
|
@ -34,20 +34,28 @@ function home() {
|
||||||
;;
|
;;
|
||||||
up)
|
up)
|
||||||
cd ~
|
cd ~
|
||||||
last_update=$(stat -c %Y .lastupdate)
|
if test -f .lastupdate; then
|
||||||
echo "Last configuration update: $last_update"
|
last_update=$(stat -c %Y .lastupdate)
|
||||||
current_date=$(date +%s)
|
echo "Last configuration update: $last_update"
|
||||||
echo "Current date: $current_date"
|
current_date=$(date +%s)
|
||||||
time_diff=$(($current_date-$last_update))
|
echo "Current date: $current_date"
|
||||||
echo "Time difference: $time_diff"
|
time_diff=$(($current_date-$last_update))
|
||||||
if (( time_diff > 86400 )) || [ "$2" = "f" ]; then
|
echo "Time difference: $time_diff"
|
||||||
echo "Doing home up..."
|
if (( time_diff > 86400 )) || [ "$2" = "f" ]; then
|
||||||
git pull
|
echo "Updating home configuration..."
|
||||||
git submodule update --init --recursive
|
if git pull; then
|
||||||
touch .lastupdate
|
if git submodule update --init --recursive; then
|
||||||
|
touch .lastupdate
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "/home/hanez was already updated in the last 24 hours."
|
||||||
|
echo "Run this to force updating: home up f"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "/home/hanez was already updated in the last 24 hours."
|
echo "~/.lastupdate does not exist!"
|
||||||
echo "Run this to force updating: home up f"
|
echo "Running: home up f now..."
|
||||||
|
touch .lastupdate
|
||||||
fi
|
fi
|
||||||
cd $OLDPWD
|
cd $OLDPWD
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue