Last active
December 24, 2022 22:33
-
-
Save FindHao/0c106f5ce2b1570ce0cc282531ee089d to your computer and use it in GitHub Desktop.
a script to automatically update and run Icalingua++ QQ on x86 linux
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 | |
# Put this script to the same folder with Icalingua++-XX.AppImage or where you want to download the appimage. | |
# get script path | |
file_path=$(dirname $(readlink -f $0)) | |
cd $file_path | |
# check github releases for new version | |
url=$(curl -s https://api.github.com/repos/Icalingua-plus-plus/Icalingua-plus-plus/releases/latest | grep "browser_download_url.*AppImage" | cut -d : -f 2,3 | tr -d \" | sed -n '3p') | |
# check if url is empty | |
if [ -z "$url" ]; then | |
echo "can not get the latest version" | |
exit 0 | |
fi | |
# get the version number | |
version=$(echo "$url" | sed -n 's/.*v\(.*\)\/.*/\1/p') | |
function update() { | |
target_file="Icalingua++-$version.AppImage" | |
# strip url | |
url=$(echo "$url" | sed -n 's/.*\(https.*\)/\1/p') | |
# download the latest version | |
wget "$url" -O $target_file | |
} | |
# get all icalingua++ appimage files | |
files=$(find . -name "Icalingua++-*.AppImage") | |
need_update=false | |
# check if there is no appimage file | |
if [ -z "$files" ]; then | |
echo "No appimage file found" | |
need_update=true | |
else | |
# check which one is the latest version | |
local_latest=$(echo "$files" | sort -V | tail -n 1) | |
local_version=$(echo "$local_latest" | sed -n 's/.*Icalingua++-\(.*\).AppImage/\1/p') | |
target_file=$local_latest | |
# check if the latest version is not the same as the latest version on github | |
if [ "$version" != "$local_version" ]; then | |
rm -f $local_latest | |
echo "New version found: $version" | |
need_update=true | |
fi | |
fi | |
if [ "$need_update" = true ]; then | |
update | |
fi | |
# run the latest version | |
chmod +x "$target_file" | |
./"$target_file" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment