Date: Friday, April 29, 2022 @ 22:54:07
  Author: heftig
Revision: 444322

qemu-common.install: Avoid script failure when file is not a dir

Modified:
  qemu/trunk/qemu-common.install

---------------------+
 qemu-common.install |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

Modified: qemu-common.install
===================================================================
--- qemu-common.install 2022-04-29 21:34:44 UTC (rev 444321)
+++ qemu-common.install 2022-04-29 22:54:07 UTC (rev 444322)
@@ -1,9 +1,14 @@
 post_install() {
-  local file
-  local files=(/sys/devices/virtual/misc/vhost-net)
+  if [[ -d /run/udev ]]; then
+    local file files=(
+      /sys/devices/virtual/misc/vhost-net
+    )
 
-  # trigger change event, if modules are already loaded
-  for file in "${files[@]}"; do
-    [[ -d "$file" ]] &&  udevadm trigger --action=change "$file"
-  done
+    # trigger change event when modules are already loaded
+    for file in "${files[@]}"; do
+      if [[ -d $file ]]; then
+        udevadm trigger --action=change "$file"
+      fi
+    done
+  fi
 }

Reply via email to