Skip to content

Instantly share code, notes, and snippets.

@dayne
Created August 8, 2024 06:09
Show Gist options
  • Save dayne/8eff76845e6b63f78f37b388c81ec7ef to your computer and use it in GitHub Desktop.
Save dayne/8eff76845e6b63f78f37b388c81ec7ef to your computer and use it in GitHub Desktop.
Script to download Obsidian
#!/usr/bin/bash
# Dayne Broderson 2024
# Script to check if Obsidian is available, if not, then figure out latest
# release version, download and install it
# exit if anything exits with an error (non-zero) status
set -e
if ! command -v obsidian > /dev/null; then
echo -n "Obsidian missing ... "
DLURL=$(wget -q -O - https://api.github.com/repos/obsidianmd/obsidian-releases/releases/latest | grep 'deb"$' | awk -F'"' ' {print $4} ')
DLFILE=$(basename $DLURL)
if [ $? -eq 0 ]; then
echo "target download: $DLFILE"
else
echo "Unable to get latest Obsidian URL to download"
exit 1
fi
cd /tmp
wget --quiet "$DLURL"
if [ $? -eq 0 ]; then
if [ -f $DLFILE ]; then
echo "Downloaded: $DLFILE"
sudo dpkg -i $DLFILE
else
echo "Download finished but $DLFILE doesn't exist in $(pwd)"
exit 1
fi
else
echo "Unable to download $DLURL"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment