NethServer Version: 7.6.1810
I am new to Nethserver. After working with phpvirtualbox and trying to install ERPNext VM.
Login and importing official ERPNext VM was succesfull after following:
My goal was to achieve autostart vms when server reboot.
After following this link, I was able to create pausevms and resumevms scripts :
modified pausevms script:
#!/bin/bash # Pause running VMs STATUSFILE=/home/vboxweb/vm-status # Clear the previous status file if it exists if [ -e $STATUSFILE ]; then rm $STATUSFILE; fi # List all VMs for VM in $(sudo -H -u vboxweb vboxmanage list vms | rev | cut -d' ' -f1 | rev) do # Get VM state STATE=$(sudo -H -u vboxweb vboxmanage showvminfo $VM --machinereadable | grep "VMState=" | cut -d'=' -f2) # Pause if state is running or paused, write to status file if [[ $STATE == \"running\" || $STATE == \"paused\" ]]; then sudo -H -u vboxweb vboxmanage controlvm $VM savestate # No need to restart paused vm's; just let them remain saved. if [[ $STATE == \"running\" ]]; then echo "$VM">>$STATUSFILE; fi fi done
modified resuemvms script:
#!/bin/bash # Restart VMs saved earlier STATUSFILE=/home/vboxweb/vm-status # If no status file exists then apparently there are no VMs to resume. if [ ! -f $STATUSFILE ]; then exit; fi while read VM; do sudo -H -u vboxweb vboxmanage startvm $VM --type headless done <$STATUSFILE
On server shutdown the created pausevms script worked well with the help of this link:
commands to configure shutdown script:
vi /etc/e-smith/events/actions/pausevms chmod +x /etc/e-smith/events/actions/pausevms ln -s /etc/e-smith/events/actions/pausevms /etc/e-smith/events/system-shutdown/S15pausevms
Same method used to configure resumevms on server reboot, but it didn’t work:
vi /etc/e-smith/events/actions/resumevms chmod +x /etc/e-smith/events/actions/resumevms ls -s /etc/e-smith/events/actions/resumevms /etc/e-smith/events/system-init/S99resumevms
kindly support how can I configure the resumevms script to auto run on sever reboot?