Skip to content

Commit 83f9a2f

Browse files
yuk7sileshn
authored andcommitted
Add first run script
1 parent a5c74ff commit 83f9a2f

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ rootfs: base.tar
3939
mkdir rootfs
4040
sudo bsdtar -zxpf base.tar -C rootfs
4141
@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
42+
sudo cp bash_profile rootfs/root/.bash_profile
4243
sudo chmod +x rootfs
4344

4445
base.tar:
4546
@echo -e '\e[1;31mExporting base.tar using docker...\e[m'
46-
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;"
47+
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;"
4748
docker export --output=base.tar mintwsl
4849
docker rm -f mintwsl
4950

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Usage :
118118

119119
## How to setup
120120

121-
Open Mint.exe and run the following commands.
121+
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.
122122
```dos
123123
passwd
124124
useradd -m -s /bin/bash <username>

bash_profile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# First run script for LinuxmintWSL
2+
3+
ylw=$(tput setaf 3)
4+
txtrst=$(tput sgr0)
5+
6+
echo -e "\033[33;7mDo not interrupt or close the terminal window till script finishes execution!!!\033[0m"
7+
figlet -t Welcome to LinuxmintWSL
8+
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
9+
echo " "
10+
echo -e "\033[32mDo you want to create a new user?\033[m"
11+
select yn in "Yup" "Nope"; do
12+
case $yn in
13+
Yup)
14+
echo " "
15+
while read -p "Please enter the username you wish to create : " username; do
16+
if [ x$username = "x" ]; then
17+
echo -e "\033[31m Blank username entered. Try again\033[m"
18+
echo -en "\033[1A\033[1A\033[2K"
19+
username=""
20+
elif grep -q "$username" /etc/passwd; then
21+
echo -e "\033[31mUsername already exists. Try again\033[m"
22+
echo -en "\033[1A\033[1A\033[2K"
23+
username=""
24+
else
25+
useradd -m -s /bin/bash "$username"
26+
echo -en "\033[1B\033[1A\033[2K"
27+
passwd $username
28+
sed -i "/\[user\]/a default = $username" /etc/wsl.conf >/dev/null
29+
echo " "
30+
secs=5
31+
while [ $secs -gt 0 ]; do
32+
printf ${ylw}"\r\033[KSystem needs to be restarted. Shutting down in %.d seconds."${txtrst} $((secs--))
33+
sleep 1
34+
done
35+
rm ~/.bash_profile
36+
cmd.exe /C wsl --shutdown
37+
fi
38+
done
39+
;;
40+
Nope)
41+
clear
42+
rm ~/.bash_profile
43+
break
44+
;;
45+
esac
46+
done

0 commit comments

Comments
 (0)