-
Notifications
You must be signed in to change notification settings - Fork 11
/
Linux_Windows11SuperLiteQCOW2_NgrokAP.sh
358 lines (358 loc) · 19.6 KB
/
Linux_Windows11SuperLiteQCOW2_NgrokAP.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
#!/bin/bash
#
#Vars
echo Install Gdrive ...
wget -O /usr/src/gdrive https://raw.githubusercontent.com/kmille36/Linux-to-Windows-with-QEMU/master/gdrive-linux-x64 >/dev/null 2>&1
chmod +x /usr/src/gdrive >/dev/null 2>&1
sudo install /usr/src/gdrive /usr/local/bin/gdrive >/dev/null 2>&1
wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip && unzip *.zip
clear
read -p "Paste authtoken here (Copy and Right-click to paste): " CRP
./ngrok authtoken $CRP
nohup ./ngrok tcp --region ap 30889 &>/dev/null &
windows_os_link=https://app.vagrantup.com/thuonghai2711/boxes/WindowsQCOW2/versions/1.0.0/providers/qemu22000.box
windows_os_name="Windows 11 Super Lite"
custom_param_disk="windows11lite.qcow2"
echo $custom_param_disk >disk.txt
echo gdrive upload $custom_param_disk >update.txt
mounted=0
GREEN='\033[1;32m';GREEN_D='\033[0;32m';RED='\033[0;31m';YELLOW='\033[0;33m';BLUE='\033[0;34m';NC='\033[0m'
# Virtualization checking..
virtu=$(egrep -i '^flags.*(vmx|svm)' /proc/cpuinfo | wc -l)
if [ $virtu = 0 ] ; then echo -e "[Error] ${RED}Virtualization/KVM in your Server/VPS is OFF\nExiting...${NC}";
else
#
# Deleting Previous Windows Installation by the Script
#umount -l /mnt /media/script /media/sw
#rm -rf /mediabots /floppy /virtio /media/* /tmp/*
#rm -f /sw.iso /disk.img
# installing required Ubuntu packages
dist=$(hostnamectl | egrep "Operating System" | cut -f2 -d":" | cut -f2 -d " ")
if [ $dist = "CentOS" ] ; then
printf "Y\n" | yum install sudo -y
sudo yum install wget vim curl genisoimage -y
# Downloading Portable QEMU-KVM
echo "Downloading QEMU"
umount /dev/mapper/centos-home
yes|lvreduce -L 2G /dev/mapper/centos-home
lvextend -r -l+100%FREE /dev/mapper/centos-root
sudo yum remove xorg* -y
sudo yum remove gnome* -y
yum remove xrdp -y
##sudo yum update -y
sudo yum install -y qemu-kvm
sudo yum install libguestfs-tools -y
curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo
##sudo yum install -y powershell
elif [ $dist = "Ubuntu" -o $dist = "Debian" ] ; then
printf "Y\n" | apt-get install sudo -y
sudo apt-get install vim curl genisoimage -y
sudo mkdir /etc/powershell
sudo wget -P /etc/powershell https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb
sudo dpkg -i /etc/powershell/packages-microsoft-prod.deb
# Downloading Portable QEMU-KVM
echo "Downloading QEMU"
sudo apt-get update
dpkg-reconfigure debconf -f noninteractive -p critical
UCF_FORCE_CONFFOLD=YES apt -o Dpkg::Options::="--force-confdef" -o DPkg::Options::="--force-confold" -y dist-upgrade
sudo apt-get install -y qemu-kvm
##sudo apt-get install -y powershell
fi
sudo ln -s /usr/bin/genisoimage /usr/bin/mkisofs
# Downloading resources
sudo mkdir /mediabots /floppy /virtio
link1_status=$(curl -Is $windows_os_link | grep HTTP | cut -f2 -d" " | head -1)
link2_status=$(curl -Is https://ia601506.us.archive.org/4/items/WS2012R2/WS2012R2.ISO | grep HTTP | cut -f2 -d" ")
#sudo wget -P /mediabots https://archive.org/download/WS2012R2/WS2012R2.ISO # Windows Server 2012 R2
if [ $link1_status = "302" ] ; then
##sudo wget -O /mediabots/WS2022.ISO https://software-download.microsoft.com/download/sg/20348.1.210507-1500.fe_release_SERVER_EVAL_x64FRE_en-us.iso
sudo wget -O $custom_param_disk $windows_os_link
elif [ $link2_status = "200" -o $link2_status = "301" -o $link2_status = "302" ] ; then
sudo wget -P /mediabots https://ia601506.us.archive.org/4/items/WS2012R2/WS2012R2.ISO
else
echo -e "${RED}[Error]${NC} ${YELLOW}Sorry! None of Windows OS image urls are available , please report about this issue on Github page : ${NC}https://github.com/mediabots/Linux-to-Windows-with-QEMU"
echo "Exiting.."
sleep 30
exit 1
fi
sudo wget -P /floppy http://dl.google.com/chrome/install/375.126/chrome_installer.exe
sudo mv /floppy/'chrome_installer.exe' /floppy/chrome_installer.exe
##sudo wget -P /floppy https://raw.githubusercontent.com/kmille36/Linux-to-Windows-with-QEMU/master/KMSpico.exe # Active Windows
# Powershell script to auto enable remote desktop for administrator
sudo touch /floppy/EnableRDP.ps1
sudo echo -e "Set-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\' -Name \"fDenyTSConnections\" -Value 0" >> /floppy/EnableRDP.ps1
sudo echo -e "Set-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\' -Name \"UserAuthentication\" -Value 1" >> /floppy/EnableRDP.ps1
sudo echo -e "Enable-NetFirewallRule -DisplayGroup \"Remote Desktop\"" >> /floppy/EnableRDP.ps1
# Downloading Virtio Drivers
##sudo wget -P /virtio https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso
# creating .iso for Windows tools & drivers
sudo mkisofs -o /sw.iso /floppy
#
#Enabling KSM
sudo echo 1 > /sys/kernel/mm/ksm/run
#Free memories
sync; sudo echo 3 > /proc/sys/vm/drop_caches
# Gathering System information
idx=0
fs=($(df | awk '{print $1}'))
for j in $(df | awk '{print $6}');do if [ $j = "/" ] ; then os=${fs[$idx]};echo $os;fi;idx=$((idx+1));done
#
ip=$(curl ifconfig.me)
echo "Linux Distro : "$dist
virtualization=$(lscpu | grep Virtualization: | head -1 | cut -f2 -d":" | awk '{$1=$1;print}')
echo "Virtualization : "$virtualization
model=$(lscpu | grep "Model name:" | head -1 | cut -f2 -d":" | awk '{$1=$1;print}')
echo "CPU Model : "$model
cpus=$(lscpu | grep CPU\(s\) | head -1 | cut -f2 -d":" | awk '{$1=$1;print}')
echo "No. of CPU cores : "$cpus
if [ $dist = "Debian" ] ;then availableRAMcommand="free -m | head -2 | tail -1 | awk '{print \$4}'" ; elif [ $dist = "Ubuntu" -o $dist = "CentOS" ] ;then availableRAMcommand="free -m | tail -2 | head -1 | awk '{print \$7}'"; fi
availableRAM=$(echo $availableRAMcommand | bash)
echo "Available RAM : "$availableRAM" MB"
diskNumbers=$(fdisk -l | grep "Disk /dev/" | wc -l)
partNumbers=$(lsblk | egrep "part" | wc -l) # $(fdisk -l | grep "^/dev/" | wc -l)
firstDisk=$(fdisk -l | grep "Disk /dev/" | head -1 | cut -f1 -d":" | cut -f2 -d" ")
freeDisk=$(df | grep "^/dev/" | awk '{print$1 " " $4}' | sort -g -k 2 | tail -1 | cut -f2 -d" ")
# Windows required at least 25 GB free disk space
firstDiskLow=0
if [ $(expr $freeDisk / 1024 / 1024 ) -ge 25 ]; then
newDisk=$(expr $freeDisk \* 90 / 100 / 1024)
if [ $(expr $newDisk / 1024 ) -lt 25 ] ; then newDisk=25600 ; fi
else
firstDiskLow=1
fi
#
# setting up default values
custom_param_os="/mediabots/"$(ls /mediabots)
custom_param_sw="/sw.iso"
custom_param_virtio="/virtio/"$(ls /virtio)
#
custom_param_ram="-m "$(expr $availableRAM - 200 )"M"
skipped=0
partition=0
other_drives=""
format=",format=raw"
if [ $dist = "CentOS" ] ; then
qemupath=$(whereis qemu-kvm | sed "s/ /\n/g" | egrep "^/usr/libexec/")
#b=($(lsblk | egrep "part" | tr -s '[:space:]' | cut -f1 -d" " | tr -cd "[:print:]\n" | sed 's/^/\/dev\//'))
else
qemupath=$(whereis qemu-system-x86_64 | cut -f2 -d" ")
#b=($(fdisk -l | grep "^/dev/" | tr -d "*" | tr -s '[:space:]' | cut -f1 -d" "))
fi
if [ $diskNumbers -eq 1 ] ; then # opened 1st if
if [ $availableRAM -ge 4650 ] ; then # opened 2nd if
echo -e "${BLUE}For below option pass${NC} yes ${BLUE}iff, your VPS/Server came with${NC} boot system in ${NC}${RED}'RESCUE'${NC} mode ${BLUE}feature${NC}"
##read -r -p "Do you want to completely delete your current Linux O.S.? (yes/no) : " deleteLinux
##deleteLinux=$(echo "$deleteLinux" | head -c 1)
deleteLinux=$(echo "N" | head -c 1)
if [ ! -z $deleteLinux ] && [ $deleteLinux = 'Y' -o $deleteLinux = 'y' ] ; then
sudo wget -qO- /tmp https://archive.org/download/vkvm.tar_201903/vkvm.tar.gz | sudo tar xvz -C /tmp
qemupath=/tmp/qemu-system-x86_64
echo "erasing primary disk data"
sudo dd if=/dev/zero of=$firstDisk bs=1M count=1 # blank out the disk
echo "mounting devices"
mount -t tmpfs -o size=4500m tmpfs /mnt
mv /mediabots/* /mnt
mkdir /media/sw
mount -t tmpfs -o size=121m tmpfs /media/sw
mv /sw.iso /media/sw
custom_param_os="/mnt/"$(ls /mnt)
custom_param_sw="/media/sw/sw.iso"
availableRAM=$(echo $availableRAMcommand | bash)
custom_param_disk=$firstDisk
custom_param_ram="-m "$(expr $availableRAM - 500 )"M"
format=""
mounted=1
else
if [ $firstDiskLow = 0 ] ; then
if [ $partNumbers -gt 1 ] ; then
idx=0;ix=0;
#for i in $(fdisk -l | grep "^/dev/" | tr -d "*" | tr -s '[:space:]' | cut -f5 -d" "); do
for i in $(lsblk | egrep "part" | tr -s '[:space:]' | cut -f4 -d" "); do
b=($(lsblk | egrep "part" | tr -s '[:space:]' | cut -f1 -d" " | tr -cd "[:alnum:]\n" | sed 's/^/\/dev\//'))
if [[ $i == *"G" ]]; then a=$(echo $i | tr -d "G"); a=${a%.*} ; if [ $a -ge 25 -a $ix = 0 -a ${b[idx]} != $os ] ; then firstDisk=${b[idx]} ; custom_param_disk=$firstDisk ; partition=1 ; ix=$((ix+3)) ; elif [ $a -ge 25 -a $ix = 3 -a ${b[idx]} != $os ] ; then other_drives="-drive file=${b[idx]},index=$ix,media=disk,format=raw " ; fi ; fi ;
idx=$((idx+1));
done
if [ $partition = 0 ] ;then
echo "creating disk image"
sudo dd if=/dev/zero of=/disk.img bs=1024k seek=$newDisk count=0
custom_param_disk="/disk.img"
fi
else
echo "creating disk image"
sudo dd if=/dev/zero of=/disk.img bs=1024k seek=$newDisk count=0
custom_param_disk="/disk.img"
fi
else
skipped=1
fi
fi
else
if [ $firstDiskLow = 0 ] ; then
if [ $partNumbers -gt 1 ] ; then
idx=0;ix=0;
for i in $(lsblk | egrep "part" | tr -s '[:space:]' | cut -f4 -d" "); do
b=($(lsblk | egrep "part" | tr -s '[:space:]' | cut -f1 -d" " | tr -cd "[:alnum:]\n" | sed 's/^/\/dev\//'))
if [[ $i == *"G" ]]; then a=$(echo $i | tr -d "G"); a=${a%.*} ; if [ $a -ge 25 -a $ix = 0 -a ${b[idx]} != $os ] ; then firstDisk=${b[idx]} ; custom_param_disk=$firstDisk ; partition=1 ; ix=$((ix+3)) ; elif [ $a -ge 25 -a $ix = 3 -a ${b[idx]} != $os ] ; then other_drives="-drive file=${b[idx]},index=$ix,media=disk,format=raw " ; fi ; fi ;
idx=$((idx+1));
done
if [ $partition = 0 ] ;then
echo "creating disk image"
sudo dd if=/dev/zero of=/disk.img bs=1024k seek=$newDisk count=0
custom_param_disk="/disk.img"
fi
else
echo "creating disk image"
sudo dd if=/dev/zero of=/disk.img bs=1024k seek=$newDisk count=0
custom_param_disk="/disk.img"
fi
else
skipped=1
fi
fi # 2nd if closed
else # 1st if else
if [ $availableRAM -ge 4650 ] ; then
##read -r -p "Do you want to completely delete your current Linux O.S.? (yes/no) : " deleteLinux
##deleteLinux=$(echo "$deleteLinux" | head -c 1)
deleteLinux=$(echo "N" | head -c 1)
if [ ! -z $deleteLinux ] && [ $deleteLinux = 'Y' -o $deleteLinux = 'y' ] ; then
sudo wget -qO- /tmp https://archive.org/download/vkvm.tar_201903/vkvm.tar.gz | sudo tar xvz -C /tmp
qemupath=/tmp/qemu-system-x86_64
echo "erasing primary disk data"
sudo dd if=/dev/zero of=$firstDisk bs=1M count=1 # blank out the disk
echo "mounting devices"
mount -t tmpfs -o size=4500m tmpfs /mnt
mv /mediabots/* /mnt
mkdir /media/sw
mount -t tmpfs -o size=121m tmpfs /media/sw
mv /sw.iso /media/sw
custom_param_os="/mnt/"$(ls /mnt)
custom_param_sw="/media/sw/sw.iso"
availableRAM=$(echo $availableRAMcommand | bash)
##custom_param_disk=$firstDisk
##custom_param_disk=/dev/mapper/centos-root
custom_param_ram="-m "$(expr $availableRAM - 500 )"M"
format=""
mounted=1
else
echo "using secondary disk for installation."
custom_param_disk=$(fdisk -l | grep "Disk /dev/" | awk 'NR==2' | cut -f2 -d" " | cut -f1 -d":") # 2nd disk chosen
fi
else
echo "using secondary disk for installation.."
custom_param_disk=$(fdisk -l | grep "Disk /dev/" | awk 'NR==2' | cut -f2 -d" " | cut -f1 -d":")
fi
fi # closed 1st if
# Adding other disks only if multi partitions are not exist
if [ $partition = 0 ] ; then
ix=2
if [ $custom_param_disk != "/disk.img" ] ; then
for i in $(fdisk -l | grep "Disk /dev/" | cut -f2 -d" " | cut -f1 -d ":") ; do
if [ $i != $custom_param_disk ];then
#echo $i;
ix=$((ix+1))
other_drives=$other_drives"-drive file=$i,index=$ix,media=disk,format=qcow2 "
if [ $ix = 3 ]; then break; fi
fi
done
fi
fi
#
# Running the KVM
custom_param_disk=$(echo cat disk.txt | bash)
echo "creating disk image"
##dd if=/dev/zero of=disk.img bs=1024k seek=52224 count=0
qemu-img resize $custom_param_disk 55GB
echo "[ Running the KVM ]"
if [ $skipped = 0 ] ; then
echo "[.] running QEMU-KVM"
sudo $qemupath -net nic -net user,hostfwd=tcp::30889-:3389 -show-cursor $custom_param_ram -localtime -enable-kvm -cpu host,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time,+nx -M pc -smp cores=$cpus -vga std -machine type=pc,accel=kvm -usb -device usb-tablet -k en-us -drive file=$custom_param_disk,index=0,media=disk,format=qcow2 -drive file=$custom_param_sw,index=1,media=cdrom -boot once=d -vnc :9 &
# [note- no sudo should be used after that]
#pidqemu=$(pgrep qemu) # does not work
pid=$(echo $! | head -1)
disown -h $pid
echo "disowned PID : "$pid
echo "[ For Debugging purpose ]"
echo -e "$qemupath -net nic -net user,hostfwd=tcp::30889-:3389 -show-cursor $custom_param_ram -localtime -enable-kvm -cpu host,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time,+nx -M pc -smp cores=$cpus -vga std -machine type=pc,accel=kvm -usb -device usb-tablet -k en-us -drive file=$custom_param_disk,index=0,media=disk$format -drive file=$custom_param_os,index=1,media=cdrom -drive file=$custom_param_sw,index=2,media=cdrom $other_drives -boot once=d -vnc :9 & disown %1"
if [ $mounted = 1 ]; then
echo -e "wget -P /tmp https://archive.org/download/vkvm.tar_201903/vkvm.tar.gz && tar -C /tmp -zxvf /tmp/vkvm.tar.gz && rm /tmp/vkvm.tar.gz && $qemupath -net nic -net user,hostfwd=tcp::30889-:3389 -show-cursor $custom_param_ram -localtime -enable-kvm -cpu host,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time,+nx -M pc -smp cores=$cpus -vga std -machine type=pc,accel=kvm -usb -device usb-tablet -k en-us -drive file=$custom_param_disk,index=0,media=disk,format=qcow2 $other_drives -boot c -vnc :9 & disown %1" > details.txt # -vnc :23456 incase you dont want to access it via VNC
else
echo -e "sudo $qemupath -net nic -net user,hostfwd=tcp::30889-:3389 -show-cursor $custom_param_ram -localtime -enable-kvm -cpu host,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time,+nx -M pc -smp cores=$cpus -vga std -machine type=pc,accel=kvm -usb -device usb-tablet -k en-us -drive file=$custom_param_disk,index=0,media=disk,format=qcow2 -drive file=$custom_param_sw,index=1,media=cdrom -boot once=d -vnc :9 & disown %1" > details.txt
echo -e "for i in $(ps aux | grep -i "qemu" | head -2 | tr -s '[:space:]' | cut -f2 -d" ") ; do echo "killing process id : "$i ; kill -9 $i ; done" > killqemu.txt
fi
echo -e "${YELLOW} SAVE BELOW GREEN COLORED COMMAND IN A SAFE LOCATION FOR FUTURE USAGE${NC}"
if [ $mounted = 1 ]; then
echo -e "${GREEN_D}wget -P /tmp https://archive.org/download/vkvm.tar_201903/vkvm.tar.gz && tar -C /tmp -zxvf /tmp/vkvm.tar.gz && /tmp/rm vkvm.tar.gz && $qemupath -net nic -net user,hostfwd=tcp::30889-:3389 -show-cursor $custom_param_ram -localtime -enable-kvm -cpu host,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time,+nx -M pc -smp cores=$cpus -vga std -machine type=pc,accel=kvm -usb -device usb-tablet -k en-us -drive file=$custom_param_disk,index=0,media=disk$format $other_drives -boot c -vnc :9 & disown %1${NC}"
else
echo -e "${GREEN_D}$qemupath -net nic -net user,hostfwd=tcp::30889-:3389 -show-cursor $custom_param_ram -localtime -enable-kvm -cpu host,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time,+nx -M pc -smp cores=$cpus -vga std -machine type=pc,accel=kvm -usb -device usb-tablet -k en-us -drive file=$custom_param_disk,index=0,media=disk$format $other_drives -boot c -vnc :9 & disown %1${NC}"
fi
echo -e "${BLUE}command also saved in details.txt file${NC}"
echo -e "${YELLOW}Now download 'VNC Viewer' App from here :${NC} https://www.realvnc.com/en/connect/download/viewer/\n${YELLOW}Then install it on your computer${NC}"
echo -e "Finally open ${GREEN_D}$ip:9${NC} on your VNC viewer."
if [ $mounted = 1 ]; then
read -r -p "Had your Windows Server setup completed successfully? (yes/no) : " setup_initial
setup_initial=$(echo "$setup_initial" | head -c 1)
sleep 10
if [ ! -z $setup_initial ] && [ $setup_initial = 'Y' -o $setup_initial = 'y' ] ; then
echo $pid $cpus $custom_param_disk $custom_param_sw $other_drives
echo "helper called"
for i in $(ps aux | grep -i "qemu" | head -2 | tr -s '[:space:]' | cut -f2 -d" ") ; do echo "killing process id : "$i ; kill -9 $i ; done
#sleep 30
echo "un-mounting"
umount -l /mnt
sleep 10
df
sync; echo 3 > /proc/sys/vm/drop_caches
free -m
availableRAM=$(echo $availableRAMcommand | bash)
custom_param_ram="-m "$(expr $availableRAM - 1048 )"M"
custom_param_ram2="-m "$(expr $availableRAM - 500 )"M"
echo $custom_param_ram
echo "[..] running QEMU-KVM again"
$qemupath -net nic -net user,hostfwd=tcp::30889-:3389 -show-cursor $custom_param_ram -localtime -enable-kvm -cpu host,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time,+nx -M pc -smp cores=$cpus -vga std -machine type=pc,accel=kvm -usb -device usb-tablet -k en-us -drive file=$custom_param_disk,index=0,media=disk -drive file=$custom_param_sw,index=1,media=cdrom $other_drives -boot c -vnc :9 &
pid2=$(echo $! | head -1)
disown -h $pid2
echo "disowned PID : "$pid2
echo "[ For Debugging purpose ]"
echo -e "$qemupath -net nic -net user,hostfwd=tcp::30889-:3389 -show-cursor $custom_param_ram -localtime -enable-kvm -cpu host,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time,+nx -M pc -smp cores=$cpus -vga std -machine type=pc,accel=kvm -usb -device usb-tablet -k en-us -drive file=$custom_param_disk,index=0,media=disk -drive file=$custom_param_sw,index=1,media=cdrom $other_drives -boot c -vnc :9 & disown %1"
# incase you get qemu-system-x86_64: -net user,hostfwd=tcp::3889-:3389: Could not set up host forwarding rule 'tcp::3389-:3389' ,use this instead -net user,hostfwd=tcp::30889-:3389
echo -e "${YELLOW} SAVE BELOW GREEN COLORED COMMAND IN A SAFE LOCATION FOR FUTURE USAGE${NC}"
echo -e "${GREEN}wget -P /tmp https://archive.org/download/vkvm.tar_201903/vkvm.tar.gz && tar -C /tmp -zxvf /tmp/vkvm.tar.gz && rm /tmp/vkvm.tar.gz && $qemupath -net nic -net user,hostfwd=tcp::30889-:3389 -show-cursor $custom_param_ram2 -localtime -enable-kvm -cpu host,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time,+nx -M pc -smp cores=$cpus -vga std -machine type=pc,accel=kvm -usb -device usb-tablet -k en-us -drive file=$custom_param_disk,index=0,media=disk $other_drives -boot c -vnc :9 & disown %1${NC}"
echo -e "Now you can access your Windows server through \"VNC viewer\" or \"Remote Desktop Application\" (if your server 'Remote Desktop' is enabled)."
echo "Job Done :)"
wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip && unzip *.zip
read -p "Paste authtoken here (Copy and Right-click to paste): " CRP
./ngrok authtoken $CRP
nohup ./ngrok tcp --region ap 30889 &>/dev/null &
sleep 5
curl --silent --show-error http://127.0.0.1:4040/api/tunnels | sed -nE 's/.*public_url":"tcp:..([^"]*).*/\1/p'
sleep 10
sudo mkdir /media/powershell
sudo wget -P /media/powershell https://gitlab.com/deadshot191414/winvps/-/raw/main/dotnumbers.ps1
sudo pwsh /media/powershell/dotnumbers.ps1
fi
else
echo "Job Done :)"
sleep 5
clear
echo Your RDP IP Address:
curl --silent --show-error http://127.0.0.1:4040/api/tunnels | sed -nE 's/.*public_url":"tcp:..([^"]*).*/\1/p'
echo User: Administrator
echo Password: Thuonghai001
echo This is $windows_os_name Pre-install, connect using RDP
sleep 10
echo VNC Server Address:
echo 10.10.20.50:9
echo Defaut RDP Port Forwading is 30889
echo Command start VM if it off: cat details.txt
echo Command force turn off VM: cat killqemu.txt
echo Command update disk to google drive: cat update.txt
echo Install Chrome in CDROM drive
##sudo mkdir /media/powershell
##sudo wget -P /media/powershell https://gitlab.com/deadshot191414/winvps/-/raw/main/dotnumbers.ps1
##sudo pwsh /media/powershell/dotnumbers.ps1
fi
else
echo "Windows OS required at least 25GB free desk space. Your Server/VPS does't have 25GB free space!"
echo "Exiting....."
fi
fi