-
-
Save zlatko-minev/9a4b42f30b1397fa8a0ab2dde0150437 to your computer and use it in GitHub Desktop.
updater for GitKraken
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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