]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Feat: inotify action
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 13 Jul 2024 19:18:44 +0000 (16:18 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 13 Jul 2024 19:18:44 +0000 (16:18 -0300)
ChangeLog.md
IDEAS.md
kvmx

index f8f520cf7468a5ef5c71b910baedf3cf695f2b8d..7a0c8a4a7c96aba28cb8872d9f65a7fc9f9d76d8 100644 (file)
@@ -1,5 +1,10 @@
 # ChangeLog
 
+## 0.3.0 - unreleased
+
+* Inotify action for watching a folder in the host and issuing commands in the
+  guest upon change.
+
 ## 0.2.0 - 2024-07-02
 
 * Increase default `msize` for 9p mounts to 32MiB depending on kernel support,
index d94272998b29d44577388f762af4bd80c8f87fcd..b49853523b229d59e074b23f48023abac3810d3e 100644 (file)
--- a/IDEAS.md
+++ b/IDEAS.md
@@ -2,13 +2,13 @@
 
 ## Usability
 
+* Submit patch for spice-client-gtk for menuless windows (spice usecase) to
+  Debian.
+
 * Docs (tutorial and manpage).
 
 * Makefile and debian package.
 
-* Submit patch for spice-client-gtk for menuless windows (spicec usecase) to
-  Debian.
-
 * Systemd service for a single VM.
 
 * Shell completions.
diff --git a/kvmx b/kvmx
index 5ab776f6636377a3fe05607dcdcbb835630c9374..e912f84005a115024d6ca128afb3e5fbe142d11d 100755 (executable)
--- a/kvmx
+++ b/kvmx
@@ -2562,6 +2562,32 @@ function kvmx_growpart {
   kvmx_restart
 }
 
+# Inotify dispatcher
+function kvmx_inotify {
+  local watched="$1"
+
+  shift
+  local command="$*"
+
+  # Syntax check
+  if [ -z "$command" ]; then
+    echo "usage $BASENAME inotify $GUEST <watched> <command>"
+    echo "example: kvmx inotify $guest hostfolder make -C guestfolder compile"
+    exit 1
+  fi
+
+  # Check if watched exists
+  if [ ! -e "$watched" ]; then
+    echo "Not found: $watched"
+    exit 1
+  fi
+
+  # Dispatch
+  while inotifywait -r $watched; do
+    echo "$command" | kvmx_ssh
+  done
+}
+
 # Dispatch
 if type kvmx_$ACTION 2> /dev/null | grep -q "kvmx_$ACTION ()"; then
   __kvmx_initialize $*