mounts manager added
This commit is contained in:
@@ -0,0 +1,33 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
:: .ssh
|
||||||
|
setlocal
|
||||||
|
set "from_1=%storage%\SSH\%user-name%"
|
||||||
|
set "to_1=%USERPROFILE%\.ssh"
|
||||||
|
rd /q "%to_1%"
|
||||||
|
mklink /D "%to_1%" "%from_1%"
|
||||||
|
endlocal
|
||||||
|
|
||||||
|
:: Bash
|
||||||
|
setlocal
|
||||||
|
set "from_1=%storage%\User Folder\.bashrc"
|
||||||
|
set "to_1=%USERPROFILE%\.bashrc"
|
||||||
|
set "from_2=%storage%\User Folder\.inputrc"
|
||||||
|
set "to_2=%USERPROFILE%\.inputrc"
|
||||||
|
set "from_3=%storage%\User Folder\.gitconfig"
|
||||||
|
set "to_3=%USERPROFILE%\.gitconfig"
|
||||||
|
del /q "%to_1%"
|
||||||
|
del /q "%to_2%"
|
||||||
|
del /q "%to_3%"
|
||||||
|
mklink "%to_1%" "%from_1%"
|
||||||
|
mklink "%to_2%" "%from_2%"
|
||||||
|
mklink "%to_3%" "%from_3%"
|
||||||
|
endlocal
|
||||||
|
|
||||||
|
:: WSL
|
||||||
|
setlocal
|
||||||
|
set "from_1=%storage%\User Folder\.wslconfig"
|
||||||
|
set "to_1=%USERPROFILE%\.wslconfig"
|
||||||
|
del /q "%to_1%"
|
||||||
|
mklink "%to_1%" "%from_1%"
|
||||||
|
endlocal
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
Enabled,Name,From,To
|
||||||
|
1,SSH,$storage\SSH\$env:USERNAME,$env:USERPROFILE\.ssh
|
||||||
|
1,bash_rc,$storage\User Folder\.bashrc,$env:USERPROFILE\.bashrc
|
||||||
|
1,bash_inputrc,$storage\User Folder\.inputrc,$env:USERPROFILE\.inputrc
|
||||||
|
1,bash_gitconfig,$storage\User Folder\.gitconfig,$env:USERPROFILE\.gitconfig
|
||||||
|
1,wslconfig,$storage\User Folder\.wslconfig,$env:USERPROFILE\.wslconfig
|
||||||
|
@@ -16,6 +16,7 @@ Write-Host "Administrator privileges confirmed."
|
|||||||
$modules = @{
|
$modules = @{
|
||||||
"appsDataManager" = @("reconnect", "connect", "disconnect")
|
"appsDataManager" = @("reconnect", "connect", "disconnect")
|
||||||
"autostartManager" = @("update", "remove")
|
"autostartManager" = @("update", "remove")
|
||||||
|
"mountsManager" = @("reconnect", "connect", "disconnect")
|
||||||
}
|
}
|
||||||
|
|
||||||
# Interactive module selection
|
# Interactive module selection
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
param(
|
||||||
|
[string]$action = "reconnect" # connect | disconnect | reconnect
|
||||||
|
)
|
||||||
|
|
||||||
|
Write-Host "Folder Symlink Manager started with action: $action"
|
||||||
|
|
||||||
|
# CSV file with folder mappings
|
||||||
|
$config = $mountsAll # переменная с путём к CSV
|
||||||
|
|
||||||
|
# Import CSV
|
||||||
|
$csv = Import-Csv -Path $config
|
||||||
|
|
||||||
|
foreach ($entry in $csv) {
|
||||||
|
if ($entry.Enabled -ne "1") { continue }
|
||||||
|
|
||||||
|
$Name = $entry.Name
|
||||||
|
|
||||||
|
# Expand From and To strings
|
||||||
|
$rawFrom = $entry.From -replace '\$Name', $Name
|
||||||
|
$rawTo = $entry.To -replace '\$Name', $Name
|
||||||
|
|
||||||
|
# Expand environment variables
|
||||||
|
$from = $ExecutionContext.InvokeCommand.ExpandString($rawFrom)
|
||||||
|
$to = $ExecutionContext.InvokeCommand.ExpandString($rawTo)
|
||||||
|
|
||||||
|
# If To path is relative, make it absolute relative to the user
|
||||||
|
if (-not [System.IO.Path]::IsPathRooted($to)) {
|
||||||
|
$to = Join-Path $env:USERPROFILE $to
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "=============================="
|
||||||
|
Write-Host "Processing $Name with action $action"
|
||||||
|
Write-Host " From: $from"
|
||||||
|
Write-Host " To : $to"
|
||||||
|
|
||||||
|
switch ($action.ToLower()) {
|
||||||
|
"disconnect" {
|
||||||
|
Write-Host " Removing $to"
|
||||||
|
if (Test-Path $to) { Remove-Item $to -Recurse -Force }
|
||||||
|
}
|
||||||
|
"connect" {
|
||||||
|
Write-Host " Creating symlink $to -> $from"
|
||||||
|
if (-not (Test-Path $to)) {
|
||||||
|
New-Item -Path $to -ItemType SymbolicLink -Value $from | Out-Null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"reconnect" {
|
||||||
|
Write-Host " Removing $to"
|
||||||
|
if (Test-Path $to) { Remove-Item $to -Recurse -Force }
|
||||||
|
Write-Host " Creating symlink $to -> $from"
|
||||||
|
if (-not (Test-Path $to)) {
|
||||||
|
New-Item -Path $to -ItemType SymbolicLink -Value $from | Out-Null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default {
|
||||||
|
Write-Warning "Unknown action: $action"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-1
@@ -1,8 +1,9 @@
|
|||||||
# LOCAL
|
# LOCAL
|
||||||
|
|
||||||
# Modules
|
# Modules
|
||||||
$appsDataManager = "$PSScriptRoot\modules\apps-data-manager.ps1"
|
$appsDataManager = "$PSScriptRoot\modules\appdata-manager.ps1"
|
||||||
$autostartManager = "$PSScriptRoot\modules\autostart-manager.ps1"
|
$autostartManager = "$PSScriptRoot\modules\autostart-manager.ps1"
|
||||||
|
$mountsManager = "$PSScriptRoot\modules\mounts-manager.ps1"
|
||||||
|
|
||||||
# Package Manager Installers
|
# Package Manager Installers
|
||||||
$winget = "$PSScriptRoot\winget.ps1"
|
$winget = "$PSScriptRoot\winget.ps1"
|
||||||
@@ -13,6 +14,7 @@ $data = "$root\data"
|
|||||||
# Setup Data Folder
|
# Setup Data Folder
|
||||||
$apps = "$data\isolate"
|
$apps = "$data\isolate"
|
||||||
$appsAll = "$data\apps.csv"
|
$appsAll = "$data\apps.csv"
|
||||||
|
$mountsAll = "$data\mounts.csv"
|
||||||
# $appsUser = "$apps\$env:COMPUTERNAME"
|
# $appsUser = "$apps\$env:COMPUTERNAME"
|
||||||
# $appsLegacy = "$apps\legacy"
|
# $appsLegacy = "$apps\legacy"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user