Skip to content

Commit

Permalink
Add support for the latest stable Debian version
Browse files Browse the repository at this point in the history
  • Loading branch information
countzero committed Jan 17, 2024
1 parent 031c75e commit 59385cd
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 45 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.1.0] - 2024-01-17

### Added

- [Debian] Add support for the latest stable Debian version
- [Debian] Add installation of mongodb-database-tools

## [2.0.0] - 2022-07-12

### Added
Expand All @@ -19,7 +26,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [WSL] Change default WSL version to 2
- [WSL] Simplified initial installation of WSL2


## [1.0.0] - 2020-03-09

### Added
Expand Down
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The following tasks have been automated:

### 1. Clone this repository

Clone the *wsl_debian* repository to a nice place on your machine via:
Clone the *wsl_debian* repository to a specific place on your machine via:

```PowerShell
git clone [email protected]:countzero/wsl_debian.git C:\wsl_debian
Expand All @@ -34,16 +34,21 @@ powershell.exe -NoProfile -ExecutionPolicy Bypass -File "C:\wsl_debian\provision

Define a UNIX username and password upon the first start of the `debian` process.

**Hint:** The installation script has launched the `debian` process automatically for you.
> [!NOTE]
> The installation script has launched the `debian` process automatically for you.
### 4. Provision the Debian installation

Execute the [`provisioning/provision_wsl_debian.sh`](https://github.com/countzero/wsl_debian/blob/master/provisioning/provision_wsl_debian.sh) Bash script as the `root` user within the `debian` app:
Execute the [`provisioning/provision_wsl_debian.sh`](https://github.com/countzero/wsl_debian/blob/master/provisioning/provision_wsl_debian.sh) Bash script as the `root` user within the `debian` distribution:

```Bash
sudo su - -c /mnt/c/wsl_debian/provisioning/provision_wsl_debian.sh
```PowerShell
wsl.exe --distribution debian --user root /mnt/c/wsl_debian/provisioning/provision_wsl_debian.sh
```

> [!IMPORTANT]
> Do _not_ use `sudo` within Debian to become `root` because that will cause the distribution
> upgrade to fail: https://github.com/microsoft/WSL/issues/4279#issuecomment-1846822075
## Uninstall (optional)

### Uninstall the Debian App
Expand All @@ -67,22 +72,23 @@ dism.exe /online `

## Troubleshooting

### WSL2 is not working
### WSL 2 is not working

Please read the following ressources for up to date hints on what is causing the issue.

- https://docs.microsoft.com/en-us/windows/wsl/troubleshooting
- https://github.com/microsoft/WSL/issues/4930
- https://www.spacedesk.net/de/forums/topic/wsl2-not-starting-after-spacedesk-installation/

### WSL2 breaks VirtualBox 6.1
### WSL 2 breaks VirtualBox

VirtualBox 6.1 is still too slow to be usable with Hyper-V. Therefore currently you have to switch between WSL2 or VirtualBox development.
VirtualBox is still too slow to be usable with Hyper-V. Therefore currently you have to switch between WSL 2 or VirtualBox development.

- https://github.com/MicrosoftDocs/WSL/issues/798

#### Enable/Disable Hyper-V

Execute the `./tools/enable_hyper_v.ps1` or `./tools/disable_hyper_v.ps1` PowerShell scripts to quickly toggle the availability of Hyper-V.

**Caution:** That scripts will automatically restart your machine.
> [!WARNING]
> That scripts will automatically restart your machine.
1 change: 0 additions & 1 deletion provisioning/tasks/add_configuration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ set -e
# Make sure this script is executed by a superuser account.
if [[ $(id -u) -ne 0 ]] ; then
echo "This script must be executed by a superuser account (UID=0), aborting!"

exit 1
fi

Expand Down
8 changes: 4 additions & 4 deletions provisioning/tasks/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ set -e
# Make sure this script is executed by a superuser account.
if [[ $(id -u) -ne 0 ]] ; then
echo "This script must be executed by a superuser account (UID=0), aborting!"

exit 1
fi

Expand All @@ -16,6 +15,7 @@ export DEBIAN_FRONTEND=noninteractive

apt-get update --allow-releaseinfo-change

apt-get --yes \
install wget \
gpg
apt-get --yes install \
curl \
wget \
gpg
28 changes: 14 additions & 14 deletions provisioning/tasks/install_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@ set -e
# Make sure this script is executed by a superuser account.
if [[ $(id -u) -ne 0 ]] ; then
echo "This script must be executed by a superuser account (UID=0), aborting!"

exit 1
fi

echo "Installing packages..."

# We are using the official MongoDB repository to get the latest version of monogsh.
wget -qO- "https://www.mongodb.org/static/pgp/server-5.0.asc" | \
wget -qO- https://www.mongodb.org/static/pgp/server-7.0.asc | \
gpg --batch --yes --dearmor -o /usr/share/keyrings/mongodb-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] http://repo.mongodb.org/apt/debian buster/mongodb-org/5.0 main" > /etc/apt/sources.list.d/mongodb.list
echo "deb [signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] http://repo.mongodb.org/apt/debian $(. /etc/os-release; echo $VERSION_CODENAME)/mongodb-org/7.0 main" > /etc/apt/sources.list.d/mongodb.list

export DEBIAN_FRONTEND=noninteractive

apt-get update --allow-releaseinfo-change

apt-get --yes \
install python3 \
python3-pip \
curl \
htop \
mongodb-mongosh \
openssh-client \
postgresql-client \
software-properties-common

pip3 install ansible
apt-get --yes install \
curl \
htop \
mongodb-mongosh \
mongodb-database-tools \
openssh-client \
postgresql-client \
python3 \
python3-pip \
software-properties-common

pip3 install ansible --break-system-packages
32 changes: 16 additions & 16 deletions provisioning/tasks/upgrade_distribution.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,35 @@ fi
#
# Automatically upgrades the current distribution.
#
# https://debian-handbook.info/browse/stable/sect.automatic-upgrades.html
#
upgrade_current_distribution () {
echo "Upgrading Debian $(cat /etc/debian_version)..."

echo "Upgrading current Debian distribition $(cat /etc/debian_version)..."

export DEBIAN_FRONTEND=noninteractive

apt-get update --allow-releaseinfo-change
apt-get --allow-releaseinfo-change update

apt-get --yes \
--option Dpkg::Options::="--force-confdef" \
--option Dpkg::Options::="--force-confold" \
dist-upgrade
apt-get --yes full-upgrade

apt-get --yes autoremove
}

upgrade_current_distribution
STABLE_CODENAME=$(curl -s https://ftp.debian.org/debian/dists/stable/Release | grep -oP '(?<=Codename:\s)\S+')
STABLE_VERSION=$(curl -s https://ftp.debian.org/debian/dists/stable/Release | grep -oP '(?<=Version:\s)\S+')

# We are importing the current Debian version details.
. /etc/os-release
echo "Upgrading Debian to the latest stable ${STABLE_VERSION} (${STABLE_CODENAME})."

echo "Switching '/etc/apt/sources.list' to Debian $VERSION_CODENAME..."
upgrade_current_distribution

echo "Switching '/etc/apt/sources.list' to Debian $STABLE_CODENAME..."

cat << EOF > /etc/apt/sources.list
deb http://deb.debian.org/debian $VERSION_CODENAME main
deb http://deb.debian.org/debian $VERSION_CODENAME-updates main
deb http://security.debian.org/debian-security $VERSION_CODENAME-security main
deb http://ftp.debian.org/debian $VERSION_CODENAME-backports main
deb http://deb.debian.org/debian $STABLE_CODENAME main
deb http://deb.debian.org/debian $STABLE_CODENAME-updates main
deb http://security.debian.org/debian-security $STABLE_CODENAME-security main
deb http://ftp.debian.org/debian $STABLE_CODENAME-backports main
EOF

upgrade_current_distribution

echo "Sucessfully upgraded to the latest stable Debian $(. /etc/os-release; echo $VERSION) distribution."

0 comments on commit 59385cd

Please sign in to comment.