My Fedora Linux (presently 30) system hosts several virtual machines (VMs) configured to start up when host system boots. These are isolated servers supposed to be visible from the internet containing no important or critical data, so it does not matter if they are hacked (they'll then be wiped out and reloaded).
To make them visible, I must set the firewall in passthrough mode for the destination IPs on the virtual bridge. The commands are grouped in a bash script.
I noticed for the commands to be successful and effective that the VMs must be up and running, which means I must wait for the VM boots to finish, i.e. probably the time when they reach
My problem is VM state can be tested in guest systems and my bash script must be run in the host system.
I already attempted to delay the bash script a fixed number of seconds but this does not seem to be always correct. VMs need a variable time to boot up (e.g. when they run their fsck on n-th boot) and I can't predict reliably the time when all are ready and running.
My goal is to operate my servers 24/7, automatically connecting them to internet in case of automatic restart of the host (after power failure or other events).
Presently, I launch this script manually (and somteimes I forget to do it).
Question: is there a way (systemd, cron, at, … ?) to launch my script after the VMs have settled in multi-user mode?
According to @Michael D.'s comment, my description is not clear or accurate.
firewall-cmd always terminates "successfully" unless there are syntax errors in the command. Even configuration for non-existing devices is accepted without rejection by firewall. Thus I can't rely on bash
$? to detect whether the command will have some effect or not. Monitoring return code will not help here.