-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-sync.ps1
More file actions
82 lines (66 loc) · 2.61 KB
/
setup-sync.ps1
File metadata and controls
82 lines (66 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# JPad Cloud Sync Setup Script (PowerShell)
# This script helps you configure WebDAV sync with your Synology NAS
Write-Host "================================" -ForegroundColor Cyan
Write-Host "JPad Cloud Sync Setup" -ForegroundColor Cyan
Write-Host "================================" -ForegroundColor Cyan
Write-Host ""
# Check if .env exists
if (Test-Path .env) {
Write-Host "⚠️ .env file already exists!" -ForegroundColor Yellow
$overwrite = Read-Host "Do you want to overwrite it? (y/N)"
if ($overwrite -notmatch '^[Yy]$') {
Write-Host "Setup cancelled." -ForegroundColor Red
exit 0
}
}
Write-Host "Please enter your Synology WebDAV details:" -ForegroundColor Green
Write-Host ""
# Get WebDAV URL
$webdav_url = Read-Host "WebDAV Server URL (e.g., https://192.168.1.100:5006)"
# Get username
$username = Read-Host "Username"
# Get password (secure input)
$password_secure = Read-Host "Password" -AsSecureString
$password = [Runtime.InteropServices.Marshal]::PtrToStringAuto(
[Runtime.InteropServices.Marshal]::SecureStringToBSTR($password_secure)
)
# Get remote path
$remote_path = Read-Host "Remote Path (default: /jpad-notes)"
if ([string]::IsNullOrWhiteSpace($remote_path)) {
$remote_path = "/jpad-notes"
}
# Get sync interval
$sync_interval = Read-Host "Auto-sync interval in seconds (default: 300, 0 to disable)"
if ([string]::IsNullOrWhiteSpace($sync_interval)) {
$sync_interval = "300"
}
# Create .env file
$env_content = @"
# Cloud Sync Configuration
# Generated by setup-sync.ps1 on $(Get-Date -Format "yyyy-MM-dd HH:mm:ss")
# WebDAV Server URL (e.g., https://your-synology.com:5006)
VITE_WEBDAV_URL=$webdav_url
# WebDAV Username
VITE_WEBDAV_USERNAME=$username
# WebDAV Password
VITE_WEBDAV_PASSWORD=$password
# Sync folder path on WebDAV server
VITE_WEBDAV_PATH=$remote_path
# Auto-sync interval in seconds (0 to disable auto-sync)
VITE_SYNC_INTERVAL=$sync_interval
"@
$env_content | Out-File -FilePath .env -Encoding UTF8
Write-Host ""
Write-Host "✅ Configuration saved to .env" -ForegroundColor Green
Write-Host ""
Write-Host "Next steps:" -ForegroundColor Cyan
Write-Host "1. Restart JPad to load the new configuration"
Write-Host "2. Open Settings → Cloud Sync"
Write-Host "3. Click 'Save & Connect' to test the connection"
Write-Host "4. Click 'Sync Now' to start syncing"
Write-Host ""
Write-Host "⚠️ Security Note:" -ForegroundColor Yellow
Write-Host "The .env file contains your password in plain text."
Write-Host "Make sure it's not committed to version control (it's in .gitignore)."
Write-Host ""
Write-Host "For more information, see SYNC_SETUP.md" -ForegroundColor Cyan