-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.ps1
41 lines (32 loc) · 1.29 KB
/
setup.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
param(
# Name to give the new user
[string]
$UserName,
# Name to register as
[string]
$DistroName = 'Fedora',
# Install Location
[string]
$InstallDirectory = "$HOME\AppData\Local\"
)
# Determine ARM64 or x86_64
$arch = 'amd64'
if ("$env:PROCESSOR_ARCHITECTURE" -eq 'ARM64') {
$arch = 'arm64'
}
$scriptDir = Split-Path $PSCommandPath
Invoke-WebRequest -Uri "https://github.com/scaryrawr/Fedora-WSL-RootFS/releases/latest/download/rootfs.${arch}.tar.gz" -OutFile "$scriptDir\Fedora${Version}.tar.gz" -ErrorAction Stop
# Make distro folder
if (!(Test-Path "$InstallDirectory\$DistroName")) {
mkdir "$InstallDirectory\$DistroName"
}
# Import image
wsl --import "$DistroName" "$InstallDirectory\$DistroName" "$scriptDir\Fedora${Version}.tar.gz"
$nixPath = wsl -e wslpath "$scriptDir"
$language = $(Get-WinSystemLocale).Name.Split('-')[0]
# Launch to configure
wsl -d "$DistroName" "$nixPath/setup.sh" -u "'$UserName'" -l "'$language'"
# Set default user as first non-root user
Get-ItemProperty Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\*\ DistributionName | Where-Object -Property DistributionName -eq "$DistroName" | Set-ItemProperty -Name DefaultUid -Value 1000
# Terminate for launching with systemd support
wsl -t "${DistroName}"