Skip to content

Commit

Permalink
Add first run script
Browse files Browse the repository at this point in the history
  • Loading branch information
yuk7 authored and sileshn committed Feb 12, 2022
1 parent a5c74ff commit 83f9a2f
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ rootfs: base.tar
mkdir rootfs
sudo bsdtar -zxpf base.tar -C rootfs
@echo "# This file was automatically generated by WSL. To stop automatic generation of this file, remove this line." | sudo tee rootfs/etc/resolv.conf > /dev/null
sudo cp bash_profile rootfs/root/.bash_profile
sudo chmod +x rootfs

base.tar:
@echo -e '\e[1;31mExporting base.tar using docker...\e[m'
docker run --net=host --name mintwsl linuxmintd/mint20.3-amd64 /bin/bash -c "echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections; apt-get update; apt-get full-upgrade -y -q; apt-get install -y -q apt-transport-https apt-utils aria2 bash-completion build-essential ca-certificates curl dialog htop iputils-ping software-properties-common tree; touch /etc/wsl.conf; echo '[automount]' | tee -a /etc/wsl.conf > /dev/null; echo >> /etc/wsl.conf; echo '[network]' | tee -a /etc/wsl.conf > /dev/null; echo >> /etc/wsl.conf; echo '[interop]' | tee -a /etc/wsl.conf > /dev/null; echo >> /etc/wsl.conf; echo '[user]' | tee -a /etc/wsl.conf > /dev/null; echo >> /etc/wsl.conf; echo '#The Boot setting is only available on Windows 11' | tee -a /etc/wsl.conf > /dev/null; echo '[boot]' | tee -a /etc/wsl.conf > /dev/null; unminimize; apt-get autoremove -y; apt-get clean;"
docker run --net=host --name mintwsl linuxmintd/mint20.3-amd64 /bin/bash -c "echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections; apt-get update; apt-get full-upgrade -y -q; apt-get install -y -q apt-transport-https apt-utils aria2 bash-completion build-essential ca-certificates curl dialog figlet htop iputils-ping software-properties-common tree; unminimize; apt-get autoremove -y; apt-get clean;"
docker export --output=base.tar mintwsl
docker rm -f mintwsl

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Usage :

## How to setup

Open Mint.exe and run the following commands.
LinuxmintWSL will ask you to create a new user during its first run. If you chose to create a new user during initial setup, the steps below are not required unless you want to create additional users.
```dos
passwd
useradd -m -s /bin/bash <username>
Expand Down
46 changes: 46 additions & 0 deletions bash_profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# First run script for LinuxmintWSL

ylw=$(tput setaf 3)
txtrst=$(tput sgr0)

echo -e "\033[33;7mDo not interrupt or close the terminal window till script finishes execution!!!\033[0m"
figlet -t Welcome to LinuxmintWSL
echo -e "[automount]\n\n[network]\n\n[interop]\n\n[user]\n\n#The Boot setting is only available on Windows 11\n[boot]\n" >/etc/wsl.conf
echo " "
echo -e "\033[32mDo you want to create a new user?\033[m"
select yn in "Yup" "Nope"; do
case $yn in
Yup)
echo " "
while read -p "Please enter the username you wish to create : " username; do
if [ x$username = "x" ]; then
echo -e "\033[31m Blank username entered. Try again\033[m"
echo -en "\033[1A\033[1A\033[2K"
username=""
elif grep -q "$username" /etc/passwd; then
echo -e "\033[31mUsername already exists. Try again\033[m"
echo -en "\033[1A\033[1A\033[2K"
username=""
else
useradd -m -s /bin/bash "$username"
echo -en "\033[1B\033[1A\033[2K"
passwd $username
sed -i "/\[user\]/a default = $username" /etc/wsl.conf >/dev/null
echo " "
secs=5
while [ $secs -gt 0 ]; do
printf ${ylw}"\r\033[KSystem needs to be restarted. Shutting down in %.d seconds."${txtrst} $((secs--))
sleep 1
done
rm ~/.bash_profile
cmd.exe /C wsl --shutdown
fi
done
;;
Nope)
clear
rm ~/.bash_profile
break
;;
esac
done

0 comments on commit 83f9a2f

Please sign in to comment.