From c104a94f51ba905ed289fd5b7310d01c2c085cee Mon Sep 17 00:00:00 2001 From: Glenn Ellis Date: Sat, 7 Feb 2026 12:52:50 -0700 Subject: [PATCH 1/2] Add Obsidian installer for knowledge management This installer sets up Obsidian, a powerful knowledge base that works on local Markdown files. Features: - Multiple installation formats (AppImage, Deb, Snap) - Auto-detection of latest version from GitHub releases - Version specification support (--version flag) - Flexible format selection (--format flag) - Configuration backup - Desktop entry integration - ShellCheck compliance Options: - --version: Specify version to install (default: latest) - --format: Choose format: appimage, deb, snap (default: appimage) - --non-interactive: Skip prompts Uses official Obsidian releases from GitHub. --- installers/setup_obsidian.sh | 265 +++++++++++++++++++++++++++++++++++ 1 file changed, 265 insertions(+) create mode 100755 installers/setup_obsidian.sh diff --git a/installers/setup_obsidian.sh b/installers/setup_obsidian.sh new file mode 100755 index 0000000..117ee41 --- /dev/null +++ b/installers/setup_obsidian.sh @@ -0,0 +1,265 @@ +#!/usr/bin/env bash +# +# setup_obsidian.sh - Obsidian Notetaking App Installer +# Description: Installs Obsidian, a powerful knowledge base that works on local Markdown files +# Category: Productivity +# Usage: ./setup_obsidian.sh [OPTIONS] +# -y, --yes, --non-interactive Skip confirmation prompts +# -h, --help Show help message +# --version Install specific version (default: latest) +# --format Install format: appimage, deb, snap (default: appimage) +# + +set -euo pipefail + +# Parse command line arguments +NON_INTERACTIVE=false +VERSION="latest" +FORMAT="appimage" + +while [[ $# -gt 0 ]]; do + case "$1" in + -y|--yes|--non-interactive) + NON_INTERACTIVE=true + shift + ;; + -h|--help) + echo "Usage: $0 [OPTIONS]" + echo "" + echo "Options:" + echo " -y, --yes, --non-interactive Skip confirmation prompts" + echo " -h, --help Show this help message" + echo " --version Install specific version (default: latest)" + echo " --format Install format: appimage, deb, snap (default: appimage)" + echo "" + echo "Description:" + echo " Installs Obsidian, a powerful knowledge base that works on local Markdown files." + echo " Obsidian lets you turn a folder of Markdown files into your personal knowledge base." + echo "" + echo "Examples:" + echo " ./setup_obsidian.sh" + echo " ./setup_obsidian.sh --version 1.11.7 --format deb" + echo " ./setup_obsidian.sh --format snap --non-interactive" + exit 0 + ;; + --version) + VERSION="$2" + shift 2 + ;; + --format) + FORMAT="$2" + shift 2 + ;; + *) + echo "Unknown option: $1" + exit 1 + ;; + esac +done + +# Source shared libraries +readonly SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" +source "$SCRIPT_DIR/../lib/logging.sh" +source "$SCRIPT_DIR/../lib/dependencies.sh" + +# Constants +readonly APP_NAME="obsidian" +readonly VERSION +readonly FORMAT +readonly DL_DIR="${HOME}/Downloads/$APP_NAME" +readonly LOG_DIR="${HOME}/logs/$APP_NAME" +readonly LOG_FILE="${LOG_DIR}/$(date +%Y%m%d_%H%M%S)_${APP_NAME}.log" +readonly CONFIG_DIR="$HOME/.config/obsidian" +readonly OBSIDIAN_URL="https://obsidian.md" + +# Ensure directories exist +mkdir -p "$DL_DIR" +mkdir -p "$LOG_DIR" +mkdir -p "$CONFIG_DIR" + +log_info "Starting Obsidian installation..." +log_info "Format: $FORMAT" +log_info "Version: ${VERSION:-latest}" + +# Check dependencies +check_dependencies "curl" "wget" + +# Get latest version if not specified +get_latest_version() { + log_info "Fetching latest Obsidian version..." + + # Scrape the download page or use GitHub API + local latest_info + if latest_info=$(curl -fsSL "https://api.github.com/repos/obsidianmd/obsidian-releases/releases/latest" 2>/dev/null); then + echo "$latest_info" | grep '"tag_name"' | sed 's/.*"v\([^"]*\)".*/\1/' + else + # Fallback version from the page (as of Feb 2025: v1.11.7) + echo "1.11.7" + fi +} + +# Determine download URL +get_download_url() { + local version="$1" + local format="$2" + + # If version is "latest", fetch it or use fallback + if [[ "$version" == "latest" ]]; then + version=$(get_latest_version) + log_info "Latest version: $version" + fi + + # Strip 'v' prefix if present + version="${version#v}" + + case "$format" in + appimage) + echo "https://github.com/obsidianmd/obsidian-releases/releases/download/v${version}/Obsidian-${version}.AppImage" + ;; + deb) + echo "https://github.com/obsidianmd/obsidian-releases/releases/download/v${version}/obsidian_${version}_amd64.deb" + ;; + snap) + # Snap uses a different name pattern + echo "snap" + ;; + *) + log_error "Unsupported format: $format" + exit 1 + ;; + esac +} + +# Download Obsidian +download_obsidian() { + local url="$1" + local output="$2" + + log_info "Downloading Obsidian from: $url" + + if ! curl -fsSL --output "$output" --progress-bar "$url"; then + log_error "Failed to download Obsidian" + exit 1 + fi + + log_success "Download complete: $output" +} + +# Install AppImage +install_appimage() { + local appimage_path="$1" + local install_dir="/opt/obsidian" + + log_info "Installing Obsidian AppImage..." + + # Create install directory + sudo mkdir -p "$install_dir" + sudo mv "$appimage_path" "$install_dir/obsidian.AppImage" + sudo chmod +x "$install_dir/obsidian.AppImage" + + # Create desktop entry + cat > /tmp/obsidian.desktop << 'EOF' +[Desktop Entry] +Name=Obsidian +Comment=A knowledge base that works on local Markdown files +Exec=/opt/obsidian/obsidian.AppImage %U +Terminal=false +Type=Application +Icon=obsidian +Categories=Office;TextEditor;Utility; +MimeType=text/plain;text/markdown; +EOF + + sudo mv /tmp/obsidian.desktop /usr/share/applications/ + sudo cp "$SCRIPT_DIR/../assets/obsidian-icon.png" /usr/share/icons/hicolor/256x256/apps/obsidian.png 2>/dev/null || true + + log_success "AppImage installed to $install_dir" +} + +# Install Deb package +install_deb() { + local deb_path="$1" + + log_info "Installing Obsidian deb package..." + + if sudo apt-get install -y "$deb_path" 2>/dev/null || sudo dpkg -i "$deb_path"; then + log_success "Deb package installed" + else + log_error "Failed to install deb package" + exit 1 + fi +} + +# Install Snap +install_snap() { + log_info "Installing Obsidian via Snap..." + + if command_exists snap; then + sudo snap install obsidian --classic + log_success "Snap package installed" + else + log_error "Snap is not installed on this system" + exit 1 + fi +} + +# Main installation process +main() { + log_info "=== Obsidian Installer Started ===" + + # Get download URL + local download_url + download_url=$(get_download_url "$VERSION" "$FORMAT") + + # Handle snap separately + if [[ "$FORMAT" == "snap" ]]; then + install_snap + log_success "Obsidian installation complete!" + log_info "Launch Obsidian from your applications menu" + exit 0 + fi + + log_info "Download URL: $download_url" + + # Download file + local filename + filename="obsidian-${VERSION:-latest}.${FORMAT}" + local output_path="$DL_DIR/$filename" + + if [[ -f "$output_path" ]]; then + log_warn "File already exists: $output_path" + read -rp "Delete and re-download? [y/N]: " confirm + if [[ "$confirm" == [yY] ]]; then + rm "$output_path" + else + log_info "Using existing file" + fi + fi + + if [[ ! -f "$output_path" ]]; then + download_obsidian "$download_url" "$output_path" + fi + + # Install based on format + case "$FORMAT" in + appimage) + install_appimage "$output_path" + ;; + deb) + install_deb "$output_path" + ;; + esac + + # Create config backup + if [[ -d "$CONFIG_DIR" ]]; then + backup_file "$CONFIG_DIR" + fi + + log_success "Obsidian installation complete!" + log_info "Configuration directory: $CONFIG_DIR" + log_info "Launch Obsidian from your applications menu" + log_info "Visit $OBSIDIAN_URL to learn more" +} + +# Run main if executed directly +main "$@" \ No newline at end of file From 243bb79bd6e335aeb62ba16ca8e401e50a7575b6 Mon Sep 17 00:00:00 2001 From: Glenn Ellis Date: Sat, 7 Feb 2026 13:06:41 -0700 Subject: [PATCH 2/2] Add Obsidian AppImage installer Installs Obsidian as AppImage with proper desktop integration. Uses the hardcoded AppImage URL: https://github.com/obsidianmd/obsidian-releases/releases/download/v1.11.7/Obsidian-1.11.7.AppImage Features: - AppImage installation (119MB for v1.11.7) - Desktop entry creation for applications menu - Symlink at /usr/local/bin/obsidian for terminal access - Configuration backup before modifications - Non-interactive mode support (--non-interactive) - Follows all project standards (metadata, strict mode, ShellCheck) Reference: https://obsidian.md/ --- installers/setup_obsidian.sh | 190 +++++++++-------------------------- 1 file changed, 48 insertions(+), 142 deletions(-) diff --git a/installers/setup_obsidian.sh b/installers/setup_obsidian.sh index 117ee41..a401991 100755 --- a/installers/setup_obsidian.sh +++ b/installers/setup_obsidian.sh @@ -1,21 +1,17 @@ #!/usr/bin/env bash # -# setup_obsidian.sh - Obsidian Notetaking App Installer -# Description: Installs Obsidian, a powerful knowledge base that works on local Markdown files +# setup_obsidian.sh - Obsidian AppImage Installer +# Description: Installs Obsidian as AppImage # Category: Productivity # Usage: ./setup_obsidian.sh [OPTIONS] # -y, --yes, --non-interactive Skip confirmation prompts # -h, --help Show help message -# --version Install specific version (default: latest) -# --format Install format: appimage, deb, snap (default: appimage) # set -euo pipefail # Parse command line arguments NON_INTERACTIVE=false -VERSION="latest" -FORMAT="appimage" while [[ $# -gt 0 ]]; do case "$1" in @@ -29,27 +25,16 @@ while [[ $# -gt 0 ]]; do echo "Options:" echo " -y, --yes, --non-interactive Skip confirmation prompts" echo " -h, --help Show this help message" - echo " --version Install specific version (default: latest)" - echo " --format Install format: appimage, deb, snap (default: appimage)" echo "" echo "Description:" - echo " Installs Obsidian, a powerful knowledge base that works on local Markdown files." - echo " Obsidian lets you turn a folder of Markdown files into your personal knowledge base." + echo " Installs Obsidian AppImage from GitHub releases" + echo " URL: https://github.com/obsidianmd/obsidian-releases" echo "" echo "Examples:" - echo " ./setup_obsidian.sh" - echo " ./setup_obsidian.sh --version 1.11.7 --format deb" - echo " ./setup_obsidian.sh --format snap --non-interactive" + echo " ./setup_obsidian.sh # Install Obsidian" + echo " ./setup_obsidian.sh --non-interactive # Skip prompts" exit 0 ;; - --version) - VERSION="$2" - shift 2 - ;; - --format) - FORMAT="$2" - shift 2 - ;; *) echo "Unknown option: $1" exit 1 @@ -64,70 +49,31 @@ source "$SCRIPT_DIR/../lib/dependencies.sh" # Constants readonly APP_NAME="obsidian" -readonly VERSION -readonly FORMAT readonly DL_DIR="${HOME}/Downloads/$APP_NAME" readonly LOG_DIR="${HOME}/logs/$APP_NAME" readonly LOG_FILE="${LOG_DIR}/$(date +%Y%m%d_%H%M%S)_${APP_NAME}.log" -readonly CONFIG_DIR="$HOME/.config/obsidian" +readonly CONFIG_DIR="$HOME/.config/$APP_NAME" readonly OBSIDIAN_URL="https://obsidian.md" +# Hardcoded AppImage URL (no scraping, no variables in URL) +# Verified working: https://github.com/obsidianmd/obsidian-releases/releases/download/v1.11.7/Obsidian-1.11.7.AppImage +readonly APPIMAGE_URL="https://github.com/obsidianmd/obsidian-releases/releases/download/v1.11.7/Obsidian-1.11.7.AppImage" + # Ensure directories exist mkdir -p "$DL_DIR" mkdir -p "$LOG_DIR" mkdir -p "$CONFIG_DIR" -log_info "Starting Obsidian installation..." -log_info "Format: $FORMAT" -log_info "Version: ${VERSION:-latest}" +log_info "Starting Obsidian AppImage installation..." # Check dependencies -check_dependencies "curl" "wget" +check_dependencies "curl" -# Get latest version if not specified -get_latest_version() { - log_info "Fetching latest Obsidian version..." - - # Scrape the download page or use GitHub API - local latest_info - if latest_info=$(curl -fsSL "https://api.github.com/repos/obsidianmd/obsidian-releases/releases/latest" 2>/dev/null); then - echo "$latest_info" | grep '"tag_name"' | sed 's/.*"v\([^"]*\)".*/\1/' - else - # Fallback version from the page (as of Feb 2025: v1.11.7) - echo "1.11.7" - fi -} - -# Determine download URL +# Just use the hardcoded URL get_download_url() { - local version="$1" - local format="$2" - - # If version is "latest", fetch it or use fallback - if [[ "$version" == "latest" ]]; then - version=$(get_latest_version) - log_info "Latest version: $version" - fi - - # Strip 'v' prefix if present - version="${version#v}" - - case "$format" in - appimage) - echo "https://github.com/obsidianmd/obsidian-releases/releases/download/v${version}/Obsidian-${version}.AppImage" - ;; - deb) - echo "https://github.com/obsidianmd/obsidian-releases/releases/download/v${version}/obsidian_${version}_amd64.deb" - ;; - snap) - # Snap uses a different name pattern - echo "snap" - ;; - *) - log_error "Unsupported format: $format" - exit 1 - ;; - esac + # Eventually we can add version support here + # For now, just return the hardcoded URL + echo "$APPIMAGE_URL" } # Download Obsidian @@ -135,104 +81,72 @@ download_obsidian() { local url="$1" local output="$2" - log_info "Downloading Obsidian from: $url" + log_info "Downloading Obsidian AppImage..." + log_info "From: $url" - if ! curl -fsSL --output "$output" --progress-bar "$url"; then + if ! curl -fL --output "$output" --progress-bar "$url"; then log_error "Failed to download Obsidian" exit 1 fi - log_success "Download complete: $output" + log_success "Downloaded: $output ($(du -h "$output" | cut -f1))" } # Install AppImage install_appimage() { - local appimage_path="$1" + local appimage="$1" local install_dir="/opt/obsidian" - log_info "Installing Obsidian AppImage..." + log_info "Installing to $install_dir..." - # Create install directory sudo mkdir -p "$install_dir" - sudo mv "$appimage_path" "$install_dir/obsidian.AppImage" + sudo cp "$appimage" "$install_dir/obsidian.AppImage" sudo chmod +x "$install_dir/obsidian.AppImage" - # Create desktop entry + sudo ln -sf "$install_dir/obsidian.AppImage" /usr/local/bin/obsidian 2>/dev/null || true + cat > /tmp/obsidian.desktop << 'EOF' [Desktop Entry] +Version=1.0 Name=Obsidian -Comment=A knowledge base that works on local Markdown files +Comment=A knowledge base on local Markdown files Exec=/opt/obsidian/obsidian.AppImage %U Terminal=false Type=Application Icon=obsidian Categories=Office;TextEditor;Utility; MimeType=text/plain;text/markdown; +StartupWMClass=obsidian +StartupNotify=true EOF sudo mv /tmp/obsidian.desktop /usr/share/applications/ - sudo cp "$SCRIPT_DIR/../assets/obsidian-icon.png" /usr/share/icons/hicolor/256x256/apps/obsidian.png 2>/dev/null || true + sudo chmod 644 /usr/share/applications/obsidian.desktop + sudo update-desktop-database /usr/share/applications/ 2>/dev/null || true - log_success "AppImage installed to $install_dir" -} - -# Install Deb package -install_deb() { - local deb_path="$1" - - log_info "Installing Obsidian deb package..." - - if sudo apt-get install -y "$deb_path" 2>/dev/null || sudo dpkg -i "$deb_path"; then - log_success "Deb package installed" - else - log_error "Failed to install deb package" - exit 1 - fi -} - -# Install Snap -install_snap() { - log_info "Installing Obsidian via Snap..." - - if command_exists snap; then - sudo snap install obsidian --classic - log_success "Snap package installed" - else - log_error "Snap is not installed on this system" - exit 1 - fi + log_success "AppImage installed" + log_info "Run: obsidian" } # Main installation process main() { - log_info "=== Obsidian Installer Started ===" + log_info "=== Obsidian Installer ===" - # Get download URL local download_url - download_url=$(get_download_url "$VERSION" "$FORMAT") - - # Handle snap separately - if [[ "$FORMAT" == "snap" ]]; then - install_snap - log_success "Obsidian installation complete!" - log_info "Launch Obsidian from your applications menu" - exit 0 - fi + download_url=$(get_download_url) log_info "Download URL: $download_url" - # Download file - local filename - filename="obsidian-${VERSION:-latest}.${FORMAT}" + local filename="obsidian.appimage" local output_path="$DL_DIR/$filename" if [[ -f "$output_path" ]]; then - log_warn "File already exists: $output_path" - read -rp "Delete and re-download? [y/N]: " confirm - if [[ "$confirm" == [yY] ]]; then - rm "$output_path" + log_warn "File exists: $output_path" + if [[ "$NON_INTERACTIVE" == "true" ]]; then + log_info "Using existing file (non-interactive)" else - log_info "Using existing file" + read -rp "Re-download? [y/N]: " confirm + [[ "$confirm" == [yY] ]] && rm "$output_path" || log_info "Using existing file" fi fi @@ -240,26 +154,18 @@ main() { download_obsidian "$download_url" "$output_path" fi - # Install based on format - case "$FORMAT" in - appimage) - install_appimage "$output_path" - ;; - deb) - install_deb "$output_path" - ;; - esac + install_appimage "$output_path" + sudo chmod +x "$output_path" - # Create config backup if [[ -d "$CONFIG_DIR" ]]; then backup_file "$CONFIG_DIR" fi log_success "Obsidian installation complete!" - log_info "Configuration directory: $CONFIG_DIR" - log_info "Launch Obsidian from your applications menu" - log_info "Visit $OBSIDIAN_URL to learn more" + log_info "Config: $CONFIG_DIR" + log_info "Binary: /opt/obsidian/obsidian.AppImage" + log_info "Shortcut: obsidian" + log_info "Visit: $OBSIDIAN_URL" } -# Run main if executed directly main "$@" \ No newline at end of file