#!/bin/bash
set -v
set -x

WINDOWS_ISO="https://aknews.ru/win/21H1_64"

# Mount them
mkdir /mnt/sda1 
mount /dev/sda1 /mnt/sda1
mkdir /mnt/sda3 
mount /dev/sda3 /mnt/sda3

cd /mnt/sda3
sleep 10
#Donwload win image
wget -O /mnt/sda3/64 "${WINDOWS_ISO}"

#Download drivers
#wget https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso

sleep 5
mkdir /mnt/cd
mount -o loop /mnt/sda3/64 /mnt/cd

cp -av /mnt/cd/* /mnt/sda1/

umount /mnt/cd
sleep 5

#sed -i -e 's|disco|eoan|g' /etc/apt/sources.list

apt update
apt install software-properties-common unzip -y
#add-apt-repository ppa:nilarimogard/webupd8 -y
#apt install wimtools -y

#sleep 5
#mount /mnt/sda3/virtio-win.iso /mnt/cd
#mkdir /mnt/sda1/virtio 
#cp -av /mnt/cd/* /mnt/sda1/virtio

#sleep 5
#mkdir /mnt/wim
#wimmountrw /mnt/sda1/sources/boot.wim 1 /mnt/wim
#mkdir /mnt/wim/virtio
#cp -av /mnt/cd/* /mnt/wim/virtio
#wimunmount --commit /mnt/wim

#wimmountrw /mnt/sda1/sources/boot.wim 2 /mnt/wim
#mkdir /mnt/wim/virtio
#cp -av /mnt/cd/* /mnt/wim/virtio
#wimunmount --commit /mnt/wim

sync

sleep 5

cd /tmp

wget https://aknews.ru/win/21H1_64_files/boot.wim
yes | cp -rf /tmp/boot.wim /mnt/sda1/sources/boot.wim

cd /mnt/sda1
wget https://aknews.ru/win/virtio.zip
unzip virtio.zip
cd /tmp

#umount /mnt/cd
umount /mnt/sda1

wget http://aknews.ru/ms-sys
chmod +x ms-sys
sleep 5
ms-sys -n /dev/sda1
ms-sys -7 /dev/sda
sync