From dbb36f089142bcb833696f468d1c50e9349b1789 Mon Sep 17 00:00:00 2001
From: Recolic <git@me.recolic.net>
Date: Sun, 17 Mar 2024 20:06:26 -0700
Subject: [PATCH] .add new default base img, add flock

---
 README.md        | 11 ++++++++++-
 cron-callback.sh |  3 +++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index e311eb3..4f7a0d1 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,7 @@ Any of: aria2c / wget / curl
 
 1. Download this repo to anywhere.
 2. Modify `init.settings` and `runtime.settings`.
-3. Add `*/2 * * * * cd /path/to/my/repo && ./cron-callback.sh` into your crontab.
+3. Add `* * * * * cd /path/to/my/repo && flock -n /tmp/.vmm.lockfile ./cron-callback.sh` into your crontab.
 
 ## Supported cloudimg
 
@@ -33,6 +33,15 @@ Any of: aria2c / wget / curl
 |Ubuntu 2204 LTS   |`focal-server-cloudimg-amd64.img` |
 |Arch Linux Rolling|`Arch-Linux-x86_64-cloudimg.qcow2`|
 
+## Supported back image
+
+**Warning**: This is unofficial back image built by myself. It has preset username and password. **USE IT AT YOUR OWN RISK!!!**.
+
+|||
+| ---               | ---                              |
+|Windows 10 Pro 22H2|`win10pro-22h2-virtio-uefi.qcow2` |
+|Tiny10 Minimal 21H2|`win10-tiny10-virtio-uefi.qcow2`  |
+
 ## FAQ
 
 ### SSH not working for my new VM
diff --git a/cron-callback.sh b/cron-callback.sh
index 143f32f..bc30439 100755
--- a/cron-callback.sh
+++ b/cron-callback.sh
@@ -39,6 +39,8 @@ function download_cloud_img_if_not_exist () {
     declare -A knowledge
     knowledge["focal-server-cloudimg-amd64.img"]=https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img
     knowledge["Arch-Linux-x86_64-cloudimg.qcow2"]=https://geo.mirror.pkgbuild.com/images/latest/Arch-Linux-x86_64-cloudimg.qcow2
+    knowledge["win10pro-22h2-virtio-uefi.qcow2"]=https://recolic.net/hms.php?/systems/win10pro-22h2-virtio-uefi.qcow2
+    knowledge["win10-tiny10-virtio-uefi.qcow2"]=https://recolic.net/hms.php?/systems/win10-tiny10-virtio-uefi.qcow2
     [ ! "${knowledge[$cloudimg]+abc}" ] && echo2 "Unknown cloudimg $cloudimg. cannot download it." && return 1
 
     echo2 "+ Downloading cloudimg $cloudimg..."
@@ -75,6 +77,7 @@ function create_vm_if_not_exist () {
         qemu-img resize "vm/$name/disk.img" "$disk" || return $?
     else
         # create from baseimg
+        download_cloud_img_if_not_exist "$cloudimg" || return $?
         qemu-img create -f qcow2 -F qcow2 -b "../../base/$cloudimg" "vm/$name/disk.img" || return $?
     fi
 }
-- 
GitLab