Skip to content

Commit

Permalink
update wsl2 config
Browse files Browse the repository at this point in the history
  • Loading branch information
hadirgax committed Aug 25, 2024
1 parent 5e439cb commit acedf69
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
5 changes: 3 additions & 2 deletions setup_devenv/windows/.wslconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 2 additions & 6 deletions setup_devenv/windows/setup-wsl2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 \
Expand Down
18 changes: 7 additions & 11 deletions setup_devenv/windows/wsl2.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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! >>>>>"

0 comments on commit acedf69

Please sign in to comment.