From 0d085277157c0818646080b143b9955569c2d757 Mon Sep 17 00:00:00 2001 From: Ville Rantanen Date: Mon, 20 Jul 2015 08:26:06 +0300 Subject: [PATCH] self update mechanism --- rc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/rc b/rc index a4d0cf9..3bbe2ad 100644 --- a/rc +++ b/rc @@ -10,3 +10,16 @@ export PATH . "$TOOLSPATH"/qcd_function +# Update self weekly +[[ -f "$TOOLSPATH"/.lastupdate ]] || touch -t 0101010101 "$TOOLSPATH"/.lastupdate +[[ -f "$TOOLSPATH"/.lastupdate ]] || return + +TOOLS_LASTUPDATE=$(( $( date +%s ) - $( stat -c %Y "$TOOLSPATH"/.lastupdate ) )) +[[ "$TOOLS_LASTUPDATE" -gt 604800 ]] && { + touch "$TOOLSPATH"/.lastupdate + pushd "$TOOLSPATH" > /dev/null + hg pull -u + popd > /dev/null +} +unset TOOLS_LASTUPDATE +