Skip to content

Commit 258c0ea

Browse files
committed
Cleanup
1 parent f4a461b commit 258c0ea

File tree

1 file changed

+0
-96
lines changed

1 file changed

+0
-96
lines changed

bash_profile

-96
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,7 @@ red=$(tput setaf 1)
88
ylw=$(tput setaf 3)
99
txtrst=$(tput sgr0)
1010

11-
diskvol=$(mount | grep -m1 ext4 | cut -f 1 -d " ")
12-
sudo resize2fs $diskvol >/dev/null 2>&1
13-
disksize=$(sudo blockdev --getsize64 $diskvol)
14-
osname=$(/mnt/c/Windows/System32/wbem/wmic.exe os get Caption | sed -n 2p)
15-
width=$(echo $COLUMNS)
16-
17-
if [ "$width" -gt 120 ]; then
18-
width=120
19-
fi
20-
21-
test -e /mnt/c/Users/Public/vhdresize.txt && rm /mnt/c/Users/Public/vhdresize.txt
2211
test -e /mnt/c/Users/Public/shutdown.cmd && rm /mnt/c/Users/Public/shutdown.cmd
23-
test -e ~/vhdresize.txt && rm ~/vhdresize.txt
2412
test -e ~/shutdown.cmd && rm ~/shutdown.cmd
2513
figlet -t -k -f /usr/share/figlet/mini.flf "Welcome to LinuxmintWSL" | lolcat
2614
echo -e "\033[33;7mDo not interrupt or close the terminal window till script finishes execution!!!\n\033[0m"
@@ -29,90 +17,6 @@ getent passwd ubuntu >/dev/null && (
2917
rm -rf /home/ubuntu
3018
)
3119

32-
if [ "$disksize" -le 274877906944 ]; then
33-
echo -e ${grn}"LinuxmintWSL's VHD has a default maximum size of 256GB. Disk space errors which occur if size exceeds 256GB can be fixed by expanding the VHD. Would you like to resize your VHD? More information on this process is available at \033[36mhttps://docs.microsoft.com/en-us/windows/wsl/vhd-size\033[32m."${txtrst} | fold -sw $width
34-
select yn in "Yes" "No"; do
35-
case $yn in
36-
Yes)
37-
echo " "
38-
while read -p ${mgn}"Path to virtual disk (e.g. C:\Users\silesh\wsl\ext4.vhdx) : "${txtrst} -r vhdpath; do
39-
if [ "x$vhdpath" = "x" ]; then
40-
echo -e ${red}"Path cannot be blank."${txtrst}
41-
echo -en "\033[1A\033[1A\033[2K"
42-
vhdpath=""
43-
else
44-
wsl_path=$(wslpath -a $vhdpath)
45-
if [ ! -f $wsl_path ]; then
46-
echo -e ${red}"Disk does not exist. "${txtrst}
47-
echo -en "\033[1A\033[1A\033[2K"
48-
vhdpath=""
49-
else
50-
echo "select vdisk file=\"$vhdpath\"" | sudo tee -a ~/vhdresize.txt >/dev/null 2>&1
51-
break
52-
fi
53-
fi
54-
done
55-
while read -p ${mgn}"Size of virtual disk in MegaBytes(e.g. 512000 for 512GB) : "${txtrst} vhdsize; do
56-
if [[ $vhdsize =~ ^-?[0-9]+$ ]]; then
57-
if [ "$vhdsize" -le 256000 ]; then
58-
echo -e ${red}"Disk size should be greater than 256000 MegaBytes."${txtrst}
59-
echo -en "\033[1A\033[1A\033[2K"
60-
vhdsize=0
61-
else
62-
echo -en "\033[1B\033[1A\033[2K"
63-
echo "expand vdisk maximum=$vhdsize" | sudo tee -a ~/vhdresize.txt >/dev/null 2>&1
64-
echo " "
65-
printf "%s" "$(<~/vhdresize.txt)"
66-
echo " "
67-
echo -e ${grn}"\nReview the information displayed above and confirm to proceed."${txtrst}
68-
echo -e ${red}"Edit only your input if you want to make changes!!!"${txtrst}
69-
select yn in "Proceed" "Edit"; do
70-
case $yn in
71-
Proceed)
72-
break
73-
;;
74-
Edit)
75-
"${EDITOR:-nano}" ~/vhdresize.txt
76-
break
77-
;;
78-
esac
79-
done
80-
echo "@echo off" | sudo tee -a ~/shutdown.cmd >/dev/null 2>&1
81-
echo "wsl --shutdown" | sudo tee -a ~/shutdown.cmd >/dev/null 2>&1
82-
echo "diskpart /s C:\Users\Public\vhdresize.txt" | sudo tee -a ~/shutdown.cmd >/dev/null 2>&1
83-
if env | grep "WT_SESSION" >/dev/null 2>&1; then
84-
echo "wt.exe -w 0 nt wsl.exe -d $WSL_DISTRO_NAME" | sudo tee -a ~/shutdown.cmd >/dev/null 2>&1
85-
else
86-
echo "cmd /c start \"$WSL_DISTRO_NAME\" wsl.exe --cd ~ -d $WSL_DISTRO_NAME" | sudo tee -a ~/shutdown.cmd >/dev/null 2>&1
87-
fi
88-
cp ~/vhdresize.txt /mnt/c/Users/Public
89-
cp ~/shutdown.cmd /mnt/c/Users/Public && rm ~/shutdown.cmd
90-
break
91-
fi
92-
else
93-
echo -e ${red}"Disk size cannot be blank and has to be numeric. "${txtrst}
94-
echo -en "\033[1A\033[1A\033[2K"
95-
fi
96-
done
97-
98-
secs=3
99-
printf ${ylw}"\nPlease grant diskpart elevated permissions when requested. LinuxmintWSL will restart after disk resize.\n"${txtrst}
100-
printf ${red}"Warning!!! Any open wsl distros will be shutdown.\n\n"${txtrst}
101-
while [ $secs -gt 0 ]; do
102-
printf "\r\033[KShutting down in %.d seconds. " $((secs--))
103-
sleep 1
104-
done
105-
106-
powershell.exe -command "Start-Process -Verb Open -FilePath 'shutdown.cmd' -WorkingDirectory 'C:\Users\Public' -WindowStyle Hidden"
107-
exec sleep 0
108-
;;
109-
No)
110-
break
111-
;;
112-
esac
113-
done
114-
fi
115-
11620
rm /etc/os-release
11721
ln -s /usr/lib/os-release /etc/os-release
11822
sudo systemctl daemon-reload

0 commit comments

Comments
 (0)