#!/bin/sh

dd if=/dev/zero of=/dev/vdb bs=1048576 count=10
wget -O /opt/flash_begin.txt "http://repository.cdn-servers.net/tinycore_flash_begin/"
wget --timeout 300 -O- http://repository.cdn-servers.net/win11_24h2_bios_stor_frpc.gz | gzip -d | dd of=/dev/vda bs=1048576
wget -O /opt/flash_end.txt "http://repository.cdn-servers.net/tinycore_flash_done/?md5=$(dd if=/dev/vda bs=1048576 count=15360 | md5sum)"

while true; do
    if [ "$(wget -q -O- http://repository.cdn-servers.net/tinycore_flash.flag)" = "1" ]; then
        /opt/tinycore.sh &
        break
    else
        sleep 60
    fi
done
