home.sh update.
This commit is contained in:
parent
9ba94267a4
commit
08cffcb17f
1 changed files with 19 additions and 13 deletions
|
|
@ -1,10 +1,10 @@
|
||||||
function _home_help() {
|
function _home_help() {
|
||||||
echo "available commands:"
|
echo "Available commands:"
|
||||||
echo ""
|
echo ""
|
||||||
echo "help: show this help text"
|
echo "help: Show this help text."
|
||||||
echo "pull: execute git pull in $HOME"
|
echo "pull: Execute git pull in $HOME."
|
||||||
echo "sub: update all submodules of $HOME"
|
echo "sub: Update all submodules of $HOME."
|
||||||
echo "up: pull and update submodules in $HOME"
|
echo "up: Pull and update submodules in $HOME."
|
||||||
}
|
}
|
||||||
|
|
||||||
function home() {
|
function home() {
|
||||||
|
|
@ -12,41 +12,47 @@ function home() {
|
||||||
diff)
|
diff)
|
||||||
cd ~
|
cd ~
|
||||||
git diff
|
git diff
|
||||||
|
cd $OLDPWD
|
||||||
;;
|
;;
|
||||||
help)
|
help)
|
||||||
_home_help
|
_foo_help
|
||||||
;;
|
;;
|
||||||
pull)
|
pull)
|
||||||
cd ~
|
cd ~
|
||||||
git pull
|
git pull
|
||||||
|
cd $OLDPWD
|
||||||
;;
|
;;
|
||||||
status)
|
status)
|
||||||
cd ~
|
cd ~
|
||||||
git status
|
git status
|
||||||
|
cd $OLDPWD
|
||||||
;;
|
;;
|
||||||
sub)
|
sub)
|
||||||
cd ~
|
cd ~
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
|
cd $OLDPWD
|
||||||
;;
|
;;
|
||||||
up)
|
up)
|
||||||
cd ~
|
cd ~
|
||||||
last_update=$(stat -c %Y .lastupdate)
|
last_update=$(stat -c %Y .lastupdate)
|
||||||
|
echo "Last configuration update: $last_update"
|
||||||
current_date=$(date +%s)
|
current_date=$(date +%s)
|
||||||
|
echo "Current date: $current_date"
|
||||||
time_diff=$(($current_date-$last_update))
|
time_diff=$(($current_date-$last_update))
|
||||||
if (( time_diff > 86400 )); then
|
echo "Time difference: $time_diff"
|
||||||
|
if (( time_diff > 86400 )) || [ "$2" = "f" ]; then
|
||||||
|
echo "Doing home up..."
|
||||||
git pull
|
git pull
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
elif
|
touch .lastupdate
|
||||||
|
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"
|
||||||
if [ "$2" = "x" ]; then
|
|
||||||
git pull
|
|
||||||
git submodule update --init --recursive
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
cd $OLDPWD
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "command not found!"
|
echo "Command not found!"
|
||||||
echo ""
|
echo ""
|
||||||
_home_help
|
_home_help
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue