Added powershell script
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
# PowerShell script to install Obsidian and configure plugins
|
||||
|
||||
function Install-Obsidian-Windows {
|
||||
Write-Output "Installing Obsidian for Windows..."
|
||||
if (-Not (Get-Command choco -ErrorAction SilentlyContinue)) {
|
||||
Write-Output "Chocolatey is not installed. Installing Chocolatey..."
|
||||
Set-ExecutionPolicy Bypass -Scope Process -Force;
|
||||
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
|
||||
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'));
|
||||
}
|
||||
choco install -y wget jq
|
||||
|
||||
Write-Output "Downloading Obsidian installer..."
|
||||
wget https://github.com/obsidianmd/obsidian-releases/releases/download/v1.6.3/Obsidian.1.6.3.exe -OutFile ObsidianInstaller.exe
|
||||
|
||||
# Check if the installer was downloaded
|
||||
if (Test-Path "ObsidianInstaller.exe") {
|
||||
Write-Output "Running Obsidian installer..."
|
||||
Start-Process -FilePath .\ObsidianInstaller.exe -ArgumentList "/S" -NoNewWindow -Wait
|
||||
|
||||
# Check if Obsidian was installed and create a symbolic link for testing
|
||||
if (Test-Path "C:\Program Files\Obsidian\Obsidian.exe") {
|
||||
Write-Output "Obsidian installed successfully."
|
||||
} else {
|
||||
Write-Output "Obsidian installation failed."
|
||||
exit 1
|
||||
}
|
||||
} else {
|
||||
Write-Output "Failed to download Obsidian installer."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
function Install-Plugins {
|
||||
Write-Output "Installing plugins..."
|
||||
|
||||
# Kill Obsidian process if running
|
||||
$obsidianProcess = Get-Process -Name "Obsidian" -ErrorAction SilentlyContinue
|
||||
if ($obsidianProcess) {
|
||||
Stop-Process -Name "Obsidian" -Force
|
||||
}
|
||||
|
||||
# Create the plugins directory if it doesn't exist
|
||||
$pluginsDir = "$env:APPDATA\obsidian\plugins"
|
||||
if (-Not (Test-Path $pluginsDir)) {
|
||||
New-Item -ItemType Directory -Path $pluginsDir | Out-Null
|
||||
}
|
||||
|
||||
# Read plugins configuration file
|
||||
$pluginsConfig = Get-Content -Raw -Path "plugins.json" | ConvertFrom-Json
|
||||
$corePlugins = $pluginsConfig.core_plugins
|
||||
$communityPlugins = $pluginsConfig.community_plugins
|
||||
|
||||
# Enable core plugins
|
||||
foreach ($plugin in $corePlugins) {
|
||||
Write-Output "Enabling core plugin: $plugin"
|
||||
New-Item -ItemType File -Path "$pluginsDir\$plugin" | Out-Null
|
||||
}
|
||||
|
||||
# Install community plugins
|
||||
foreach ($plugin in $communityPlugins) {
|
||||
Write-Output "Installing community plugin: $plugin"
|
||||
New-Item -ItemType Directory -Path "$pluginsDir\$plugin" | Out-Null
|
||||
}
|
||||
|
||||
Write-Output "Plugins installed successfully."
|
||||
}
|
||||
|
||||
Write-Output "Please select your operating system:"
|
||||
Write-Output "L) Linux"
|
||||
Write-Output "M) macOS"
|
||||
Write-Output "W) Windows"
|
||||
|
||||
$osChoice = Read-Host "Enter your choice"
|
||||
|
||||
switch ($osChoice.ToUpper()) {
|
||||
"L" {
|
||||
Write-Output "Please run the script install_obsidian.sh on Linux."
|
||||
}
|
||||
"M" {
|
||||
Write-Output "Please run the script install_obsidian.sh on macOS."
|
||||
}
|
||||
"W" {
|
||||
Install-Obsidian-Windows
|
||||
Install-Plugins
|
||||
}
|
||||
default {
|
||||
Write-Output "Invalid choice. Exiting."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user