Skip to content

Instantly share code, notes, and snippets.

@SathvikKS
Created December 25, 2018 01:58
Show Gist options
  • Save SathvikKS/c4fdaa1b227d85a654bcdd92fa6bf343 to your computer and use it in GitHub Desktop.
Save SathvikKS/c4fdaa1b227d85a654bcdd92fa6bf343 to your computer and use it in GitHub Desktop.
Auto Update script.
dir="/path/to/local/repo/"
cd $HOME/$dir
git checkout origin/master *
echo "Searching for updates. Please wait :)"
touch $HOME/.sksupdater
rm $HOME/.sksupdater
git fetch --dry-run 2>&1 > /dev/null| tee $HOME/.sksupdater
up=$HOME/.sksupdater
if grep -q origin/master "$up"; then
clear
echo "Updates are found. Now updating"
sleep 1
update=$(git fetch --all
git reset --hard origin/master
git pull)
clear
chmod +x *
echo "Update done. Restarting"
sleep 2
reload=$(readlink -f "$0")
exec "$reload"
else
chmod +x *
echo "No updates"
sleep 2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment