User Tools

Site Tools


userspace:windows-subsystem-for-linux

This Script installes the Windows Subsystem for Linux and any linux distribution.

You need the “reboot control” function included in your WINST / OPSI-Script.

  1. Download the needed Distributions –> https://docs.microsoft.com/de-de/windows/wsl/install-manual

Tree:

CLIENT_DATA
  ├── files
│   ├── wsl-debian-gnulinux.appx
│   ├── wsl-kalilinux-1140.appx
│   ├── wsl-opensuse-42.appx
│   ├── wsl-sles-12.appx
│   ├── wsl-ubuntu-1604.appx
│   └── wsl-ubuntu-1804.appx
├── Microsoft-WSL.png
└── setup.opsiscript
[Actions]
importlib "fhg_rebootcontrol.opsiinc"
requiredWinstVersion >= "4.11.4.6"
ScriptErrorMessages=off


DefVar $MsiId$
DefVar $UninstallProgram$
DefVar $LogDir$
DefVar $ProductId$  
DefVar $MinimumSpace$
DefVar $rebootCounter$
DefVar $rebooted$

DefVar $distribution$

Set $LogDir$ = "%opsiLogDir%"

Message "init reboot counter"
set $rebooted$ = rebootcontrol("auto","read")

; ----------------------------------------------------------------
; - Please edit the following values                             -
; ----------------------------------------------------------------
;$ProductId$ should be the name of the product in opsi
; therefore please: only lower letters, no umlauts, 
; no white space use '-' as a seperator
Set $ProductId$       = "Microsoft-WSL"
Set $MinimumSpace$    = "5000 MB"
; the path were we find the product after the installation
; ----------------------------------------------------------------

if not(HasMinimumSpace ("%SystemDrive%", $MinimumSpace$))
	LogError "Not enough space on %SystemDrive%, " + $MinimumSpace$ + " on drive %SystemDrive% needed for " + $ProductId$
	isFatalError "No Space"
	; Stop process and set installation status to failed
else
	comment "Show product picture"
	ShowBitmap "%ScriptPath%\" + $ProductId$ + ".png" $ProductId$
	
	comment "get property value ....."
	set $distribution$ = getProductProperty("distribution", "wsl-ubuntu-1804")
	
	
	Message "Installing " + $ProductId$ + " ..."
	comment "Start setup program"
	ChangeDirectory "%SCRIPTPATH%"

	if $rebooted$ <= "0" 
		powershellCall('Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -NoRestart')
		set $rebootCounter$ = rebootcontrol("auto","write")
		ExitWindows /ImmediateReboot
	else
		message "WSL is enabled"
		message "install Distribution"
		powershellCall('Add-AppxProvisionedPackage -SkipLicense -Online -PackagePath %scriptpath%\files\'+$distribution$)

		set $rebootCounter$ = rebootcontrol("auto","delete")
	endif
			

endif
[Package]
version: 1
depends: 
incremental: False

[Product]
type: localboot
id: Microsoft-WSL
name: Windows Subsystem for Linux
description: A template for opsi products
advice: 
version: 4.0.6
priority: 0
licenseRequired: False
productClasses: 
setupScript: setup.opsiscript
uninstallScript:
updateScript: 
alwaysScript: 
onceScript: 
customScript: 
userLoginScript: 

[ProductProperty]
type: unicode
name: Distribution
multivalue: False
editable: True
description: Select Distribution
values: ["wsl-ubuntu-1804.appx","wsl-debian-gnulinux.appx","wsl-ubuntu-1604.appx","wsl-kalilinux-1140.appx","wsl-sles-12.appx","wsl-opensuse-42.appx"]
default: ["wsl-ubuntu-1804.appx"]

userspace/windows-subsystem-for-linux.txt · Last modified: 2021/08/23 08:37 (external edit)