From acedf69ff93278a47226220f4b7b18ab6bd5eb77 Mon Sep 17 00:00:00 2001 From: Hadir Garcia Date: Sun, 25 Aug 2024 08:11:24 -0300 Subject: [PATCH] update wsl2 config --- setup_devenv/windows/.wslconfig | 5 +++-- setup_devenv/windows/setup-wsl2.sh | 8 ++------ setup_devenv/windows/wsl2.ps1 | 18 +++++++----------- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/setup_devenv/windows/.wslconfig b/setup_devenv/windows/.wslconfig index d845aea..5631c6b 100644 --- a/setup_devenv/windows/.wslconfig +++ b/setup_devenv/windows/.wslconfig @@ -2,14 +2,15 @@ memory=6GB -processors=2 +processors=4 swap=2GB +# Boolean to turn on or off nested virtualization, enabling other nested VMs to run inside WSL 2. Only available for Windows 11. nestedVirtualization=false # Disable page reporting so WSL retains all allocated memory claimed from Windows and releases none back when free -pageReporting=false +# pageReporting=true # Turn off default connection to bind WSL 2 localhost to Windows localhost # Boolean specifying if ports bound to wildcard or localhost in the WSL 2 VM should be connectable from the host via localhost:port. diff --git a/setup_devenv/windows/setup-wsl2.sh b/setup_devenv/windows/setup-wsl2.sh index 615167e..942d88b 100644 --- a/setup_devenv/windows/setup-wsl2.sh +++ b/setup_devenv/windows/setup-wsl2.sh @@ -3,9 +3,6 @@ set -e # exit on error set -x # debug trace mode -FEATURE_DIR=${FEATURE_DIR} -BACKUP_FILE=${BACKUP_FILE} - function main { # if wsl need to chenge nameserver in file /etc/resolv.conf then uncomment this: # set_nameserver @@ -29,7 +26,6 @@ function update_and_install { echo;echo ">>>>> Installing Latest Version of GIT... >>>>>" install_git echo ">>>>> Testing git installation... >>>>>" - git --version echo;echo ">>>>> Configuring oh-my-zsh repository... >>>>>" configuring_oh_my_zsh @@ -93,16 +89,16 @@ function install_git { sudo rm -rf /var/lib/apt/lists/* git --version # This configuration ensures that line endings in Git repositories are normalized to LF (Unix-style) endings, - git config --global core.autocrlf input + # git config --global core.autocrlf input } function configuring_oh_my_zsh() { # Adapted, simplified inline Oh My Zsh! install steps that adds, defaults to a codespaces theme. # See https://github.com/ohmyzsh/ohmyzsh/blob/master/tools/install.sh for official script. + echo ">>>>> Inside if statement oh-my-zsh configuration... >>>>>" && \ cd ${HOME} && \ OMZ_DIR="${HOME}/.oh-my-zsh" && \ - echo ">>>>> Inside if statement oh-my-zsh configuration... >>>>>" && \ umask g-w,o-w && \ mkdir -p ${OMZ_DIR} && \ git clone --depth=1 \ diff --git a/setup_devenv/windows/wsl2.ps1 b/setup_devenv/windows/wsl2.ps1 index dcddcbb..dd09563 100644 --- a/setup_devenv/windows/wsl2.ps1 +++ b/setup_devenv/windows/wsl2.ps1 @@ -7,7 +7,10 @@ wsl.exe -s $WSL_DISTRO # VARIABLES $DEVOPS_DIR="${env:UserProfile}\workspace\devops" $FEATURE_WIN_DIR="$DEVOPS_DIR\setup_devenv\windows" -$SETUP_WIN_PATH="$FEATURE_WIN_DIR\setup-wsl2.sh" +$SETUP_FILE="setup-wsl2.sh" +$SETUP_WIN_PATH="$FEATURE_WIN_DIR\$SETUP_FILE" +$FEATURE_WSL_DIR = $FEATURE_WIN_DIR -replace '\\', '/' -replace 'C:', '/mnt/c' +$SETUP_WSL_PATH = $SETUP_WIN_PATH -replace '\\', '/' -replace 'C:', '/mnt/c' # Provide a date to be restored, in the format "yyyyMMdd-HHmmss" # $BACKUP_FILE="20230211-193753_wsl_backup.tar.gz" @@ -17,16 +20,9 @@ $SETUP_WIN_PATH="$FEATURE_WIN_DIR\setup-wsl2.sh" # Write-Output "`n>>>>> Transfering the Backup File from GDrive... >>>>>" # Copy-Item -Path $BACKUP_ORIGIN -Destination $BACKUP_DESTINATION -$FEATURE_WSL_DIR = $FEATURE_WIN_DIR -replace '\\', '/' -replace 'C:', '/mnt/c' -$FEATURE_WSL_DIR - -$SETUP_WSL_PATH = $SETUP_WIN_PATH -replace '\\', '/' -replace 'C:', '/mnt/c' -$SETUP_WSL_PATH - # Write-Output "`n>>> Configuring a new WSL setup..." -# wsl.exe -d $WSL_DISTRO -e bash -c "sed -i -e 's/\r$//' $SETUP_WSL_PATH" -wsl.exe -d $WSL_DISTRO -e bash -c "sudo chmod +x $SETUP_WSL_PATH" -wsl.exe -d $WSL_DISTRO -e bash -c "FEATURE_DIR=$FEATURE_WSL_DIR $SETUP_WSL_PATH main" - # BACKUP_FILE=$BACKUP_FILE \ +cp -Force $SETUP_WIN_PATH \\wsl.localhost\Ubuntu\tmp +wsl.exe -d $WSL_DISTRO -e bash -c "sed -i -e 's/\r$//' /tmp/$SETUP_FILE" +wsl.exe -d $WSL_DISTRO -e bash -c "sudo chmod +x /tmp/$SETUP_FILE" Write-Output "`n>>>>> Done! >>>>>"