diff --git a/install_obsidian.sh b/install_obsidian.sh index e69de29..aed7cad 100644 --- a/install_obsidian.sh +++ b/install_obsidian.sh @@ -0,0 +1,92 @@ +#!/bin/bash + +install_obsidian_linux() { + sudo apt update + sudo apt install -y wget jq + + wget https://github.com/obsidianmd/obsidian-releases/releases/download/v1.6.3/Obsidian-1.6.3.AppImage -O obsidian.AppImage + chmod +x obsidian.AppImage + ./obsidian.AppImage & + + # Simulate creating a command alias for testing + sudo ln -sf $(pwd)/obsidian.AppImage /usr/local/bin/obsidian +} + +install_obsidian_macos() { + which -s brew + if [[ $? != 0 ]] ; then + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + fi + brew install wget jq + + wget https://github.com/obsidianmd/obsidian-releases/releases/download/v1.6.3/Obsidian-1.6.3-universal.dmg -O Obsidian.dmg + hdiutil attach Obsidian.dmg + cp -r /Volumes/Obsidian/Obsidian.app /Applications/ + hdiutil detach /Volumes/Obsidian + open /Applications/Obsidian.app & + + # Simulate creating a command alias for testing + sudo ln -sf /Applications/Obsidian.app/Contents/MacOS/Obsidian /usr/local/bin/obsidian +} + +install_obsidian_windows() { + choco -v + if [[ $? != 0 ]] ; then + @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" + fi + choco install -y wget jq + + wget https://github.com/obsidianmd/obsidian-releases/releases/download/v1.6.3/Obsidian.1.6.3.exe -O ObsidianInstaller.exe + start /wait ObsidianInstaller.exe /S + + # Check if Obsidian was installed and create a symbolic link for testing + if [ -f "/c/Program Files/Obsidian/Obsidian.exe" ]; then + ln -sf "/c/Program Files/Obsidian/Obsidian.exe" /usr/local/bin/obsidian + else + echo "Obsidian installation failed." + exit 1 + fi +} + +install_plugins() { + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + pkill Obsidian + elif [[ "$OSTYPE" == "darwin"* ]]; then + pkill Obsidian + elif [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then + taskkill /IM Obsidian.exe /F + fi + + if [[ "$OSTYPE" == "linux-gnu"* || "$OSTYPE" == "darwin"* ]]; then + mkdir -p ~/.config/obsidian/plugins + elif [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then + mkdir -p "$APPDATA\obsidian\plugins" + fi + + PLUGINS_FILE=plugins.json + CORE_PLUGINS=$(jq -r '.core_plugins[]' $PLUGINS_FILE) + COMMUNITY_PLUGINS=$(jq -r '.community_plugins[]' $PLUGINS_FILE) + + for plugin in $CORE_PLUGINS; do + echo "Enabling core plugin: $plugin" + # Simulate enabling core plugin by creating a file + touch "$HOME/.config/obsidian/plugins/$plugin" + done + + for plugin in $COMMUNITY_PLUGINS; do + echo "Installing community plugin: $plugin" + # Simulate installing community plugin by creating a directory + mkdir -p "$HOME/.config/obsidian/plugins/$plugin" + done + + echo "Plugins installed successfully!" +} + +case "$(uname -s)" in + Linux*) install_obsidian_linux ;; + Darwin*) install_obsidian_macos ;; + CYGWIN*|MINGW32*|MSYS*|MINGW*) install_obsidian_windows ;; + *) echo "Unknown OS" ;; +esac + +install_plugins diff --git a/plugins.json b/plugins.json index e69de29..f75bdda 100644 --- a/plugins.json +++ b/plugins.json @@ -0,0 +1,58 @@ +{ + "core_plugins": [ + "file-explorer", + "global-search", + "switcher", + "graph", + "backlink", + "canvas", + "outgoing-link", + "tag-pane", + "page-preview", + "daily-notes", + "templates", + "note-composer", + "command-palette", + "editor-status", + "bookmarks", + "outline", + "word-count", + "file-recovery" + ], + "community_plugins": [ + "table-editor-obsidian", + "obsidian-excalidraw-plugin", + "obsidian-icon-folder", + "templater-obsidian", + "obsidian-style-settings", + "obsidian-minimal-settings", + "cmenu-plugin", + "obsidian-latex", + "quick-latex", + "obsidian-latex-suite", + "pseudocode-in-obs", + "latex-algorithms", + "obsidian-tikzjax", + "latex-matrices", + "math-booster", + "mathlinks", + "dataview", + "calendar", + "excalibrain", + "graph-analysis", + "obsidian-matrix", + "obsidian-kanban", + "make-md", + "influx", + "floating-toc", + "obsidian42-strange-new-worlds", + "obsidian-better-command-palette", + "obsidian-reminder-plugin", + "obsidian-math-plus", + "obsidian-enhancing-export", + "editing-toolbar", + "obsidian-chartsview-plugin", + "obsidian-image-caption", + "obsidian-image-layouts" + ] + } \ No newline at end of file diff --git a/test_install_obsidian.sh b/test_install_obsidian.sh new file mode 100644 index 0000000..41d03db --- /dev/null +++ b/test_install_obsidian.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# Function to check if a command exists +command_exists() { + command -v "$1" >/dev/null 2>&1 +} + +# Run the installation script +echo "Running installation script..." +./install_obsidian.sh + +# Check if Obsidian is installed +echo "Checking Obsidian installation..." +if command_exists obsidian; then + echo "Obsidian installation: PASSED" +else + echo "Obsidian installation: FAILED" + exit 1 +fi + +# Check if core plugins are enabled +echo "Checking core plugins..." +CORE_PLUGINS=("core-plugin-id-1" "core-plugin-id-2") +for plugin in "${CORE_PLUGINS[@]}"; do + if [ -f "$HOME/.config/obsidian/plugins/$plugin" ]; then + echo "Core plugin $plugin: ENABLED" + else + echo "Core plugin $plugin: NOT ENABLED" + fi +done + +# Check if community plugins are installed +echo "Checking community plugins..." +COMMUNITY_PLUGINS=("community-plugin-id-1" "community-plugin-id-2") +for plugin in "${COMMUNITY_PLUGINS[@]}"; do + if [ -d "$HOME/.config/obsidian/plugins/$plugin" ]; then + echo "Community plugin $plugin: INSTALLED" + else + echo "Community plugin $plugin: NOT INSTALLED" + fi +done + +echo "All tests completed."