From 9ece0152e4d76a89ab73cb99b8eb183159011e24 Mon Sep 17 00:00:00 2001 From: oqyude Date: Fri, 10 Oct 2025 23:09:48 +0300 Subject: [PATCH] complete.. --- data/autorun/syncthing.lnk | Bin 0 -> 1527 bytes data/mounts (not done yet)/all.bat | 33 ------------- data/mounts (not done yet)/mounts.bat | 33 ------------- run.ps1 | 7 +-- run.ps1.old | 39 --------------- src/modules/autostart-manager1.ps1.old | 66 ------------------------- src/modules/deploy.ps1 | 36 ++++++++++++++ src/vars.ps1 | 14 +++--- 8 files changed, 46 insertions(+), 182 deletions(-) create mode 100644 data/autorun/syncthing.lnk delete mode 100644 data/mounts (not done yet)/all.bat delete mode 100644 data/mounts (not done yet)/mounts.bat delete mode 100644 run.ps1.old delete mode 100644 src/modules/autostart-manager1.ps1.old create mode 100644 src/modules/deploy.ps1 diff --git a/data/autorun/syncthing.lnk b/data/autorun/syncthing.lnk new file mode 100644 index 0000000000000000000000000000000000000000..0449d20ff50199c5ddbcc321e3115d5dd637bfd5 GIT binary patch literal 1527 zcmeZaU|?VrVPXJ*10aHd!ELny2ZI6&1H+xAHMUoI?=Yg%5M>Muj4%e2=42LOkPmp^ ze?j4uRi?nA8ypPU1_pB_8T6g4VxUTpsR{-|FqboW;ygiy(BjmhVuln3P6if+_xlM({f6f>kU6fqPtFfceU6fi3}wSiC|L$pr-Ogi&zUV_~a)i<}lbGnF$gHnHh@J%p33b zGx#v%GbA%4GUR}L9s@OxJ37i)fWbF2xhTIlKdpqp1<6d19LUTBu$gRN*CB|daYBr~ z44Dkc3`Gq248;uj3~3A{3=9ks@KEK9zBEOEAv`nBJ+%ZmR2AlfWI!gLzYdB^V-SHb zm?3BuCqpo$4FixI2!qUBT?$gp4I&tL z7#J3S84MtEiy0~z@)(jCN*FT0Hl#D?F{Cn7fK!7E0|P?^0|Nty26+-hn?STOl!L>H zfq|KUfq{?9nL~hqfuSt5q%t=#mBHC62Am0EAW1R?nu=n;@g4(@tr$qy#(;w(2GtV` z9t?U6dJHirBqEo@prqRvv=kSElv-jKFk?9eC4NAvL9qo2+ZYDi;UUSO%b?4U$B@sU z%aF{F&yWXBH8~8a3<^jxN#OKU4$aS?P+?_YSfIhc!0;0qlH3do3;J7g;*|Ij+-LoJ zWh}m}uoxtlzyJ=-1rg8?hJ_}S%aGJ7yYO_*3fGx&Wo?1a`v3GdbLH%={2;h0fI&3& z?dGL~gFXWT zLokCbgCT=1gDJG&0Tn-{45kc*3`Ptl48{x=48~x2V+L~uGX?_&QwB3|fo0BM0oG~3 zV8md|V8CF;V8LL*UGaur=<%7gw7yvWoDu@68 literal 0 HcmV?d00001 diff --git a/data/mounts (not done yet)/all.bat b/data/mounts (not done yet)/all.bat deleted file mode 100644 index 6177617..0000000 --- a/data/mounts (not done yet)/all.bat +++ /dev/null @@ -1,33 +0,0 @@ -@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 \ No newline at end of file diff --git a/data/mounts (not done yet)/mounts.bat b/data/mounts (not done yet)/mounts.bat deleted file mode 100644 index 6177617..0000000 --- a/data/mounts (not done yet)/mounts.bat +++ /dev/null @@ -1,33 +0,0 @@ -@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 \ No newline at end of file diff --git a/run.ps1 b/run.ps1 index 4142797..e6b37e2 100644 --- a/run.ps1 +++ b/run.ps1 @@ -14,9 +14,10 @@ Write-Host "Administrator privileges confirmed." # Define available modules with their respective actions $modules = @{ - "appsDataManager" = @("reconnect", "connect", "disconnect") - "autostartManager" = @("update", "remove") - "mountsManager" = @("reconnect", "connect", "disconnect") + "appsDataManagerModule" = @("reconnect", "connect", "disconnect") + "autostartManagerModule" = @("update", "remove") + "mountsManagerModule" = @("reconnect", "connect", "disconnect") + "deployModule" = @("apply", "clean") } # Interactive module selection diff --git a/run.ps1.old b/run.ps1.old deleted file mode 100644 index dc28648..0000000 --- a/run.ps1.old +++ /dev/null @@ -1,39 +0,0 @@ -$initFile = Join-Path $PSScriptRoot ".\src\init.ps1" -. $initFile - -# Check for administrator privileges -if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { - Write-Host "The script requires administrator privileges. Restarting..." - - # Restart the script with admin rights - Start-Process -FilePath "powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs - exit -} - -Write-Host "Administrator privileges confirmed." - -# Define available actions -$actions = @("reconnect", "connect", "disconnect") - -# Determine action: from argument or interactive menu -if ($args.Count -ge 1) { - $action = $args[0] -} else { - Write-Host "Select an action:" - for ($i = 0; $i -lt $actions.Count; $i++) { - Write-Host "[$($i+1)] $($actions[$i])" - } - - do { - $selection = Read-Host "Enter the number of your choice" - $valid = ($selection -as [int]) -and ($selection -ge 1) -and ($selection -le $actions.Count) - if (-not $valid) { Write-Host "Invalid selection. Try again." } - } until ($valid) - - $action = $actions[$selection - 1] -} - -Write-Host "Selected action: $action" - -# Call with the chosen action -. $appsDataManager $action diff --git a/src/modules/autostart-manager1.ps1.old b/src/modules/autostart-manager1.ps1.old deleted file mode 100644 index 06978b3..0000000 --- a/src/modules/autostart-manager1.ps1.old +++ /dev/null @@ -1,66 +0,0 @@ -param( - [string]$action = "update" # update, remove -) - -$taskPrefix = "winos_" - -function Get-ManagedTasks { - Get-ScheduledTask | Where-Object {$_.TaskName -like "$taskPrefix*"} -} -function Update-Tasks($shortcut) { - $shell = New-Object -ComObject WScript.Shell - $sc = $shell.CreateShortcut($shortcut.FullName) - $taskName = "$taskPrefix$($shortcut.BaseName)" - - $existingTask = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue - - # Добавляем аргументы из ярлыка - $actionObj = New-ScheduledTaskAction -Execute $sc.TargetPath -Argument $sc.Arguments - if ($sc.WorkingDirectory) { $actionObj.WorkingDirectory = $sc.WorkingDirectory } - $trigger = New-ScheduledTaskTrigger -AtLogOn - - if ($existingTask) { - Set-ScheduledTask -TaskName $taskName -Action $actionObj -Trigger $trigger - } else { - Register-ScheduledTask -TaskName $taskName -Action $actionObj -Trigger $trigger -User $env:USERNAME -RunLevel Highest -Force - } -} - - -function Remove-AllTasks($tasks) { - foreach ($t in $tasks) { - Unregister-ScheduledTask -TaskName $t.TaskName -Confirm:$false - } -} - -switch ($action) { - "update" { - if (-Not (Test-Path $autostartDir)) { - Write-Error "Папка автозапуска не найдена: $autostartDir" - break - } - - # Получаем все ярлыки из папки - $shortcuts = Get-ChildItem -Path $autostartDir -Filter *.lnk - - # Создаем/обновляем задачи по ярлыкам - foreach ($sc in $shortcuts) { - Update-Tasks $sc - } - - # Удаляем задачи, которых нет в папке - $existingTasks = Get-ManagedTasks - foreach ($t in $existingTasks) { - $nameWithoutPrefix = $t.TaskName.Substring($taskPrefix.Length) - if (-Not ($shortcuts.BaseName -contains $nameWithoutPrefix)) { - Unregister-ScheduledTask -TaskName $t.TaskName -Confirm:$false - } - } - } - "remove" { - Remove-AllTasks (Get-ManagedTasks) - } - default { - Write-Error "Неизвестное действие: $action. Используйте 'update' или 'remove'." - } -} diff --git a/src/modules/deploy.ps1 b/src/modules/deploy.ps1 new file mode 100644 index 0000000..527d80d --- /dev/null +++ b/src/modules/deploy.ps1 @@ -0,0 +1,36 @@ +param( + [ValidateSet("apply","clean")] + [string]$action = "apply" +) + +Write-Host "Deployment Manager started with action: $action" + +# Список модулей с аргументами для apply и clean +$deployModules = @( + @{ Module = "autostartManager"; Apply = "update"; Clean = "remove" }, + @{ Module = "appsDataManager"; Apply = "reconnect"; Clean = "disconnect" }, + @{ Module = "mountsManagerModule"; Apply = "reconnect"; Clean = "disconnect" } +) + +foreach ($item in $deployModules) { + $moduleName = $item.Module + $moduleAction = if ($action -eq "apply") { $item.Apply } else { $item.Clean } + + Write-Host "==============================" + Write-Host "Executing module '$moduleName' with action '$moduleAction'" + + $modulePath = Join-Path $PSScriptRoot "$moduleName.ps1" + + if (Test-Path $modulePath) { + try { + # Передаём аргумент точно так же, как $action передавался бы напрямую модулю + & $modulePath $moduleAction + } catch { + Write-Warning "Module '$moduleName' failed: $($_.Exception.Message)" + } + } else { + Write-Warning "Module script not found: $modulePath" + } +} + +Write-Host "Deployment finished." diff --git a/src/vars.ps1 b/src/vars.ps1 index 23aa500..0b3cb85 100644 --- a/src/vars.ps1 +++ b/src/vars.ps1 @@ -1,9 +1,10 @@ # LOCAL # Modules -$appsDataManager = "$PSScriptRoot\modules\appdata-manager.ps1" -$autostartManager = "$PSScriptRoot\modules\autostart-manager.ps1" -$mountsManager = "$PSScriptRoot\modules\mounts-manager.ps1" +$appsDataManagerModule = "$PSScriptRoot\modules\appdata-manager.ps1" +$autostartManagerModule = "$PSScriptRoot\modules\autostart-manager.ps1" +$mountsManagerModule = "$PSScriptRoot\modules\mounts-manager.ps1" +$deployModule = "$PSScriptRoot\modules\deploy.ps1" # Package Manager Installers $winget = "$PSScriptRoot\winget.ps1" @@ -16,14 +17,11 @@ $apps = "$data\isolate" $appsAll = "$data\apps.csv" $mountsAll = "$data\mounts.csv" # $appsUser = "$apps\$env:COMPUTERNAME" -# $appsLegacy = "$apps\legacy" - -# Mounts -# $mounts = "$data\mounts" # GLOBAL $storage = "$env:USERPROFILE\Storage" -$autostartDir = "C:\Winos\Scenaries\Autorun" +$autostartDir = "$data\autorun" +# $autostartDir = "C:\Winos\Scenaries\Autorun" # $userName = "oqyude" # $diskLabel = "S:"