Skip to content

Commit 8ff5c4e

Browse files
committed
Cleanup
1 parent 2f3dfc9 commit 8ff5c4e

File tree

1 file changed

+0
-95
lines changed

1 file changed

+0
-95
lines changed

bash_profile

-95
Original file line numberDiff line numberDiff line change
@@ -8,106 +8,11 @@ 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-
width=$(echo $COLUMNS)
15-
16-
if [ "$width" -gt 120 ]; then
17-
width=120
18-
fi
19-
20-
test -e /mnt/c/Users/Public/vhdresize.txt && rm /mnt/c/Users/Public/vhdresize.txt
2111
test -e /mnt/c/Users/Public/shutdown.cmd && rm /mnt/c/Users/Public/shutdown.cmd
22-
test -e ~/vhdresize.txt && rm ~/vhdresize.txt
2312
test -e ~/shutdown.cmd && rm ~/shutdown.cmd
2413
figlet -t -k -f /usr/share/figlet/fonts/mini.flf "Welcome to ArchWSL2" | lolcat
2514
echo -e "\033[33;7mDo not interrupt or close the terminal window till script finishes execution!!!\n\033[0m"
2615

27-
if [ "$disksize" -le 274877906944 ]; then
28-
echo -e ${grn}"ArchWSL2'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
29-
select yn in "Yes" "No"; do
30-
case $yn in
31-
Yes)
32-
echo " "
33-
while read -p ${mgn}"Path to virtual disk (e.g. C:\Users\silesh\wsl\ext4.vhdx) : "${txtrst} -r vhdpath; do
34-
if [ "x$vhdpath" = "x" ]; then
35-
echo -e ${red}"Path cannot be blank."${txtrst}
36-
echo -en "\033[1A\033[1A\033[2K"
37-
vhdpath=""
38-
else
39-
wsl_path=$(wslpath -a $vhdpath)
40-
if [ ! -f $wsl_path ]; then
41-
echo -e ${red}"Disk does not exist. "${txtrst}
42-
echo -en "\033[1A\033[1A\033[2K"
43-
vhdpath=""
44-
else
45-
echo "select vdisk file=\"$vhdpath\"" | sudo tee -a ~/vhdresize.txt >/dev/null 2>&1
46-
break
47-
fi
48-
fi
49-
done
50-
while read -p ${mgn}"Size of virtual disk in MegaBytes(e.g. 512000 for 512GB) : "${txtrst} vhdsize; do
51-
if [[ $vhdsize =~ ^-?[0-9]+$ ]]; then
52-
if [ "$vhdsize" -le 256000 ]; then
53-
echo -e ${red}"Disk size should be greater than 256000 MegaBytes."${txtrst}
54-
echo -en "\033[1A\033[1A\033[2K"
55-
vhdsize=0
56-
else
57-
echo -en "\033[1B\033[1A\033[2K"
58-
echo "expand vdisk maximum=$vhdsize" | sudo tee -a ~/vhdresize.txt >/dev/null 2>&1
59-
echo " "
60-
printf "%s" "$(<~/vhdresize.txt)"
61-
echo " "
62-
echo -e ${grn}"\nReview the information displayed above and confirm to proceed."${txtrst}
63-
echo -e ${red}"Edit only your input if you want to make changes!!!"${txtrst}
64-
select yn in "Proceed" "Edit"; do
65-
case $yn in
66-
Proceed)
67-
break
68-
;;
69-
Edit)
70-
"${EDITOR:-nano}" ~/vhdresize.txt
71-
break
72-
;;
73-
esac
74-
done
75-
echo "@echo off" | sudo tee -a ~/shutdown.cmd >/dev/null 2>&1
76-
echo "wsl --shutdown" | sudo tee -a ~/shutdown.cmd >/dev/null 2>&1
77-
echo "diskpart /s C:\Users\Public\vhdresize.txt" | sudo tee -a ~/shutdown.cmd >/dev/null 2>&1
78-
if env | grep "WT_SESSION" >/dev/null 2>&1; then
79-
echo "wt.exe -w 0 nt wsl.exe -d $WSL_DISTRO_NAME" | sudo tee -a ~/shutdown.cmd >/dev/null 2>&1
80-
else
81-
echo "cmd /c start \"$WSL_DISTRO_NAME\" wsl.exe --cd ~ -d $WSL_DISTRO_NAME" | sudo tee -a ~/shutdown.cmd >/dev/null 2>&1
82-
fi
83-
cp ~/vhdresize.txt /mnt/c/Users/Public
84-
cp ~/shutdown.cmd /mnt/c/Users/Public && rm ~/shutdown.cmd
85-
break
86-
fi
87-
else
88-
echo -e ${red}"Disk size cannot be blank and has to be numeric. "${txtrst}
89-
echo -en "\033[1A\033[1A\033[2K"
90-
fi
91-
done
92-
93-
secs=3
94-
printf ${ylw}"\nPlease grant diskpart elevated permissions when requested. ArchWSL2 will restart after disk resize.\n"${txtrst}
95-
printf ${red}"Warning!!! Any open wsl distros will be shutdown.\n\n"${txtrst}
96-
while [ $secs -gt 0 ]; do
97-
printf "\r\033[KShutting down in %.d seconds. " $((secs--))
98-
sleep 1
99-
done
100-
101-
powershell.exe -command "Start-Process -Verb Open -FilePath 'shutdown.cmd' -WorkingDirectory 'C:\Users\Public' -WindowStyle Hidden"
102-
exec sleep 0
103-
;;
104-
No)
105-
break
106-
;;
107-
esac
108-
done
109-
fi
110-
11116
echo -e ${grn}"Initializing and populating keyring..."${txtrst}
11217
pacman-key --init >/dev/null 2>&1
11318
pacman-key --populate >/dev/null 2>&1

0 commit comments

Comments
 (0)