-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61fec67
commit 83578b4
Showing
9 changed files
with
96 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
*.exe | ||
*.exe | ||
/bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Install ps2exe module if not already installed | ||
if (-not (Get-Module -Name ps2exe -ListAvailable)) { | ||
Install-Module -Name ps2exe -Scope CurrentUser -Force | ||
} | ||
|
||
# Create /bin/ subdirectory if it does not exist | ||
if (-not (Test-Path -Path ".\bin\" -PathType Container)) { | ||
New-Item -ItemType Directory -Path ".\bin\" | ||
} | ||
|
||
# Get list of .ps1 files in current directory | ||
$ps1Files = Get-ChildItem -Path . -Filter *.ps1 | ||
|
||
# Loop through each .ps1 file and convert to .exe using ps2exe | ||
foreach ($ps1File in $ps1Files) { | ||
$exeFile = ".\bin\" + $ps1File.Name.Replace(".ps1", ".exe") | ||
ps2exe -inputFile $ps1File.FullName -outputFile $exeFile | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Define variables | ||
$taskName = "WSL Distro Automatic Update" | ||
$taskDescription = "Runs wsl-dist-update.exe 10 minutes after Windows boots" | ||
$executablePath = "wsl-dist-update.exe" | ||
$arguments = "--system" | ||
|
||
# Create scheduled task | ||
$action = New-ScheduledTaskAction -Execute $executablePath -Argument $arguments | ||
$trigger = New-ScheduledTaskTrigger -AtStartup -Delay 10m | ||
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries | ||
Register-ScheduledTask -TaskName $taskName -Description $taskDescription -Action $action -Trigger $trigger -Settings $settings -RunLevel Highest -Force | ||
|
||
# Run scheduled task in the background | ||
Start-ScheduledTask -TaskName $taskName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Get list of installed WSL distros from registry | ||
$distros = Get-ChildItem "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss" | ForEach-Object { $_.GetValue("DistributionName") } | ||
|
||
# Loop through each distro and get ID_LIKE variable from /etc/os-release using wsl.exe | ||
$results = foreach ($distro in $distros) { | ||
$osReleasePath = "\\wsl$\$distro\etc\os-release" | ||
#$idLike = (wsl.exe -d $distro cat /etc/os-release | Select-String "^ID_LIKE=").ToString().Split("=")[1] | ||
$id = (wsl.exe -d $distro cat /etc/os-release | Select-String "^ID=").ToString().Split("=")[1] | ||
Write-Host "Updating $distro" | ||
switch -Wildcard ($id) { | ||
"*debian*" { | ||
wsl.exe -d $distro -u root apt-get update > $null | ||
wsl.exe -d $distro -u root apt-get upgrade -y > $null | ||
} | ||
"*ubuntu*" { | ||
wsl.exe -d $distro -u root apt-get update > $null | ||
wsl.exe -d $distro -u root apt-get upgrade -y > $null | ||
} | ||
"*fedora*" { | ||
wsl.exe -d $distro -u root dnf update -y > $null | ||
} | ||
"*rhel*" { | ||
wsl.exe -d $distro -u root dnf update -y > $null | ||
} | ||
"*suse*" { | ||
wsl.exe -d $distro -u root zypper dup -y > $null | ||
} | ||
"*arch*" { | ||
wsl.exe -d $distro -u root pacman -Syu --noconfirm > $null | ||
} | ||
} | ||
[PSCustomObject]@{ | ||
DistroName = $distro | ||
ID_LIKE = $idLike | ||
} | ||
} | ||
|
||
# Update WSL System Distro if --system flag is passed | ||
if ($args.Contains("--system")) { | ||
Write-Host "Updating WSL System Distro" | ||
wsl.exe -u root --system tdnf update -y > $null | ||
} |