14 lines
583 B
Bash
Executable File
14 lines
583 B
Bash
Executable File
#!/bin/sh
|
|
|
|
inotifywait -q -m --format '%f' -e create /run/qemu-server/ | while read -r vm; do
|
|
# Only act if the line is not empty
|
|
if [ ${vm} ] && [ "$(echo ${vm} | sed -E 's/[0-9]{3}(\..*)/\1/')" = ".qmp" ]; then
|
|
# Get VM id ; The sed transforms 100.pid (or .whatever) to 100
|
|
vm_id=$(echo ${vm} | sed -E 's/([0-9]{3})\..*/\1/')
|
|
# If vm status is not "stopped"
|
|
if [ "$(qm status ${vm_id})" != "status: stopped" ]; then
|
|
creationRoutesVM ${vm_id}
|
|
fi
|
|
fi
|
|
done
|