@@ -8,10 +8,11 @@ Add-AppxPackage -Path ~/Ubuntu.appx
8
8
9
9
RefreshEnv
10
10
11
+ $distro = " ubuntu1804"
11
12
$username = " ubuntu"
12
13
$password = " ubuntu"
13
14
14
- Ubuntu1804 install -- root
15
+ & $distro install -- root
15
16
if ($LASTEXITCODE -ne 0 ) { throw " Could not install distro." }
16
17
17
18
# the only non-interactive way to set up a WSL distro is the --root flag
@@ -21,16 +22,13 @@ if ($LASTEXITCODE -ne 0) { throw "Could not install distro." }
21
22
# Workaround this by installing with --root but then replicating,
22
23
# noninteractively, what happens in the WSL DistroLauncher:
23
24
# https://github.com/microsoft/WSL-DistroLauncher/blob/2ed9a9335fc89a688a5150c95eff4fbdbc830f25/DistroLauncher/DistributionInfo.cpp#L8-L33
24
- wsl - d Ubuntu - 18.04 - u root useradd - m " $username "
25
+ & $distro run useradd - m " $username "
25
26
if ($LASTEXITCODE -ne 0 ) { throw }
26
- wsl - d Ubuntu - 18.04 - u root sh - c ' echo "${username}:${password}" | chpasswd' # wrapped in sh -c to get the pipe to work
27
+ & $distro run sh - c ' echo "${username}:${password}" | chpasswd' # wrapped in sh -c to get the pipe to work
27
28
if ($LASTEXITCODE -ne 0 ) { throw }
28
- wsl - d Ubuntu - 18.04 - u root chsh - s / bin/ bash " $username "
29
+ & $distro run chsh - s / bin/ bash " $username "
29
30
if ($LASTEXITCODE -ne 0 ) { throw }
30
- wsl - d Ubuntu- 18.04 - u root usermod - aG adm, cdrom, sudo, dip, plugdev " $username "
31
- if ($LASTEXITCODE -ne 0 ) { throw }
32
-
33
- Ubuntu1804 config -- default- user " $username "
31
+ & $distro run usermod - aG adm, cdrom, sudo, dip, plugdev " $username "
34
32
if ($LASTEXITCODE -ne 0 ) { throw }
35
33
36
34
@@ -39,15 +37,18 @@ $env:DEBIAN_FRONTEND = "noninteractive"
39
37
$env: WSLENV += " :DEBIAN_FRONTEND"
40
38
41
39
# update software
42
- wsl - d Ubuntu - 18.04 - u root apt- get update
40
+ & $distro run apt- get update
43
41
if ($LASTEXITCODE -ne 0 ) { throw }
44
- wsl - d Ubuntu - 18.04 - u root apt- get full- upgrade - y
42
+ & $distro run apt- get full- upgrade - y
45
43
if ($LASTEXITCODE -ne 0 ) { throw }
46
- wsl - d Ubuntu - 18.04 - u root apt- get autoremove - y
44
+ & $distro run apt- get autoremove - y
47
45
if ($LASTEXITCODE -ne 0 ) { throw }
48
- wsl - d Ubuntu - 18.04 - u root apt- get autoclean
46
+ & $distro run apt- get autoclean
49
47
if ($LASTEXITCODE -ne 0 ) { throw }
50
- wsl -- shutdown # instead of 'reboot'
48
+ wsl -- terminate " Ubuntu-18.04" # instead of 'reboot'
49
+ if ($LASTEXITCODE -ne 0 ) { throw }
50
+
51
+ & $distro config -- default- user " $username "
51
52
if ($LASTEXITCODE -ne 0 ) { throw }
52
53
53
54
<#
0 commit comments