Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d2dc30777 | ||
|
|
108c694a3b | ||
|
|
5622aceeff | ||
|
|
7845e9461b | ||
|
|
ddc78f35e0 | ||
|
|
e4772c09b6 | ||
|
|
876d2dab3d | ||
|
|
71963cca8e | ||
|
|
f21f7cca44 |
@@ -0,0 +1,128 @@
|
|||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
We as members, contributors, and leaders pledge to make participation in our
|
||||||
|
community a harassment-free experience for everyone, regardless of age, body
|
||||||
|
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||||
|
identity and expression, level of experience, education, socio-economic status,
|
||||||
|
nationality, personal appearance, race, religion, or sexual identity
|
||||||
|
and orientation.
|
||||||
|
|
||||||
|
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||||
|
diverse, inclusive, and healthy community.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to a positive environment for our
|
||||||
|
community include:
|
||||||
|
|
||||||
|
* Demonstrating empathy and kindness toward other people
|
||||||
|
* Being respectful of differing opinions, viewpoints, and experiences
|
||||||
|
* Giving and gracefully accepting constructive feedback
|
||||||
|
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||||
|
and learning from the experience
|
||||||
|
* Focusing on what is best not just for us as individuals, but for the
|
||||||
|
overall community
|
||||||
|
|
||||||
|
Examples of unacceptable behavior include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery, and sexual attention or
|
||||||
|
advances of any kind
|
||||||
|
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or email
|
||||||
|
address, without their explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a
|
||||||
|
professional setting
|
||||||
|
|
||||||
|
## Enforcement Responsibilities
|
||||||
|
|
||||||
|
Community leaders are responsible for clarifying and enforcing our standards of
|
||||||
|
acceptable behavior and will take appropriate and fair corrective action in
|
||||||
|
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||||
|
or harmful.
|
||||||
|
|
||||||
|
Community leaders have the right and responsibility to remove, edit, or reject
|
||||||
|
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||||
|
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||||
|
decisions when appropriate.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies within all community spaces, and also applies when
|
||||||
|
an individual is officially representing the community in public spaces.
|
||||||
|
Examples of representing our community include using an official e-mail address,
|
||||||
|
posting via an official social media account, or acting as an appointed
|
||||||
|
representative at an online or offline event.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
|
reported to the community leaders responsible for enforcement at
|
||||||
|
quinta0github@gmail.com.
|
||||||
|
All complaints will be reviewed and investigated promptly and fairly.
|
||||||
|
|
||||||
|
All community leaders are obligated to respect the privacy and security of the
|
||||||
|
reporter of any incident.
|
||||||
|
|
||||||
|
## Enforcement Guidelines
|
||||||
|
|
||||||
|
Community leaders will follow these Community Impact Guidelines in determining
|
||||||
|
the consequences for any action they deem in violation of this Code of Conduct:
|
||||||
|
|
||||||
|
### 1. Correction
|
||||||
|
|
||||||
|
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||||
|
unprofessional or unwelcome in the community.
|
||||||
|
|
||||||
|
**Consequence**: A private, written warning from community leaders, providing
|
||||||
|
clarity around the nature of the violation and an explanation of why the
|
||||||
|
behavior was inappropriate. A public apology may be requested.
|
||||||
|
|
||||||
|
### 2. Warning
|
||||||
|
|
||||||
|
**Community Impact**: A violation through a single incident or series
|
||||||
|
of actions.
|
||||||
|
|
||||||
|
**Consequence**: A warning with consequences for continued behavior. No
|
||||||
|
interaction with the people involved, including unsolicited interaction with
|
||||||
|
those enforcing the Code of Conduct, for a specified period of time. This
|
||||||
|
includes avoiding interactions in community spaces as well as external channels
|
||||||
|
like social media. Violating these terms may lead to a temporary or
|
||||||
|
permanent ban.
|
||||||
|
|
||||||
|
### 3. Temporary Ban
|
||||||
|
|
||||||
|
**Community Impact**: A serious violation of community standards, including
|
||||||
|
sustained inappropriate behavior.
|
||||||
|
|
||||||
|
**Consequence**: A temporary ban from any sort of interaction or public
|
||||||
|
communication with the community for a specified period of time. No public or
|
||||||
|
private interaction with the people involved, including unsolicited interaction
|
||||||
|
with those enforcing the Code of Conduct, is allowed during this period.
|
||||||
|
Violating these terms may lead to a permanent ban.
|
||||||
|
|
||||||
|
### 4. Permanent Ban
|
||||||
|
|
||||||
|
**Community Impact**: Demonstrating a pattern of violation of community
|
||||||
|
standards, including sustained inappropriate behavior, harassment of an
|
||||||
|
individual, or aggression toward or disparagement of classes of individuals.
|
||||||
|
|
||||||
|
**Consequence**: A permanent ban from any sort of public interaction within
|
||||||
|
the community.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||||
|
version 2.0, available at
|
||||||
|
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
||||||
|
|
||||||
|
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
||||||
|
enforcement ladder](https://github.com/mozilla/diversity).
|
||||||
|
|
||||||
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
|
||||||
|
For answers to common questions about this code of conduct, see the FAQ at
|
||||||
|
https://www.contributor-covenant.org/faq. Translations are available at
|
||||||
|
https://www.contributor-covenant.org/translations.
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
# Security Policy
|
||||||
|
|
||||||
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
If you discover a security vulnerability, please report it to us as follows:
|
||||||
|
|
||||||
|
1. **Email**: Send an email to [quinta0github@gmail.com](mailto:quinta0github@gmail.com). Please include the following details:
|
||||||
|
- A description of the vulnerability.
|
||||||
|
- Steps to reproduce the issue.
|
||||||
|
- Any potential impact or exploitation scenarios.
|
||||||
|
|
||||||
|
2. **Acknowledgment**: We will acknowledge receipt of your report within 48 hours and will provide a detailed response within 5 working days.
|
||||||
|
|
||||||
|
3. **Resolution**: We will work with you to understand and resolve the issue as quickly as possible.
|
||||||
|
|
||||||
|
We take security issues seriously and appreciate your efforts in helping us maintain the security of our project.
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
/ObsidianInstaller.exe
|
/ObsidianInstaller.exe
|
||||||
.idea
|
.idea
|
||||||
|
/invalid_plugins.json
|
||||||
|
|||||||
@@ -0,0 +1,212 @@
|
|||||||
|
# Define Test-Administrator function
|
||||||
|
function Test-Administrator {
|
||||||
|
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
|
||||||
|
return $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
||||||
|
}
|
||||||
|
|
||||||
|
function Test-AdminPrivilege {
|
||||||
|
if (-Not (Test-Administrator)) {
|
||||||
|
Write-Output "Running as non-admin user for testing admin check..."
|
||||||
|
} else {
|
||||||
|
Write-Output "Running as admin user for testing admin check..."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Test-ChocolateyInstallation {
|
||||||
|
Write-Output "Simulating environment without Chocolatey..."
|
||||||
|
Remove-Item -Path "C:\ProgramData\chocolatey" -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
if (-Not (Get-Command choco -ErrorAction SilentlyContinue)) {
|
||||||
|
Write-Output "Chocolatey is not installed. Proceeding with installation..."
|
||||||
|
} else {
|
||||||
|
Write-Output "Chocolatey is already installed."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Test-ObsidianDownload {
|
||||||
|
Write-Output "Simulating download failure..."
|
||||||
|
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name "ProxyEnable" -Value 1
|
||||||
|
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name "ProxyServer" -Value "127.0.0.1:8080"
|
||||||
|
Start-Sleep -Seconds 10 # Ensure proxy settings take effect
|
||||||
|
|
||||||
|
Write-Output "Downloading Obsidian installer..."
|
||||||
|
try {
|
||||||
|
Invoke-WebRequest -Uri "https://github.com/obsidianmd/obsidian-releases/releases/download/v1.6.3/Obsidian.1.6.3.exe" -OutFile "ObsidianInstaller.exe" -ErrorAction Stop
|
||||||
|
} catch {
|
||||||
|
Write-Output "Download failed as expected."
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Test-Path "ObsidianInstaller.exe") {
|
||||||
|
Write-Output "Download succeeded unexpectedly."
|
||||||
|
} else {
|
||||||
|
Write-Output "Download failed as expected."
|
||||||
|
}
|
||||||
|
|
||||||
|
# Clean up proxy settings
|
||||||
|
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name "ProxyEnable" -Value 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# Simulate invalid plugins.json file
|
||||||
|
Set-Content -Path "invalid_plugins.json" -Value @"
|
||||||
|
{
|
||||||
|
"core_plugins": ["plugin1", "plugin2"]
|
||||||
|
"community_plugins": ["plugin3", "plugin4"]
|
||||||
|
}
|
||||||
|
"@
|
||||||
|
|
||||||
|
function Test-InvalidPluginConfig {
|
||||||
|
Write-Output "Testing with invalid plugins.json..."
|
||||||
|
try {
|
||||||
|
$null = Get-Content -Raw -Path "invalid_plugins.json" | ConvertFrom-Json
|
||||||
|
} catch {
|
||||||
|
Write-Output "Caught error parsing invalid plugins.json as expected: $_"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Test-ObsidianInstallation {
|
||||||
|
Write-Output "Testing Obsidian installation..."
|
||||||
|
|
||||||
|
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;
|
||||||
|
$script = (New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')
|
||||||
|
Invoke-Command -ScriptBlock ([ScriptBlock]::Create($script))
|
||||||
|
}
|
||||||
|
choco install -y jq
|
||||||
|
|
||||||
|
Write-Output "Downloading Obsidian installer..."
|
||||||
|
$installerPath = "$env:TEMP\ObsidianInstaller.exe"
|
||||||
|
Invoke-WebRequest -Uri "https://github.com/obsidianmd/obsidian-releases/releases/download/v1.6.3/Obsidian.1.6.3.exe" -OutFile $installerPath
|
||||||
|
|
||||||
|
# Check if the installer was downloaded
|
||||||
|
if (Test-Path $installerPath) {
|
||||||
|
Write-Output "Running Obsidian installer..."
|
||||||
|
$startProcess = Start-Process -FilePath $installerPath -ArgumentList "/S" -PassThru -Wait
|
||||||
|
Write-Output "Installer exit code: $($startProcess.ExitCode)"
|
||||||
|
|
||||||
|
# Check for Obsidian executable in possible installation paths
|
||||||
|
$obsidianPaths = @(
|
||||||
|
"C:\Program Files\Obsidian\Obsidian.exe",
|
||||||
|
"$env:LOCALAPPDATA\Programs\Obsidian\Obsidian.exe",
|
||||||
|
"$env:LOCALAPPDATA\Obsidian\Obsidian.exe"
|
||||||
|
)
|
||||||
|
|
||||||
|
$obsidianInstalled = $false
|
||||||
|
foreach ($path in $obsidianPaths) {
|
||||||
|
if (Test-Path $path) {
|
||||||
|
$obsidianInstalled = $true
|
||||||
|
Write-Output "Obsidian found at $path"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($obsidianInstalled) {
|
||||||
|
Write-Output "Obsidian installed successfully."
|
||||||
|
} else {
|
||||||
|
Write-Output "Obsidian installation failed."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-Output "Failed to download Obsidian installer."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Initialize-ObsidianConfig {
|
||||||
|
Write-Output "Initializing Obsidian configuration..."
|
||||||
|
$vaultPath = "$env:USERPROFILE\Documents\ObsidianVault"
|
||||||
|
$configPath = "$vaultPath\.obsidian\config"
|
||||||
|
|
||||||
|
if (-Not (Test-Path $vaultPath)) {
|
||||||
|
Write-Output "Creating Obsidian vault directory..."
|
||||||
|
New-Item -ItemType Directory -Path $vaultPath | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-Not (Test-Path $configPath)) {
|
||||||
|
Write-Output "Creating default Obsidian config..."
|
||||||
|
$defaultConfig = @{
|
||||||
|
"plugin:file-explorer" = $true;
|
||||||
|
"plugin:global-search" = $true;
|
||||||
|
}
|
||||||
|
$defaultConfig | ConvertTo-Json -Compress | Set-Content -Path $configPath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Test-PluginInstallation {
|
||||||
|
Write-Output "Testing plugin installation..."
|
||||||
|
|
||||||
|
# Define the vault path and plugins directory
|
||||||
|
$vaultPath = "$env:USERPROFILE\Documents\ObsidianVault" # Update this path as needed
|
||||||
|
$pluginsDir = "$vaultPath\.obsidian\plugins"
|
||||||
|
|
||||||
|
# Ensure the plugins directory exists
|
||||||
|
if (-Not (Test-Path $pluginsDir)) {
|
||||||
|
New-Item -ItemType Directory -Path $pluginsDir | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get the list of installed plugins before installation
|
||||||
|
$pluginsBefore = Get-ChildItem -Path $pluginsDir
|
||||||
|
|
||||||
|
# Simulate plugin installation
|
||||||
|
$pluginsConfigPath = ".\plugins.json"
|
||||||
|
$pluginsConfig = Get-Content -Raw -Path $pluginsConfigPath | ConvertFrom-Json
|
||||||
|
$corePlugins = $pluginsConfig.core_plugins
|
||||||
|
$communityPlugins = $pluginsConfig.community_plugins
|
||||||
|
|
||||||
|
# Enable core plugins
|
||||||
|
$configPath = "$vaultPath\.obsidian\config"
|
||||||
|
if (-Not (Test-Path $configPath)) {
|
||||||
|
Initialize-ObsidianConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
$config = Get-Content -Raw -Path $configPath | ConvertFrom-Json
|
||||||
|
foreach ($plugin in $corePlugins) {
|
||||||
|
Write-Output "Enabling core plugin: $plugin"
|
||||||
|
$config["plugin:$plugin"] = $true
|
||||||
|
}
|
||||||
|
$config | ConvertTo-Json -Compress | Set-Content -Path $configPath
|
||||||
|
|
||||||
|
# Install community plugins
|
||||||
|
foreach ($plugin in $communityPlugins) {
|
||||||
|
Write-Output "Installing community plugin: $plugin"
|
||||||
|
$pluginName = $plugin -replace '/','-'
|
||||||
|
$pluginUrl = "https://github.com/$plugin/releases/latest/download/main.js"
|
||||||
|
$pluginDir = "$pluginsDir\$pluginName"
|
||||||
|
if (-Not (Test-Path $pluginDir)) {
|
||||||
|
New-Item -ItemType Directory -Path $pluginDir | Out-Null
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Invoke-WebRequest -Uri $pluginUrl -OutFile "$pluginDir\main.js" -ErrorAction Stop
|
||||||
|
} catch {
|
||||||
|
Write-Output "Failed to download plugin from $pluginUrl"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get the list of installed plugins after installation
|
||||||
|
$pluginsAfter = Get-ChildItem -Path $pluginsDir
|
||||||
|
|
||||||
|
# Compare the before and after lists
|
||||||
|
Write-Output "Plugins before installation:"
|
||||||
|
$pluginsBefore | ForEach-Object { Write-Output $_.Name }
|
||||||
|
|
||||||
|
Write-Output "Plugins after installation:"
|
||||||
|
$pluginsAfter | ForEach-Object { Write-Output $_.Name }
|
||||||
|
|
||||||
|
# Check if new plugins were installed
|
||||||
|
$newPlugins = Compare-Object -ReferenceObject $pluginsBefore -DifferenceObject $pluginsAfter
|
||||||
|
if ($newPlugins) {
|
||||||
|
Write-Output "New plugins installed successfully."
|
||||||
|
} else {
|
||||||
|
Write-Output "No new plugins were installed."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run tests
|
||||||
|
Test-AdminPrivilege
|
||||||
|
Test-ChocolateyInstallation
|
||||||
|
Test-ObsidianDownload
|
||||||
|
Test-InvalidPluginConfig
|
||||||
|
Test-ObsidianInstallation
|
||||||
|
Test-PluginInstallation
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function test_os_selection {
|
||||||
|
echo "Testing OS selection..."
|
||||||
|
echo "L" | ./install_obsidian.sh
|
||||||
|
echo "M" | ./install_obsidian.sh
|
||||||
|
echo "W" | ./install_obsidian.sh
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_dependencies_installation {
|
||||||
|
echo "Simulating environment without wget and jq..."
|
||||||
|
sudo apt remove -y wget jq
|
||||||
|
|
||||||
|
echo "Installing dependencies..."
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install -y wget jq
|
||||||
|
|
||||||
|
if ! command -v wget &> /dev/null || ! command -v jq &> /dev/null; then
|
||||||
|
echo "Failed to install dependencies."
|
||||||
|
else
|
||||||
|
echo "Dependencies installed successfully."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_obsidian_download_failure {
|
||||||
|
echo "Simulating download failure..."
|
||||||
|
sudo iptables -A OUTPUT -p tcp --dport 443 -j REJECT
|
||||||
|
|
||||||
|
echo "Downloading Obsidian..."
|
||||||
|
wget https://github.com/obsidianmd/obsidian-releases/releases/download/v1.6.3/Obsidian-1.6.3.AppImage -O obsidian.AppImage
|
||||||
|
if [ ! -f obsidian.AppImage ]; then
|
||||||
|
echo "Download failed as expected."
|
||||||
|
else
|
||||||
|
echo "Download succeeded unexpectedly."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Clean up iptables rule
|
||||||
|
sudo iptables -D OUTPUT -p tcp --dport 443 -j REJECT
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create an invalid plugins.json file
|
||||||
|
echo '{
|
||||||
|
"core_plugins": ["plugin1", "plugin2"],
|
||||||
|
"community_plugins": ["plugin3", "plugin4"]
|
||||||
|
}' > invalid_plugins.json
|
||||||
|
|
||||||
|
function test_invalid_plugins_config {
|
||||||
|
echo "Testing with invalid plugins.json..."
|
||||||
|
if jq . invalid_plugins.json; then
|
||||||
|
echo "Invalid plugins.json parsed unexpectedly."
|
||||||
|
else
|
||||||
|
echo "Caught error parsing invalid plugins.json as expected."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_plugin_installation {
|
||||||
|
echo "Testing plugin installation..."
|
||||||
|
|
||||||
|
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||||
|
CONFIG_DIR="$HOME/.config/obsidian"
|
||||||
|
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
|
CONFIG_DIR="$HOME/Library/Application Support/obsidian"
|
||||||
|
fi
|
||||||
|
|
||||||
|
PLUGINS_DIR="$CONFIG_DIR/plugins"
|
||||||
|
|
||||||
|
mkdir -p "$PLUGINS_DIR"
|
||||||
|
|
||||||
|
PLUGINS_FILE=plugins.json
|
||||||
|
echo '{
|
||||||
|
"core_plugins": [
|
||||||
|
"file-explorer",
|
||||||
|
"global-search"
|
||||||
|
],
|
||||||
|
"community_plugins": [
|
||||||
|
"tgrosinger/advanced-tables-obsidian",
|
||||||
|
"mgmeyers/obsidian-kanban"
|
||||||
|
]
|
||||||
|
}' > "$PLUGINS_FILE"
|
||||||
|
|
||||||
|
# Capture the list of installed plugins before running the installation script
|
||||||
|
PLUGINS_BEFORE=$(ls -1 "$PLUGINS_DIR")
|
||||||
|
|
||||||
|
# Run the installation script
|
||||||
|
./install_obsidian.sh
|
||||||
|
|
||||||
|
# Capture the list of installed plugins after running the installation script
|
||||||
|
PLUGINS_AFTER=$(ls -1 "$PLUGINS_DIR")
|
||||||
|
|
||||||
|
# Compare the lists of plugins
|
||||||
|
echo "Plugins before installation:"
|
||||||
|
echo "$PLUGINS_BEFORE"
|
||||||
|
|
||||||
|
echo "Plugins after installation:"
|
||||||
|
echo "$PLUGINS_AFTER"
|
||||||
|
|
||||||
|
# Check for newly installed plugins
|
||||||
|
NEW_PLUGINS=$(comm -13 <(echo "$PLUGINS_BEFORE") <(echo "$PLUGINS_AFTER"))
|
||||||
|
if [ -n "$NEW_PLUGINS" ]; then
|
||||||
|
echo "New plugins installed successfully:"
|
||||||
|
echo "$NEW_PLUGINS"
|
||||||
|
else
|
||||||
|
echo "No new plugins were installed."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run tests
|
||||||
|
test_os_selection
|
||||||
|
test_dependencies_installation
|
||||||
|
test_obsidian_download_failure
|
||||||
|
test_invalid_plugins_config
|
||||||
|
test_plugin_installation
|
||||||
+34
-14
@@ -9,24 +9,21 @@ function Install-Obsidian-Windows {
|
|||||||
Write-Output "Installing Obsidian for Windows..."
|
Write-Output "Installing Obsidian for Windows..."
|
||||||
if (-Not (Get-Command choco -ErrorAction SilentlyContinue)) {
|
if (-Not (Get-Command choco -ErrorAction SilentlyContinue)) {
|
||||||
Write-Output "Chocolatey is not installed. Installing Chocolatey..."
|
Write-Output "Chocolatey is not installed. Installing Chocolatey..."
|
||||||
Set-ExecutionPolicy Bypass -Scope Process -Force;
|
Set-ExecutionPolicy Bypass -Scope Process -Force
|
||||||
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
|
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
|
||||||
$script = (New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')
|
$script = (New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')
|
||||||
Invoke-Command -ScriptBlock ([ScriptBlock]::Create($script))
|
Invoke-Command -ScriptBlock ([ScriptBlock]::Create($script))
|
||||||
}
|
}
|
||||||
choco install -y jq
|
choco install -y jq
|
||||||
|
|
||||||
Write-Output "Checking latest Obsidian version..."
|
Write-Output "Downloading Obsidian installer..."
|
||||||
$version = (Invoke-RestMethod -Uri "https://api.github.com/repos/obsidianmd/obsidian-releases/releases/latest").tag_name
|
$installerPath = "$env:TEMP\ObsidianInstaller.exe"
|
||||||
$versionNum = $version.TrimStart('v')
|
Invoke-WebRequest -Uri "https://github.com/obsidianmd/obsidian-releases/releases/download/v1.6.3/Obsidian.1.6.3.exe" -OutFile $installerPath
|
||||||
|
|
||||||
Write-Output "Downloading Obsidian installer ($version)..."
|
|
||||||
Invoke-WebRequest -Uri "https://github.com/obsidianmd/obsidian-releases/releases/download/$version/Obsidian-$versionNum.exe" -OutFile "ObsidianInstaller.exe"
|
|
||||||
|
|
||||||
# Check if the installer was downloaded
|
# Check if the installer was downloaded
|
||||||
if (Test-Path "ObsidianInstaller.exe") {
|
if (Test-Path $installerPath) {
|
||||||
Write-Output "Running Obsidian installer..."
|
Write-Output "Running Obsidian installer..."
|
||||||
$startProcess = Start-Process -FilePath .\ObsidianInstaller.exe -ArgumentList "/S" -PassThru -Wait
|
$startProcess = Start-Process -FilePath $installerPath -ArgumentList "/S" -PassThru -Wait
|
||||||
Write-Output "Installer exit code: $($startProcess.ExitCode)"
|
Write-Output "Installer exit code: $($startProcess.ExitCode)"
|
||||||
|
|
||||||
# Check for Obsidian executable in possible installation paths
|
# Check for Obsidian executable in possible installation paths
|
||||||
@@ -66,27 +63,50 @@ function Install-Plugin {
|
|||||||
Stop-Process -Name "Obsidian" -Force
|
Stop-Process -Name "Obsidian" -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Define the vault path and plugins directory
|
||||||
|
$vaultPath = "$env:USERPROFILE\Documents\ObsidianVault" # Update this path as needed
|
||||||
|
$pluginsDir = "$vaultPath\.obsidian\plugins"
|
||||||
|
|
||||||
# Create the plugins directory if it doesn't exist
|
# Create the plugins directory if it doesn't exist
|
||||||
$pluginsDir = "$env:APPDATA\obsidian\plugins"
|
|
||||||
if (-Not (Test-Path $pluginsDir)) {
|
if (-Not (Test-Path $pluginsDir)) {
|
||||||
New-Item -ItemType Directory -Path $pluginsDir | Out-Null
|
New-Item -ItemType Directory -Path $pluginsDir | Out-Null
|
||||||
}
|
}
|
||||||
|
|
||||||
# Read plugins configuration file
|
# Read plugins configuration file
|
||||||
$pluginsConfig = Get-Content -Raw -Path "plugins.json" | ConvertFrom-Json
|
$pluginsConfigPath = ".\plugins.json" # Ensure this is the correct path to your plugins.json file
|
||||||
|
if (-Not (Test-Path $pluginsConfigPath)) {
|
||||||
|
Write-Output "plugins.json file not found."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
$pluginsConfig = Get-Content -Raw -Path $pluginsConfigPath | ConvertFrom-Json
|
||||||
$corePlugins = $pluginsConfig.core_plugins
|
$corePlugins = $pluginsConfig.core_plugins
|
||||||
$communityPlugins = $pluginsConfig.community_plugins
|
$communityPlugins = $pluginsConfig.community_plugins
|
||||||
|
|
||||||
# Enable core plugins
|
# Enable core plugins
|
||||||
|
$configPath = "$vaultPath\.obsidian\config"
|
||||||
|
if (-Not (Test-Path $configPath)) {
|
||||||
|
Write-Output "Obsidian config not found. Ensure Obsidian has been started at least once with the vault."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
$config = Get-Content -Raw -Path $configPath | ConvertFrom-Json
|
||||||
foreach ($plugin in $corePlugins) {
|
foreach ($plugin in $corePlugins) {
|
||||||
Write-Output "Enabling core plugin: $plugin"
|
Write-Output "Enabling core plugin: $plugin"
|
||||||
New-Item -ItemType File -Path "$pluginsDir\$plugin" | Out-Null
|
$config["plugin:$plugin"] = $true
|
||||||
}
|
}
|
||||||
|
$config | ConvertTo-Json -Compress | Set-Content -Path $configPath
|
||||||
|
|
||||||
# Install community plugins
|
# Install community plugins
|
||||||
foreach ($plugin in $communityPlugins) {
|
foreach ($plugin in $communityPlugins) {
|
||||||
Write-Output "Installing community plugin: $plugin"
|
Write-Output "Installing community plugin: $plugin"
|
||||||
New-Item -ItemType Directory -Path "$pluginsDir\$plugin" | Out-Null
|
$pluginName = $plugin -replace '/','-'
|
||||||
|
$pluginUrl = "https://github.com/$plugin/releases/latest/download/main.js"
|
||||||
|
$pluginDir = "$pluginsDir\$pluginName"
|
||||||
|
if (-Not (Test-Path $pluginDir)) {
|
||||||
|
New-Item -ItemType Directory -Path $pluginDir | Out-Null
|
||||||
|
}
|
||||||
|
Invoke-WebRequest -Uri $pluginUrl -OutFile "$pluginDir\main.js"
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Output "Plugins installed successfully."
|
Write-Output "Plugins installed successfully."
|
||||||
|
|||||||
+36
-18
@@ -5,11 +5,15 @@ install_obsidian_linux() {
|
|||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install -y wget jq
|
sudo apt install -y wget jq
|
||||||
|
|
||||||
VERSION=$(wget -qO- https://api.github.com/repos/obsidianmd/obsidian-releases/releases/latest | jq -r .tag_name)
|
wget https://github.com/obsidianmd/obsidian-releases/releases/download/v1.6.3/Obsidian-1.6.3.AppImage -O obsidian.AppImage
|
||||||
wget "https://github.com/obsidianmd/obsidian-releases/releases/download/${VERSION}/Obsidian-${VERSION#v}.AppImage" -O obsidian.AppImage
|
|
||||||
chmod +x obsidian.AppImage
|
chmod +x obsidian.AppImage
|
||||||
./obsidian.AppImage &
|
./obsidian.AppImage &
|
||||||
|
|
||||||
|
# Wait a bit to ensure Obsidian initializes its config
|
||||||
|
sleep 10
|
||||||
|
pkill -f obsidian.AppImage
|
||||||
|
|
||||||
|
# Simulate creating a command alias for testing
|
||||||
sudo ln -sf $(pwd)/obsidian.AppImage /usr/local/bin/obsidian
|
sudo ln -sf $(pwd)/obsidian.AppImage /usr/local/bin/obsidian
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,44 +25,56 @@ install_obsidian_macos() {
|
|||||||
fi
|
fi
|
||||||
brew install wget jq
|
brew install wget jq
|
||||||
|
|
||||||
VERSION=$(wget -qO- https://api.github.com/repos/obsidianmd/obsidian-releases/releases/latest | jq -r .tag_name)
|
wget https://github.com/obsidianmd/obsidian-releases/releases/download/v1.6.3/Obsidian-1.6.3-universal.dmg -O Obsidian.dmg
|
||||||
wget "https://github.com/obsidianmd/obsidian-releases/releases/download/${VERSION}/Obsidian-${VERSION#v}.dmg" -O Obsidian.dmg
|
|
||||||
hdiutil attach Obsidian.dmg
|
hdiutil attach Obsidian.dmg
|
||||||
cp -r /Volumes/Obsidian/Obsidian.app /Applications/
|
cp -r /Volumes/Obsidian/Obsidian.app /Applications/
|
||||||
hdiutil detach /Volumes/Obsidian
|
hdiutil detach /Volumes/Obsidian
|
||||||
open /Applications/Obsidian.app &
|
open /Applications/Obsidian.app &
|
||||||
|
|
||||||
|
# Wait a bit to ensure Obsidian initializes its config
|
||||||
|
sleep 10
|
||||||
|
pkill Obsidian
|
||||||
|
|
||||||
|
# Simulate creating a command alias for testing
|
||||||
sudo ln -sf /Applications/Obsidian.app/Contents/MacOS/Obsidian /usr/local/bin/obsidian
|
sudo ln -sf /Applications/Obsidian.app/Contents/MacOS/Obsidian /usr/local/bin/obsidian
|
||||||
}
|
}
|
||||||
|
|
||||||
install_plugins() {
|
install_plugins() {
|
||||||
echo "Installing plugins..."
|
echo "Installing plugins..."
|
||||||
if [[ "$OSTYPE" == "linux-gnu"* || "$OSTYPE" == "darwin"* ]]; then
|
|
||||||
|
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||||
|
pkill -f obsidian.AppImage
|
||||||
|
CONFIG_DIR="$HOME/.config/obsidian"
|
||||||
|
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
pkill Obsidian
|
pkill Obsidian
|
||||||
elif [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
|
CONFIG_DIR="$HOME/Library/Application Support/obsidian"
|
||||||
taskkill /IM Obsidian.exe /F
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$OSTYPE" == "linux-gnu"* || "$OSTYPE" == "darwin"* ]]; then
|
mkdir -p "$CONFIG_DIR/plugins"
|
||||||
mkdir -p ~/.config/obsidian/plugins
|
|
||||||
elif [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
|
|
||||||
mkdir -p "$APPDATA\obsidian\plugins"
|
|
||||||
fi
|
|
||||||
|
|
||||||
PLUGINS_FILE=plugins.json
|
PLUGINS_FILE=plugins.json
|
||||||
CORE_PLUGINS=$(jq -r '.core_plugins[]' $PLUGINS_FILE)
|
CORE_PLUGINS=$(jq -r '.core_plugins[]' $PLUGINS_FILE)
|
||||||
COMMUNITY_PLUGINS=$(jq -r '.community_plugins[]' $PLUGINS_FILE)
|
COMMUNITY_PLUGINS=$(jq -r '.community_plugins[]' $PLUGINS_FILE)
|
||||||
|
|
||||||
|
# Enable core plugins
|
||||||
|
CONFIG_FILE="$CONFIG_DIR/config"
|
||||||
|
if [[ ! -f "$CONFIG_FILE" ]]; then
|
||||||
|
echo "{}" > "$CONFIG_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
for plugin in $CORE_PLUGINS; do
|
for plugin in $CORE_PLUGINS; do
|
||||||
echo "Enabling core plugin: $plugin"
|
echo "Enabling core plugin: $plugin"
|
||||||
# Simulate enabling core plugin by creating a file
|
jq ". + {\"plugin:$plugin\": true}" "$CONFIG_FILE" > tmp.json && mv tmp.json "$CONFIG_FILE"
|
||||||
touch "$HOME/.config/obsidian/plugins/$plugin"
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Install community plugins
|
||||||
for plugin in $COMMUNITY_PLUGINS; do
|
for plugin in $COMMUNITY_PLUGINS; do
|
||||||
echo "Installing community plugin: $plugin"
|
echo "Installing community plugin: $plugin"
|
||||||
# Simulate installing community plugin by creating a directory
|
PLUGIN_NAME=$(echo $plugin | sed 's/\//-/g')
|
||||||
mkdir -p "$HOME/.config/obsidian/plugins/$plugin"
|
PLUGIN_URL="https://github.com/$plugin/releases/latest/download/main.js"
|
||||||
|
PLUGIN_DIR="$CONFIG_DIR/plugins/$PLUGIN_NAME"
|
||||||
|
mkdir -p "$PLUGIN_DIR"
|
||||||
|
wget "$PLUGIN_URL" -O "$PLUGIN_DIR/main.js" || echo "Failed to download plugin $plugin"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Plugins installed successfully!"
|
echo "Plugins installed successfully!"
|
||||||
@@ -72,8 +88,10 @@ echo "W) Windows"
|
|||||||
read -p "Enter your choice: " os_choice
|
read -p "Enter your choice: " os_choice
|
||||||
|
|
||||||
case "$os_choice" in
|
case "$os_choice" in
|
||||||
[Ll]) install_obsidian_linux; install_plugins ;;
|
[Ll]) install_obsidian_linux ;;
|
||||||
[Mm]) install_obsidian_macos; install_plugins ;;
|
[Mm]) install_obsidian_macos ;;
|
||||||
[Ww]) echo "Please run the script install_obsidian.ps1 in PowerShell for Windows installation." ;;
|
[Ww]) echo "Please run the script install_obsidian.ps1 in PowerShell for Windows installation." ;;
|
||||||
*) echo "Invalid choice. Exiting." ;;
|
*) echo "Invalid choice. Exiting." ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
install_plugins
|
||||||
|
|||||||
Reference in New Issue
Block a user