Add a script for adding nextcloud sync
This commit is contained in:
parent
8dadaa875a
commit
63875268ea
1 changed files with 26 additions and 0 deletions
|
@ -219,6 +219,32 @@ class Context {
|
|||
return "$env:APPDATA/Nextcloud/nextcloud.cfg";
|
||||
}
|
||||
|
||||
[void] AddNextcloudSync([string] $localPath, [string] $targetPath) {
|
||||
$this.AddNextcloudSync($localPath, $targetPath, $false);
|
||||
}
|
||||
|
||||
[void] AddNextcloudSync([string] $localPath, [string] $targetPath, [bool] $virtualFiles) {
|
||||
$pattern = "^\d+\\Folders(?:WithPlaceholders)?\\(\d+)"
|
||||
|
||||
$folderID = (
|
||||
Get-Content $($this.GetNextcloudConfigFile()) | `
|
||||
Where-Object { $_ -match "$pattern" } | `
|
||||
ForEach-Object { $_ -replace "$pattern.*$","`$1" } | `
|
||||
Sort-Object -Unique | `
|
||||
Measure-Object -Maximum).Maximum + 1;
|
||||
|
||||
$configName = "Folders" + (if ($virtualFiles) { "WithPlaceholders" } else { "" });
|
||||
$localPath = $localPath -replace "\","/";
|
||||
$targetPath = $targetPath -replace "\","/";
|
||||
|
||||
Add-Content $this.GetNextcloudConfigFile() `
|
||||
[string]::Join(
|
||||
"`n",
|
||||
@(
|
||||
"0\$configName\$folderID\localPath=$localPath",
|
||||
"0\$configName\$folderID\targetPath=$targetPath"));
|
||||
}
|
||||
|
||||
[void] Reboot() {
|
||||
Write-Host "Restarting Computer...";
|
||||
$this.RegisterReboot();
|
||||
|
|
Loading…
Reference in a new issue