complete..

This commit is contained in:
2025-10-10 23:09:48 +03:00
parent a708387ddd
commit 9ece0152e4
8 changed files with 46 additions and 182 deletions
Binary file not shown.
-33
View File
@@ -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
-33
View File
@@ -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
+4 -3
View File
@@ -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
-39
View File
@@ -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
-66
View File
@@ -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'."
}
}
+36
View File
@@ -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."
+6 -8
View File
@@ -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:"