2022-08-14 22:12:09 +02:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
|
|
|
COLOR_RED=`tput setaf 1`
|
|
|
|
COLOR_GREEN=`tput setaf 2`
|
|
|
|
COLOR_YELLOW=`tput setaf 3`
|
|
|
|
COLOR_BLUE=`tput setaf 4`
|
|
|
|
COLOR_RESET=`tput sgr0`
|
|
|
|
|
|
|
|
trap 'handleError' ERR
|
|
|
|
|
|
|
|
handleError() {
|
|
|
|
cat <<EOT
|
|
|
|
|
|
|
|
Leider ist ein Fehler aufgetreten.
|
|
|
|
|
|
|
|
Bitte hilf mit dieses Skript zu verbessern und sende einen
|
|
|
|
Fehlerbericht per EMail an installer@logseq.eu
|
|
|
|
EOT
|
|
|
|
}
|
|
|
|
|
|
|
|
showLogo() {
|
|
|
|
echo -n "${COLOR_GREEN}"
|
|
|
|
cat <<-'EOT'
|
|
|
|
.____
|
|
|
|
| | ____ ____ ______ ____ ______
|
|
|
|
| | / _ \ / ___\/ ___// __ \/ ____/
|
|
|
|
| |__( <_> ) /_/ >___ \\ ___< <_| |
|
|
|
|
|_______ \____/\___ /____ >\___ >__ |
|
|
|
|
\/ /_____/ \/ \/ |__|
|
|
|
|
EOT
|
|
|
|
|
|
|
|
echo -n "${COLOR_YELLOW}"
|
|
|
|
cat <<-'EOT'
|
|
|
|
.___ __ .__ .__
|
|
|
|
| | ____ _______/ |______ | | | | ___________
|
|
|
|
| |/ \ / ___/\ __\__ \ | | | | _/ __ \_ __ \
|
|
|
|
| | | \\___ \ | | / __ \| |_| |_\ ___/| | \/
|
|
|
|
|___|___| /____ > |__| (____ /____/____/\___ >__|
|
|
|
|
\/ \/ \/ \/
|
|
|
|
|
|
|
|
|
|
|
|
EOT
|
|
|
|
echo -n "${COLOR_RESET}"
|
|
|
|
}
|
|
|
|
|
|
|
|
getVersionLatest() {
|
|
|
|
VERSION_LATEST="$( wget -qO - https://github.com/logseq/logseq/releases/latest | grep -Poi "Logseq-linux-x64-\K\d\.\d\.\d" | head -n 1 )"
|
|
|
|
}
|
|
|
|
|
|
|
|
getVersionCurrent() {
|
2022-08-15 19:38:52 +02:00
|
|
|
local FILENAME="$( ls -1rt ~/.local/bin/Logseq-*AppImage 2>/dev/null | head -n1 )"
|
2022-08-14 22:12:09 +02:00
|
|
|
if [ -n "$FILENAME" ]; then
|
|
|
|
VERSION_CURRENT="$( echo $FILENAME | grep -Poi "Logseq-linux-x64-\K\d\.\d\.\d" | head -n 1 )"
|
|
|
|
else
|
|
|
|
VERSION_CURRENT=
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
getLatest() {
|
|
|
|
local URL="https://github.com$( wget -qO - https://github.com/logseq/logseq/releases/latest | grep -Poi "/logseq.*AppImage" )"
|
|
|
|
local DIR_DEST=~/.local/bin
|
2022-08-14 23:39:45 +02:00
|
|
|
local FILE_DELETE=
|
2022-08-14 22:12:09 +02:00
|
|
|
|
|
|
|
FILENAME_LOGSEQ="$( basename "$URL" )"
|
|
|
|
mkdir -p $DIR_DEST
|
|
|
|
wget $URL --show-progress -qO $DIR_DEST/$FILENAME_LOGSEQ
|
|
|
|
chmod u+x $DIR_DEST/$FILENAME_LOGSEQ
|
2022-08-14 23:39:45 +02:00
|
|
|
|
|
|
|
# Veraltete Versionen löschen
|
|
|
|
FILE_DELETE="$( find ~/.local/bin -iname Logseq-\*AppImage | grep -v $FILENAME_LOGSEQ )"
|
|
|
|
[ -n "$FILE_DELETE" ] && rm -f $FILE_DELETE
|
2022-08-14 22:12:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
createDesktop() {
|
2022-08-14 22:46:38 +02:00
|
|
|
local FILE_PNG=${HOME}/.local/share/applications/logseq.png
|
|
|
|
[ -e $FILE_PNG ] || wget https://raw.githubusercontent.com/logseq/logseq/master/resources/icons/logseq.png -qO $FILE_PNG
|
2022-08-14 22:12:09 +02:00
|
|
|
|
2022-08-14 22:46:38 +02:00
|
|
|
cat > ~/.local/share/applications/logseq.desktop <<-EOF
|
2022-08-14 22:12:09 +02:00
|
|
|
[Desktop Entry]
|
|
|
|
Encoding=UTF-8
|
|
|
|
Name=Logseq
|
|
|
|
Comment=Wissensmanagement mit Logseq
|
|
|
|
Exec=${HOME}/.local/bin/$FILENAME_LOGSEQ
|
|
|
|
Icon=${HOME}/.local/share/applications/logseq.png
|
|
|
|
Type=Application
|
|
|
|
Categories=Office;
|
|
|
|
X-GNOME-SingleWindow=true
|
|
|
|
SingleMainWindow=true
|
|
|
|
EOF
|
|
|
|
|
|
|
|
update-desktop-database ~/.local/share/applications
|
|
|
|
}
|
|
|
|
|
|
|
|
showLogo
|
|
|
|
getVersionLatest
|
|
|
|
getVersionCurrent
|
|
|
|
echo "Neuste verfügbare Version...... $COLOR_GREEN$VERSION_LATEST$COLOR_RESET"
|
|
|
|
echo "Derzeit installierte Version... $COLOR_GREEN${VERSION_CURRENT:-${COLOR_RED}Keine installiert}$COLOR_RESET"
|
|
|
|
|
|
|
|
[ "$VERSION_CURRENT" != "$VERSION_LATEST" ] || exit
|
|
|
|
|
|
|
|
echo "Logseq Download gestartet"
|
|
|
|
getLatest
|
|
|
|
createDesktop
|
|
|
|
echo "Logseq wurde installiert"
|