From 59385cd30d1022cb20fdec286fc46cbf1cfdaa6e Mon Sep 17 00:00:00 2001 From: Finn Kumkar Date: Wed, 17 Jan 2024 13:51:06 +0100 Subject: [PATCH] Add support for the latest stable Debian version --- CHANGELOG.md | 8 +++++- README.md | 24 ++++++++++------ provisioning/tasks/add_configuration.sh | 1 - provisioning/tasks/bootstrap.sh | 8 +++--- provisioning/tasks/install_packages.sh | 28 +++++++++---------- provisioning/tasks/upgrade_distribution.sh | 32 +++++++++++----------- 6 files changed, 56 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7779aed..f02702f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 diff --git a/README.md b/README.md index 6fd02ee..1bdaa0b 100644 --- a/README.md +++ b/README.md @@ -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 git@github.com:countzero/wsl_debian.git C:\wsl_debian @@ -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 @@ -67,7 +72,7 @@ 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. @@ -75,9 +80,9 @@ Please read the following ressources for up to date hints on what is causing the - 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 @@ -85,4 +90,5 @@ VirtualBox 6.1 is still too slow to be usable with Hyper-V. Therefore currently 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. diff --git a/provisioning/tasks/add_configuration.sh b/provisioning/tasks/add_configuration.sh index ed8f1b8..2d6df25 100644 --- a/provisioning/tasks/add_configuration.sh +++ b/provisioning/tasks/add_configuration.sh @@ -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 diff --git a/provisioning/tasks/bootstrap.sh b/provisioning/tasks/bootstrap.sh index e316865..09d0e9b 100644 --- a/provisioning/tasks/bootstrap.sh +++ b/provisioning/tasks/bootstrap.sh @@ -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 @@ -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 diff --git a/provisioning/tasks/install_packages.sh b/provisioning/tasks/install_packages.sh index 9139652..39d514d 100644 --- a/provisioning/tasks/install_packages.sh +++ b/provisioning/tasks/install_packages.sh @@ -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 diff --git a/provisioning/tasks/upgrade_distribution.sh b/provisioning/tasks/upgrade_distribution.sh index 4e7c101..282b2d4 100644 --- a/provisioning/tasks/upgrade_distribution.sh +++ b/provisioning/tasks/upgrade_distribution.sh @@ -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."