This script shuts down a list of virtual machines (VMs) and powers off the host machine.
Before running the script, ensure you are operating as the root user. You can either:
-
Switch to the root user:
su -
-
Or use
sudo -i
to start a root shell:sudo -i
Once you have elevated privileges, run the script using bash
:
bash shutdown.sh
To simulate the shutdown without making any changes:
bash shutdown.sh -d
The script will shut down the following VMs by default:
dc1
idm
idm2
nessus
dc2
You can modify this list in the script under the VM_names
array.
If you receive a syntax error like ^M: bad interpreter
, it could be due to Windows-style line endings. Use dos2unix
to convert the script:
dos2unix shutdown.sh