Skip to content

Instantly share code, notes, and snippets.

@raitonoberu
Created July 22, 2025 08:15
Show Gist options
  • Select an option

  • Save raitonoberu/79d9f896e4664d25f696ff2beef97db4 to your computer and use it in GitHub Desktop.

Select an option

Save raitonoberu/79d9f896e4664d25f696ff2beef97db4 to your computer and use it in GitHub Desktop.

(powershell)

  1. Install WSL2
wsl --install archlinux -n
  1. Run script. Enter password when prompted
wsl -- bash -c "curl https://gist.githubusercontent.com/raitonoberu/79d9f896e4664d25f696ff2beef97db4/raw/wsl.sh -o /tmp/wsl.sh && bash /tmp/wsl.sh $Env:UserName"
  1. Restart to apply configuration
wsl --shutdown
wsl
#!/usr/bin/env bash
set -e
[ -z "$1" ] && exit 1
USERNAME="$1"
echo "### Creating user $USERNAME ###"
useradd -m $USERNAME
passwd $USERNAME
printf "[user]\ndefault=%s\n" $USERNAME >> /etc/wsl.conf
echo "$USERNAME ALL=(ALL) ALL" > "/etc/sudoers.d/00_${USERNAME//./}"
echo "### Updating system & installing packages ###"
pacman -Syu --noconfirm git openssh nano sudo wget unzip less vault
echo "### Installing dotnet ###"
wget -q https://dot.net/v1/dotnet-install.sh -O /tmp/dotnet-install.sh
sudo -u $USERNAME bash /tmp/dotnet-install.sh --channel 8.0
sudo -u $USERNAME bash /tmp/dotnet-install.sh --channel 9.0
echo "export DOTNET_ROOT=\$HOME/.dotnet" >> /home/$USERNAME/.bash_profile
echo "export PATH=\$PATH:\$DOTNET_ROOT:\$DOTNET_ROOT/tools" >> /home/$USERNAME/.bash_profile
echo "### Installing cement ###"
wget -q https://cement.skbkontur.ru/api/v1/channels/release/runtimes/linux-x64/releases/latest/download -O /tmp/cement.zip
unzip -q /tmp/cement.zip -d /tmp/cement
sudo -u $USERNAME bash /tmp/cement/dotnet/linux-x64/install.sh
echo "export PATH=\$PATH:\$HOME/bin:\$HOME/bin/dotnet" >> /home/$USERNAME/.bash_profile
echo "### Copying host configuration ###"
sudo -iu $USERNAME bash << EOF || true
ln -s /mnt/c/Users/$USERNAME/.vault-token ~
ln -s /mnt/c/Users/$USERNAME/.houston-token ~
cp /mnt/c/Users/$USERNAME/.gitconfig ~
cp -r /mnt/c/Users/$USERNAME/.ssh ~
chmod 600 ~/.ssh/id_rsa
EOF
echo "### Configuring environment ###"
echo "export DOTNET_ROLL_FORWARD=Major" >> /home/$USERNAME/.bash_profile
echo "export VAULT_ADDR=https://vault.kontur.host" >> /home/$USERNAME/.bash_profile
printf "[interop]\nenabled=false\nappendWindowsPath=false\n" >> /etc/wsl.conf
echo "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment