new modules
This commit is contained in:
@@ -10,6 +10,8 @@ $Modules = @(
|
||||
@{ Name = 'autostartManagerModule'; Apply = 'update'; Clean = 'remove' },
|
||||
@{ Name = 'appsDataManagerModule'; Apply = 'reconnect'; Clean = 'disconnect' },
|
||||
@{ Name = 'mountsManagerModule'; Apply = 'reconnect'; Clean = 'disconnect' }
|
||||
@{ Name = 'wingetInstallerModule'; Apply = 'install'; Clean = 'check' }
|
||||
@{ Name = 'packageManagerModule'; Apply = 'install'; Clean = 'uninstall' }
|
||||
)
|
||||
|
||||
foreach ($module in $Modules) {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[ValidateSet("install","uninstall")]
|
||||
[string]$Mode
|
||||
)
|
||||
|
||||
$packageList = @(
|
||||
"MartiCliment.UniGetUI"
|
||||
)
|
||||
|
||||
if (-not (checkWingetStatus)) {
|
||||
Write-Host "winget is not available. Aborting." -ForegroundColor Red
|
||||
return
|
||||
}
|
||||
|
||||
foreach ($pkg in $packageList) {
|
||||
switch ($Mode) {
|
||||
"install" {
|
||||
Write-Host "Installing $pkg..." -ForegroundColor Cyan
|
||||
try {
|
||||
winget install --id $pkg --silent --accept-package-list-agreements --accept-source-agreements
|
||||
}
|
||||
catch {
|
||||
Write-Host "Failed to install $pkg : $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
"uninstall" {
|
||||
Write-Host "Uninstalling $pkg..." -ForegroundColor Cyan
|
||||
try {
|
||||
winget uninstall --id $pkg --silent
|
||||
}
|
||||
catch {
|
||||
Write-Host "Failed to uninstall $pkg : $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Write-Host "All requested packages processed." -ForegroundColor Green
|
||||
@@ -0,0 +1,33 @@
|
||||
param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[ValidateSet("check","install")]
|
||||
[string]$Mode
|
||||
)
|
||||
function install {
|
||||
if (checkWingetStatus) {
|
||||
Write-Host "Skipping installation, winget already present." -ForegroundColor Cyan
|
||||
return
|
||||
}
|
||||
$wingetUrl = "https://aka.ms/getwinget"
|
||||
$wingetFile = "$tempFolder\winget.msixbundle"
|
||||
try {
|
||||
Write-Host "Downloading winget..." -ForegroundColor Cyan
|
||||
Invoke-WebRequest -Uri $wingetUrl -OutFile $wingetFile -UseBasicParsing
|
||||
|
||||
Write-Host "Installing winget..." -ForegroundColor Cyan
|
||||
Add-AppxPackage $wingetFile
|
||||
|
||||
Write-Host "winget successfully installed." -ForegroundColor Green
|
||||
}
|
||||
catch {
|
||||
Write-Host "Failed to install winget: $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
finally {
|
||||
if (Test-Path $wingetFile) { Remove-Item $wingetFile -Force }
|
||||
}
|
||||
}
|
||||
|
||||
switch ($Mode) {
|
||||
"check" { return checkWingetStatus | Out-Null }
|
||||
"install" { install }
|
||||
}
|
||||
+16
-2
@@ -3,6 +3,8 @@ $appsDataManagerModule = "$PSScriptRoot\modules\appdata-manager.ps1"
|
||||
$autostartManagerModule = "$PSScriptRoot\modules\autostart-manager.ps1"
|
||||
$mountsManagerModule = "$PSScriptRoot\modules\mounts-manager.ps1"
|
||||
$deployModule = "$PSScriptRoot\modules\deploy.ps1"
|
||||
$wingetInstallerModule = "$PSScriptRoot\modules\winget-installer.ps1"
|
||||
$packageManagerModule = "$PSScriptRoot\modules\package-manager.ps1"
|
||||
|
||||
# Define available modules with their respective actions
|
||||
$modules = @{
|
||||
@@ -10,10 +12,21 @@ $modules = @{
|
||||
"autostartManagerModule" = @("update", "remove")
|
||||
"deployModule" = @("apply", "clean")
|
||||
"mountsManagerModule" = @("reconnect", "connect", "disconnect")
|
||||
"packageManagerModule" = @("install", "uninstall")
|
||||
}
|
||||
|
||||
# Package Manager Installers
|
||||
$winget = "$PSScriptRoot\winget.ps1"
|
||||
# Functions
|
||||
function checkWingetStatus {
|
||||
try {
|
||||
$null = winget --version 2>$null
|
||||
Write-Host "Winget is installed." -ForegroundColor Green
|
||||
return $true
|
||||
}
|
||||
catch {
|
||||
Write-Host "Winget is not installed." -ForegroundColor Yellow
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
# Data folder
|
||||
$data = "$root\data"
|
||||
@@ -24,5 +37,6 @@ $appsAll = "$data\apps.csv"
|
||||
$mountsAll = "$data\mounts.csv"
|
||||
|
||||
# GLOBAL
|
||||
$tempFolder = "$env:TEMP\winos";
|
||||
$storage = "$env:USERPROFILE\Storage"
|
||||
$autostartDir = "$data\autorun"
|
||||
@@ -1,3 +0,0 @@
|
||||
Invoke-WebRequest -Uri https://aka.ms/getwinget -OutFile winget.msixbundle
|
||||
Add-AppxPackage winget.msixbundle
|
||||
Remove-Item winget.msixbundle
|
||||
Reference in New Issue
Block a user