Skip to content

Instantly share code, notes, and snippets.

@koter84
Last active April 16, 2019 18:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save koter84/4db827c8c7c9476ece789d52fe98558c to your computer and use it in GitHub Desktop.
Save koter84/4db827c8c7c9476ece789d52fe98558c to your computer and use it in GitHub Desktop.
updater for GitKraken
#!/bin/bash
# get current dir
prog_dir="/opt/$(ls /opt/ | grep gitkraken | grep -v tar)"
if [ "$prog_dir" == "/opt/" ]
then
prog_dir=""
fi
echo "DIR: $prog_dir"
if [ -f $prog_dir/gitkraken ]
then
prog_dir_version=$(${prog_dir}/gitkraken --version | grep -v Node)
fi
echo "DIR Version: $prog_dir_version"
# get current url
prog_url="https://release.gitkraken.com/linux/gitkraken-amd64.tar.gz"
echo "URL: $prog_url"
prog_url_version=$(curl -s https://www.gitkraken.com/download | sed 's/<p/\n<p/g' | grep 'Latest release' | sed 's/.*<strong>//' | cut -d'<' -f1 | sed 's/.*: //')
echo "URL Version: $prog_url_version"
#prog_url_dir=$(echo $prog_url | awk -F/ '{print $NF}' | cut -d"/" -f-1 | sed s/'-linux64.tar.xz'// )
#echo "URL Dir: $prog_url_dir"
# check that a current version is found
if [ "$prog_dir_version" == "" ]
then
echo "New Installation! (no old version found)"
new_install="1"
fi
# check that a new version and url are found
if [ "$prog_url" == "" ] || [ "$prog_url_version" == "" ]
then
echo "couldn't find url for new version"
exit
fi
# check current dir version with current url version
if [ "$prog_dir_version" != "$prog_url_version" ]
then
if [ "$new_install" != "1" ]
then
echo "New Version Found!"
fi
gist_pwd=$(pwd)
cd /opt/
# download
wget --quiet --show-progress -O gitkraken.new.tar.gz "$prog_url"
# remove old version
rm -rf /opt/gitkraken/
# unpack
tar -xf gitkraken.new.tar.gz
# remove download
rm gitkraken.new.tar.gz
# install desktop shortcut, menu item and file associations
cp ${gist_pwd}/~~gitkraken.png /opt/gitkraken/gitkraken.png
cp ${gist_pwd}/~~gitkraken.desktop ${HOME}/.local/share/applications/gitkraken.desktop
fi
[Desktop Entry]
Encoding=UTF-8
Name=GitKraken
Comment=Git viewer
Exec="/opt/gitkraken/gitkraken"
Icon=/opt/gitkraken/gitkraken.png
Terminal=false
Type=Application
MimeType=text/plain;
Categories=Application;Development;Editor;Utility;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment