-
Notifications
You must be signed in to change notification settings - Fork 11
/
virtio-win-drivers-prepare
executable file
·60 lines (53 loc) · 2.26 KB
/
virtio-win-drivers-prepare
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
#!/bin/sh
if [ "$VIRTIO_ISO" = "" ]; then
VIRTIO_ISO=./virtio-win.iso
echo "VIRTIO_ISO not set, defaulting to './virtio-win.iso'."
fi
if [ "$VIRTIO_DRIVERS" = "" ]; then
VIRTIO_DRIVERS=./drivers
echo "VIRTIO_DRIVERS not set, using driver directory './drivers'."
fi
if [ ! -f $VIRTIO_ISO -a "$VIRTIO_URL" = "" ]; then
VIRTIO_URL=https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso
echo "VIRTIO_URL not set, defaulting to:"
echo $VIRTIO_URL
fi
if [ "$WIN_VER" = "" ]; then
WIN_VER=2k25
echo "WIN_VER not set, defaulting to '2k25'."
fi
if [ ! -f $VIRTIO_ISO ]; then
echo "Downloading latest stable virtio-win.iso..."
if [ "$(which curl 2> /dev/null)" != "" ]; then
curl -L https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso -o $VIRTIO_ISO
elif [ "$(which wget 2> /dev/null)" != "" ]; then
wget https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso -O $VIRTIO_ISO
else
echo "No curl/wget available, can't download virtio-win.iso automatically" 1>&2
exit 1
fi
fi
if [ ! -f $VIRTIO_ISO ]; then
echo "Failed to download virtio-win.iso" 1>&2
exit 1
fi
rm -rf $VIRTIO_DRIVERS
if [ "$(which 7z 2> /dev/null)" != "" ]; then
7z x -o$VIRTIO_DRIVERS $VIRTIO_ISO > /dev/null || exit 2
elif [ "$(which bsdtar 2> /dev/null)" != "" ]; then
mkdir -p $VIRTIO_DRIVERS
bsdtar -C $VIRTIO_DRIVERS -xf $VIRTIO_ISO || exit 3
elif [ "$(which guestfish 2> /dev/null)" != "" ]; then
mkdir -p $VIRTIO_DRIVERS
guestfish --ro -a $VIRTIO_ISO -m /dev/sda tar-out / - | tar -C $VIRTIO_DRIVERS -xf - || exit 4
else
echo "No 7z/bsdtar/guestfish available, can't extract virtio-win.iso automatically" 1>&2
exit 1
fi
find $VIRTIO_DRIVERS -type d -exec chmod 0755 {} +
find $VIRTIO_DRIVERS -type f -exec chmod 0644 {} +
find $VIRTIO_DRIVERS -maxdepth 1 -type f \! -name virtio-win-guest-tools.exe -exec rm -r {} +
find $VIRTIO_DRIVERS -mindepth 1 -maxdepth 1 -type d \! \( -name Balloon -o -name NetKVM -o -name qemufwcfg -o -name vioserial -o -name viostor \) -exec rm -r {} +
find $VIRTIO_DRIVERS -mindepth 2 -maxdepth 2 -type d \! -name $WIN_VER -exec rm -r {} +
echo
echo "KVM/QEMU/VirtIO drivers for Windows $WIN_VER now ready in directory '$VIRTIO_DRIVERS'."