-
-
Save danielnbalasoiu/aefbb31327f9b860e8cd29267d08c54c to your computer and use it in GitHub Desktop.
Download nightly logseq release
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
#!/usr/bin/env bash | |
# | |
# downloads nightly logseq release | |
# returns error 3 if up-to-date | |
set -e | |
APPLOC="$HOME/Applications" | |
LOGBIN="$APPLOC/logseq-linux-x64-bin" | |
usage() { echo "Usage: $0 [-s <45|90>] [-p <string>]" 1>&2; exit 1; } | |
cleanup() { | |
rv=$? | |
rm -rf "$tmpfile" | |
[ -f "$name" ] && rm "$name" | |
exit $rv | |
} | |
get_gh_release() { | |
echo "Updating Logseq from GH" | |
curl -s https://api.github.com/repos/logseq/logseq/releases > "$tmpfile" | |
name=$(grep "name.*Logseq-linux.*nightly.*zip" "$tmpfile" \ | |
| cut -d : -f 2,3 \ | |
| tr -d \" \ | |
| tr -d ,\ | |
| awk '{$1=$1;print}') | |
name2=$(basename "$name" .zip) | |
} | |
get_nightly() { | |
echo "Downloading nightly" | |
cd /tmp | |
grep "browser_download.*Logseq-linux.*nightly.*zip" "$tmpfile" \ | |
| cut -d : -f 2,3 \ | |
| tr -d \" \ | |
| wget -qi - | |
unzip -qq "$name" | |
mv Logseq-linux-x64 "$APPLOC/$name2" | |
ln -sf "$APPLOC/$name2/Logseq" "$LOGBIN" | |
ls -l "$LOGBIN" | |
} | |
trap "cleanup" EXIT | |
tmpfile=$(mktemp) | |
while getopts "lo" o; do | |
case "${do}" in | |
d) | |
echo "Creating desktop file" | |
exit | |
;; | |
r) | |
xdg-open https://github.com/logseq/logseq/releases/nightly | |
exit | |
;; | |
*) | |
usage | |
;; | |
esac | |
done | |
shift $((OPTIND-1)) | |
get_gh_release | |
if [ -d "$APPLOC/$name2" ]; then | |
echo "Logseq is up to date ($name2)" | |
exit 3 | |
fi | |
get_nightly | |
echo "Finished updating Logseq to the latest snapshot" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment