background update

This commit is contained in:
q
2016-02-26 20:06:05 +02:00
parent daacff7a1a
commit b6c2c572ad

5
rc
View File

@@ -13,13 +13,14 @@ export PATH
function _self_update() { function _self_update() {
touch "$TOOLSPATH"/.lastupdate touch "$TOOLSPATH"/.lastupdate
pushd "$TOOLSPATH" > /dev/null pushd "$TOOLSPATH" > /dev/null
timeout 5 hg pull -u > /dev/null 2>&1 timeout 5 hg pull -u > /dev/null 2>&1 &
popd > /dev/null popd > /dev/null
} }
[[ "$1" = "-u" ]] && _self_update [[ "$1" = "-u" ]] && _self_update
# Update self weekly # Update self weekly
[[ -w "$TOOLSPATH" ]] || return
[[ -t 0 ]] || return [[ -t 0 ]] || return
[[ -t 1 ]] || return [[ -t 1 ]] || return
[[ -t 2 ]] || return [[ -t 2 ]] || return
@@ -27,6 +28,6 @@ function _self_update() {
[[ -w "$TOOLSPATH"/.lastupdate ]] || return [[ -w "$TOOLSPATH"/.lastupdate ]] || return
TOOLS_LASTUPDATE=$(( $( date +%s ) - $( stat -c %Y "$TOOLSPATH"/.lastupdate ) )) TOOLS_LASTUPDATE=$(( $( date +%s ) - $( stat -c %Y "$TOOLSPATH"/.lastupdate ) ))
[[ "$TOOLS_LASTUPDATE" -gt 604800 ]] && _self_update [[ "$TOOLS_LASTUPDATE" -gt 604800 ]] && _self_update
unset TOOLS_LASTUPDATE unset TOOLS_LASTUPDATE
unset -f _self_update unset -f _self_update