forked from rennzone/Custom-Windows-Server-Image
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindows-server-autoinstaller.sh
67 lines (54 loc) · 1.89 KB
/
windows-server-autoinstaller.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
#!/bin/bash
# Function to display menu and get user choice
display_menu() {
echo "Please select the Windows Server version:"
echo "1. Windows Server 2016"
echo "2. Windows Server 2019"
echo "3. Windows Server 2022"
read -p "Enter your choice: " choice
}
# Update package repositories and upgrade existing packages
apt-get update && apt-get upgrade -y
# Install QEMU and its utilities
apt-get install qemu -y
apt install qemu-utils -y
apt install qemu-system-x86-xen -y
apt install qemu-system-x86 -y
apt install qemu-kvm -y
echo "QEMU installation completed successfully."
# Get user choice
display_menu
case $choice in
1)
# Windows Server 2016
img_file="windows2016.img"
iso_link="https://go.microsoft.com/fwlink/p/?LinkID=2195174&clcid=0x409&culture=en-us&country=US"
iso_file="windows2016.iso"
;;
2)
# Windows Server 2019
img_file="windows2019.img"
iso_link="https://go.microsoft.com/fwlink/p/?LinkID=2195167&clcid=0x409&culture=en-us&country=US"
iso_file="windows2019.iso"
;;
3)
# Windows Server 2022
img_file="windows2022.img"
iso_link="https://go.microsoft.com/fwlink/p/?LinkID=2195280&clcid=0x409&culture=en-us&country=US"
iso_file="windows2022.iso"
;;
*)
echo "Invalid choice. Exiting."
exit 1
;;
esac
echo "Selected Windows Server version: $img_file"
# Create a raw image file with the chosen name
qemu-img create -f raw "$img_file" 30G
echo "Image file $img_file created successfully."
# Download Virtio driver ISO
wget -O virtio-win.iso 'https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.215-1/virtio-win-0.1.215.iso'
echo "Virtio driver ISO downloaded successfully."
# Download Windows ISO with the chosen name
wget -O "$iso_file" "$iso_link"
echo "Windows ISO downloaded successfully."