129 lines
6.9 KiB
PowerShell
129 lines
6.9 KiB
PowerShell
# ═══════════════════════════════════════════════════════════════════
|
|
# apps.ps1
|
|
# Windows equivalent of apps.sh — uses winget
|
|
# Run in PowerShell as Administrator:
|
|
# irm https://git.edemilov.ru/edemilov/scripts/raw/branch/main/apps.ps1 | iex
|
|
# ═══════════════════════════════════════════════════════════════════
|
|
|
|
#Requires -RunAsAdministrator
|
|
|
|
$ErrorActionPreference = "Continue"
|
|
|
|
function Write-Header { param($t) Write-Host "`n── $t ──────────────────────────────" -ForegroundColor Cyan }
|
|
function Write-Info { param($t) Write-Host "[•] $t" -ForegroundColor Cyan }
|
|
function Write-Success { param($t) Write-Host "[✓] $t" -ForegroundColor Green }
|
|
function Write-Skip { param($t) Write-Host "[~] $t (already installed)" -ForegroundColor Magenta }
|
|
function Write-Warn { param($t) Write-Host "[!] $t" -ForegroundColor Yellow }
|
|
|
|
Write-Host ""
|
|
Write-Host " ╔══════════════════════════════════════════════╗" -ForegroundColor Cyan
|
|
Write-Host " ║ apps.ps1 — Windows installer ║" -ForegroundColor Cyan
|
|
Write-Host " ║ edemilov homelab scripts ║" -ForegroundColor Cyan
|
|
Write-Host " ╚══════════════════════════════════════════════╝" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
# ── Check winget ────────────────────────────────────────────────────
|
|
Write-Header "Checking winget"
|
|
if (-not (Get-Command winget -ErrorAction SilentlyContinue)) {
|
|
Write-Warn "winget not found — install App Installer from Microsoft Store first"
|
|
Write-Warn "https://www.microsoft.com/store/productId/9NBLGGH4NNS1"
|
|
exit 1
|
|
}
|
|
Write-Success "winget available"
|
|
|
|
# ── Smart install function ───────────────────────────────────────────
|
|
function Install-App {
|
|
param(
|
|
[string]$Name,
|
|
[string]$WingetId,
|
|
[string]$CheckCmd = ""
|
|
)
|
|
|
|
# Check if already installed via command or winget list
|
|
$alreadyInstalled = $false
|
|
if ($CheckCmd -and (Get-Command $CheckCmd -ErrorAction SilentlyContinue)) {
|
|
$alreadyInstalled = $true
|
|
} elseif (winget list --id $WingetId 2>$null | Select-String $WingetId) {
|
|
$alreadyInstalled = $true
|
|
}
|
|
|
|
if ($alreadyInstalled) {
|
|
Write-Skip $Name
|
|
} else {
|
|
Write-Info "Installing $Name..."
|
|
winget install --id $WingetId --silent --accept-package-agreements --accept-source-agreements 2>$null
|
|
if ($LASTEXITCODE -eq 0) {
|
|
Write-Success "$Name installed"
|
|
} else {
|
|
Write-Warn "$Name failed — skipping"
|
|
}
|
|
}
|
|
}
|
|
|
|
# ── Core tools ──────────────────────────────────────────────────────
|
|
Write-Header "Core tools"
|
|
Install-App "Git" "Git.Git" "git"
|
|
Install-App "curl" "cURL.cURL" "curl"
|
|
Install-App "wget" "GnuWin32.Wget"
|
|
Install-App "7-Zip" "7zip.7zip" "7z"
|
|
Install-App "jq" "jqlang.jq" "jq"
|
|
Install-App "Neofetch" "nepnep.neofetch"
|
|
|
|
# ── Shell ────────────────────────────────────────────────────────────
|
|
Write-Header "Shell & terminal"
|
|
Install-App "Windows Terminal" "Microsoft.WindowsTerminal"
|
|
Install-App "PowerShell 7" "Microsoft.PowerShell" "pwsh"
|
|
Install-App "Oh My Posh" "JanDeDobbeleer.OhMyPosh" "oh-my-posh"
|
|
|
|
# ── Development ─────────────────────────────────────────────────────
|
|
Write-Header "Development tools"
|
|
Install-App "VS Code" "Microsoft.VisualStudioCode" "code"
|
|
Install-App "Python 3" "Python.Python.3.12" "python"
|
|
Install-App "Node.js" "OpenJS.NodeJS.LTS" "node"
|
|
Install-App "Docker Desktop" "Docker.DockerDesktop" "docker"
|
|
|
|
# ── Network & security ───────────────────────────────────────────────
|
|
Write-Header "Network tools"
|
|
Install-App "nmap" "Nmap.Nmap" "nmap"
|
|
Install-App "Wireshark" "WiresharkFoundation.Wireshark" "Wireshark"
|
|
Install-App "WinSCP" "WinSCP.WinSCP"
|
|
Install-App "PuTTY" "PuTTY.PuTTY" "putty"
|
|
|
|
# ── Samba / network drives ───────────────────────────────────────────
|
|
Write-Header "Samba network drives"
|
|
Write-Info "Configuring vanga homelab network drives..."
|
|
|
|
$SAMBA = "10.0.99.100"
|
|
$CRED = Get-Credential -Message "Enter Samba credentials for $SAMBA"
|
|
|
|
$drives = @(
|
|
@{ Letter="E"; Share="Edemilov"; Label="edemilov-user" },
|
|
@{ Letter="D"; Share="Depo"; Label="depo" },
|
|
@{ Letter="M"; Share="Family-Documents"; Label="documents" },
|
|
@{ Letter="P"; Share="Family-Photos"; Label="photos" }
|
|
)
|
|
|
|
foreach ($d in $drives) {
|
|
$unc = "\\$SAMBA\$($d.Share)"
|
|
if (Get-PSDrive -Name $d.Letter -ErrorAction SilentlyContinue) {
|
|
Write-Skip "$($d.Letter): ($unc)"
|
|
} else {
|
|
try {
|
|
New-PSDrive -Name $d.Letter -PSProvider FileSystem -Root $unc `
|
|
-Credential $CRED -Persist -ErrorAction Stop | Out-Null
|
|
Write-Success "Mapped $($d.Letter): → $unc"
|
|
} catch {
|
|
Write-Warn "Could not map $($d.Letter): — $($_.Exception.Message)"
|
|
}
|
|
}
|
|
}
|
|
|
|
# ── Done ─────────────────────────────────────────────────────────────
|
|
Write-Host ""
|
|
Write-Host "═══════════════════════════════════════════════════" -ForegroundColor Green
|
|
Write-Host " ✓ apps.ps1 complete!" -ForegroundColor Green
|
|
Write-Host "═══════════════════════════════════════════════════" -ForegroundColor Green
|
|
Write-Host ""
|
|
Write-Host " Restart PowerShell to pick up PATH changes" -ForegroundColor Yellow
|
|
Write-Host ""
|