Skip to content

Commit

Permalink
Updated several software package versions and fixed issues detected in
Browse files Browse the repository at this point in the history
  • Loading branch information
kaisalmen committed Sep 28, 2021
1 parent 23089ed commit 331e410
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 24 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
*.sh text eol=lf
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog

## 2021-09-28
- Fixed Issue #1: Staging area is now created if it does not exist
- Fixed Issue #2: Updated [README.md](./README.md) and updated default wsl.conf
- Updated docker-compose from `1.28.4` to `2.0.0`. Command is now `docker compose` instead of `docker-compose`
- Updated Gradle from `6.8.3`to `7.2`
- Updated Apache Maven to from `3.6.3` to `3.8.2`
- n install the latest nodejs version instead of lts version
- All other software packages are installed with the latest version
- Added [.gitattributes](.gitattributes) config to ensure sh files stay with lf line ending
- Introduced this changelog
27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,44 @@
Automated creation of WSL 2 Development Machine
===

Welcome to the WSL Tooling repository. The aim of this project is to supply with the ability to autpmatically install a fully working WSL 2 development environment just by invoking a powershell script even without the `wsl --install` flag.
Welcome to the WSL Tooling repository. The aim of this project is to supply you with the ability to automatically install a fully working WSL 2 development environment just by invoking a powershell script even without the `wsl --install` flag.

I have fully reworked and updated the whole installation. Once your Windows is capabale of running WSL 2 instances, the Ubuntu LTS WSL 2 installation is fully automatic.
I have fully reworked and updated the whole installation. Once your Windows is capable of running WSL 2 instances, the Ubuntu LTS WSL 2 installation is fully automatic.


## Preparation
This repository must be clone on your local disk.
This repository must be cloned on your local disk.

### Enable Windows Subsystem for Linux V2 support
### Enable Windows Subsystem for Linux
***This step is only required if WSL support was never activated before on your Windows machine***

Open a powershell with administrative privileges and execute:
Run the script to enable WSL and VM paltform on your machine
Open a powershell with **administrative** privileges and execute this script to enable WSL and VM platform on your machine.
It might be necessary to adjust the security policy (see first commnd below) because the Powershell scripts are not digitally signed (https:/go.microsoft.com/fwlink/?LinkID=135170):
```powershell
# Optional: Set Security to Bypass
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
# Enable WSL
.\enableWSL.ps1
```
This will take a couple of minutes. If it was not enabled before, you need to reboot Windows.

A restart is required if any of the two above features have not been installed before.

### Set WSL default version to 2

Set the default WSL version to 2. Open a powershell with administrative privileges:
```powershell
.\installWSL2.ps1
```

## Installation
## Distribution Installation

### Download and Install Ubuntu LTS (20.04)
If not already done, open a new powershell with administrative privileges and install Ubuntu LTS. You **need** to provide four arguments. If you don't specify them on command line, then the script will ask:
- `<wslName>`: Provide a name for the WSL that is goind to be created (e.g. `devbox`)
- `<wslInstallationPath>`: The directory where the vhdx disk of the new WSL is stored
- `<username>`: the name of the user that is used when WSL distro is launched without `-u`
- `<installAllSoftware>`: Tell if all software packages (see [Available Software](#Available-Software)) shall be installed or if `false` only a fully updated system with configured user is supplied
- `<installAllSoftware>`: Use `true`|`false`. Tell if all software packages (see [Available Software](#Available-Software)) shall be installed or if `false` only a fully updated system with configured user is supplied
For example, the command can look as follows:
```powershell
installUbuntuLTS.ps1 devbox D:\WSL2\devbox kai true
Expand All @@ -42,7 +47,7 @@ installUbuntuLTS.ps1 devbox D:\WSL2\devbox kai true
### Available Software Package
If don't want to install all packages during initial WSL creation, you can install them one buy one. They are available here [./scripts](./scripts). These are currently available
- Ubunut Base Package (git, virt-manager, firefox, dbus-x11, x11-apps, make, unzip) ([scripts/install/installBasePackage.sh](./scripts/install/installBasePackage.sh))
- docker &docker-compose ([scripts/install/installDocker.sh](./scripts/install/installDocker.sh))
- docker & compose V2 ([scripts/install/installDocker.sh](./scripts/install/installDocker.sh))
- OpenJDK 11 ([scripts/install/installOpenjdk.sh](scripts/install/installOpenjdk.sh))
- Apache Maven ([scripts/install/installMaven.sh](./scripts/install/installMaven.sh))
- Gradle ([scripts/install/installGradle.sh](./scripts/install/installGradle.sh))
Expand All @@ -55,12 +60,14 @@ If don't want to install all packages during initial WSL creation, you can insta
Firefox and other tools can be installed directly with Ubuntu's package manager `apt`. Some of the above scripts also use `apt` and apply additional configuration.

#### Removal
Not available yet, but with fast a internet connection and fast SSD you have the WSL recreated in approx. five minutes. :sunglasses:
Not available yet, but with a fast internet connection and fast SSD you have the WSL recreated in approx. five minutes. :sunglasses:


## Usage

### X-Server
***Once Windows 11 including WSLg is generally available this will become superfluous.***

I recommend to use [VcXsrv](https://sourceforge.net/projects/vcxsrv/) (also available via chocolatey) to connect to user interfaces launched from WSL on display 0. The WSL linux setup configures everything properly. Use the following Powershell script to launch (it assume vcxsrv is installed at default location `C:\Program Files\VcXsrv\vcxsrv.exe`):
```powershell
.\scripts\xserver\xerver.ps1
Expand Down
8 changes: 4 additions & 4 deletions installUbuntuLTS.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ Remove-Item .\staging\$wslName.zip
Remove-Item -r .\staging\$wslName\

# Update the system
wsl -d $wslName -u root -- apt update`; apt upgrade -y
wsl -d $wslName -u root bash -ic "apt update; apt upgrade -y"

# create your user and add it to sudoers
wsl -d $wslName -u root -e scripts/config/system/createUser.sh $username
wsl -d $wslName -u root bash -ic "./scripts/config/system/createUser.sh $username"

# ensure WSL Distro is restarted when first used with user account
wsl -t $wslName

if ($installAllSoftware -ieq $true) {
wsl -d $wslName -u root -- ./scripts/install/installBasePackages.sh
wsl -d $wslName -u $username -- ./scripts/install/installAllSoftware.sh
wsl -d $wslName -u root bash -ic ./scripts/install/installBasePackages.sh
wsl -d $wslName -u $username bash -ic ./scripts/install/installAllSoftware.sh
}
5 changes: 4 additions & 1 deletion scripts/config/system/wsl.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Enable extra metadata options by default
[automount]
enabled = true
mountFsTab = true
root = /mnt
options="metadata,umask=22,fmask=11"
mountFsTab = false

[Interop]
appendWindowsPath = False
9 changes: 6 additions & 3 deletions scripts/install/installDocker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubun
sudo apt update
sudo apt install -y --no-install-recommends docker-ce

VERSION_DOCKER_COMPOSE="1.28.4"
sudo curl -fSL "https://github.com/docker/compose/releases/download/${VERSION_DOCKER_COMPOSE}/docker-compose-Linux-x86_64" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
VERSION_DOCKER_COMPOSE="2.0.0"
if [[ ! -d ~/.docker/cli-plugins ]]; then
mkdir -p ~/.docker/cli-plugins
fi
curl -fSL https://github.com/docker/compose/releases/download/v2.0.0/docker-compose-linux-amd64 -o ~/.docker/cli-plugins/docker-compose
chmod +x ~/.docker/cli-plugins/docker-compose
2 changes: 1 addition & 1 deletion scripts/install/installGradle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -euo pipefail
DIR_ME=$(realpath $(dirname $0))
VERSION_GRADLE="6.8.3"
VERSION_GRADLE="7.2"

# This script is called by any user. It shall succeed without a username parameter
. ${DIR_ME}/.installUtils.sh
Expand Down
6 changes: 3 additions & 3 deletions scripts/install/installMaven.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -euo pipefail
DIR_ME=$(realpath $(dirname $0))
VERSION_MAVEN="3.6.3"
VERSION_MAVEN="3.8.2"

# This script is called by any user. It shall succeed without a username parameter
. ${DIR_ME}/.installUtils.sh
Expand All @@ -14,7 +14,7 @@ if [[ -d /usr/share/maven ]]; then
fi

if [[ $(which mvn | wc -l) == 0 ]]; then

sudo mkdir -p /usr/lib/maven

# download & unpack
Expand All @@ -31,7 +31,7 @@ if [[ $(which mvn | wc -l) == 0 ]]; then
# only use windows m2 if told to do so
if [[ ${USE_WIN_M2} == "--useWinM2" ]]; then

if [[ ! -z ${WINDOWS_USER_HOME} ]]; then
if [[ -n ${WINDOWS_USER_HOME} ]]; then

if [[ -f ${WINDOWS_USER_HOME}/.m2/settings.xml ]]; then
cp -f ${WINDOWS_USER_HOME}/.m2/settings.xml ${HOMEDIR}/.m2
Expand Down
5 changes: 4 additions & 1 deletion scripts/install/installNodejs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ setUserName ${1-"$(whoami)"}

if [[ $(which n | wc -l) == 0 ]]; then
sudo apt install -y make
cp ${HOMEDIR}/.bashrc ${HOMEDIR}/.bashrc.bak
cp ${HOMEDIR}/.bashrc ${HOMEDIR}/.bashrc.bak
curl -L https://git.io/n-install | bash -s -- -y
mv ${HOMEDIR}/.bashrc.bak ${HOMEDIR}/.bashrc
else
Expand All @@ -22,6 +22,9 @@ modifyBashrc "configureN.sh" ". ${HOMEDIR}/.local/bin/env/configureN.sh"
# source the script, so the following installation can proceed
. ${HOMEDIR}/.local/bin/env/configureN.sh

# Ensure latest node version is installed
n latest

if [[ $(which tsc | wc -l) == 0 ]]; then
npm install -g typescript
tsc -version
Expand Down
2 changes: 1 addition & 1 deletion scripts/report/listVersions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ echo -e "\n\nListing software versions:"

echo -e "\ndocker:"
docker --version
docker-compose --version
docker --help | grep compose

echo -e "\njava:"
java --version
Expand Down

0 comments on commit 331e410

Please sign in to comment.