Thanks Richard! here I answer your questions… (sorry I coulnd answer before but too much work at job:|)
Here it is:
chkconfig -l vboxes
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
vboxes 0:off 1:off 2:off 3:on 4:off 5:on 6:off
Done…
Remember that I have an user I create called vbox where I run the machines, so, I think… the script should be run as this user?
Done…
I have vboxes service running since the server boot up, so… is it alright to run the /var/tmp/vboxes status?
What user should I use to test the /var/temp/vboxes status?
(also I have two machines now configured to autostartup with vboxes)
quahog:~ # cat /etc/sysconfig/vbox
# Virtual box machines to autostart
# Example to start 2 machines
# VBOX_AUTOSTART = "MachineName1 MachineName2"
# VBOX_AUTOSTART=""
VBOX_AUTOSTART="win2003;vbox winxpfirmas;vbox"
I tried to run it with both root and vbox user, here is the output:
**quahog:~ # /var/tmp/vboxes status**
redirecting to systemctl
+ VBOXMGR_BIN=/usr/lib/virtualbox/VBoxManage
+ ! -x /usr/lib/virtualbox/VBoxManage ]]
+ VBOXHeadLess_BIN=/usr/lib/virtualbox/VBoxHeadless
+ ! -x /usr/lib/virtualbox/VBoxHeadless ]]
++ basename /var/tmp/vboxes
+ PRG=vboxes
+ SERVICE='Virtualbox machines'
+ '' -r /etc/sysconfig/vbox ']'
+ . /etc/sysconfig/vbox
++ VBOX_AUTOSTART='win2003;vbox winxpfirmas;vbox'
+ case "$1" in
+ status
+ for VBOX in '$VBOX_AUTOSTART'
+ grep -q ';'
++ cut '-d;' -f2
+ VBOX_USER=vbox
+ grep -qw vbox
+ VBOX_USERS=' vbox'
+ for VBOX in '$VBOX_AUTOSTART'
+ grep -q ';'
++ cut '-d;' -f2
+ VBOX_USER=vbox
+ grep -qw vbox
+ N=1
+ for VBOX_USER in '$VBOX_USERS'
++ su vbox -c '/usr/lib/virtualbox/VBoxManage list --long runningvms'
++ sed -n 's/^Name::blank:]]\{7\} *//p'
+ VBOX_RUNNING='win2003
winxpfirmas'
+ for VBOX in '$VBOX_RUNNING'
+ VBOX_NAME$N]=win2003
+ VBOX_USER$N]=vbox
+ N=2
+ for VBOX in '$VBOX_RUNNING'
+ VBOX_NAME$N]=winxpfirmas
+ VBOX_USER$N]=vbox
+ N=3
+ VBOXES=2
+ 2 -eq 0 ]]
+ N=1
+ 1 -le 2 ]]
++ su vbox -c '/usr/lib/virtualbox/VBoxManage showvminfo win2003'
++ sed 's/\([0-9][0-9]\)\.[0-9]\{9\}/\1/;s/\([0-9][0-9]\)T\([0-9][0-9]\)/\1 \2/'
++ sed -n 's/State: *//p'
+ STATE='running (since 2013-01-30 21:06:55)'
+ printf ' %-56s %s' 'win2003 (user: vbox):' 'running (since 2013-01-30 21:06:55)'
win2003 (user: vbox): running (since 2013-01-30 21:06:55)+ rc_status -v
+ rc_check
+ _rc_status_ret=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ _rc_status_ret=0
+ local i
+ for i in '"$@"'
+ case "$i" in
+ local vrt=
+ local out=1
+ local opt=en
+ test -n ''
+ opt=e
+ case "$_rc_status" in
+ vrt=' running'
+ echo -e '' running
running
+ _rc_status=0
+ return 0
+ N=2
+ 2 -le 2 ]]
++ su vbox -c '/usr/lib/virtualbox/VBoxManage showvminfo winxpfirmas'
++ sed 's/\([0-9][0-9]\)\.[0-9]\{9\}/\1/;s/\([0-9][0-9]\)T\([0-9][0-9]\)/\1 \2/'
++ sed -n 's/State: *//p'
+ STATE='running (since 2013-01-30 21:06:55)'
+ printf ' %-56s %s' 'winxpfirmas (user: vbox):' 'running (since 2013-01-30 21:06:55)'
winxpfirmas (user: vbox): running (since 2013-01-30 21:06:55)+ rc_status -v
+ rc_check
+ _rc_status_ret=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ _rc_status_ret=0
+ local i
+ for i in '"$@"'
+ case "$i" in
+ local vrt=
+ local out=1
+ local opt=en
+ test -n ''
+ opt=e
+ case "$_rc_status" in
+ vrt=' running'
+ echo -e '' running
running
+ _rc_status=0
+ return 0
+ N=3
+ 3 -le 2 ]]
(OK! I understand, if I run it as vbox… it will ask for root password somewhere in the middle of the vboxes script because it is supposed to be run as root, so I wont post the output of running as vbox user…)
OK, this is the output: (da#n this way it works wonderful )
quahog:~ # /var/tmp/vboxes stop
redirecting to systemctl
+ VBOXMGR_BIN=/usr/lib/virtualbox/VBoxManage
+ ! -x /usr/lib/virtualbox/VBoxManage ]]
+ VBOXHeadLess_BIN=/usr/lib/virtualbox/VBoxHeadless
+ ! -x /usr/lib/virtualbox/VBoxHeadless ]]
++ basename /var/tmp/vboxes
+ PRG=vboxes
+ SERVICE='Virtualbox machines'
+ '' -r /etc/sysconfig/vbox ']'
+ . /etc/sysconfig/vbox
++ VBOX_AUTOSTART='win2003;vbox winxpfirmas;vbox'
+ case "$1" in
+ stop
+ for VBOX in '$VBOX_AUTOSTART'
+ grep -q ';'
++ cut '-d;' -f2
+ VBOX_USER=vbox
+ grep -qw vbox
+ VBOX_USERS=' vbox'
+ for VBOX in '$VBOX_AUTOSTART'
+ grep -q ';'
++ cut '-d;' -f2
+ VBOX_USER=vbox
+ grep -qw vbox
+ N=1
+ for VBOX_USER in '$VBOX_USERS'
++ su vbox -c '/usr/lib/virtualbox/VBoxManage list --long runningvms'
++ sed -n 's/^Name::blank:]]\{7\} *//p'
+ VBOX_RUNNING='win2003
winxpfirmas'
+ for VBOX in '$VBOX_RUNNING'
+ VBOX_NAME$N]=win2003
+ VBOX_USER$N]=vbox
+ N=2
+ for VBOX in '$VBOX_RUNNING'
+ VBOX_NAME$N]=winxpfirmas
+ VBOX_USER$N]=vbox
+ N=3
+ VBOXES=2
+ 2 -eq 0 ]]
+ echo -n 'Shutting down Virtualbox machines: '
Shutting down Virtualbox machines: + N=1
+ 1 -le 2 ]]
+ 1 -lt 2 ]]
+ echo -n 'win2003 (user: vbox), '
win2003 (user: vbox), + N=2
+ 2 -le 2 ]]
+ 2 -lt 2 ]]
+ echo 'winxpfirmas (user: vbox)'
winxpfirmas (user: vbox)
+ N=3
+ 3 -le 2 ]]
+ N=1
+ 1 -le 2 ]]
+ echo -n ' win2003: '
win2003: + su vbox -c '/usr/lib/virtualbox/VBoxManage -q controlvm win2003 savestate'
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
+ RETVAL=0
+ echo -n ' Shutting down virtual machine: win2003 (user: vbox)'
Shutting down virtual machine: win2003 (user: vbox)+ 0 == 0 ]]
+ rc_status -v -r
+ rc_check
+ _rc_status_ret=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ test 0 -gt 7
+ _rc_status_ret=0
+ case "$_rc_todo" in
+ test 0 -eq 7
+ local i
+ for i in '"$@"'
+ case "$i" in
+ local vrt=
+ local out=1
+ local opt=en
+ test -n ''
+ opt=e
+ case "$_rc_status" in
+ vrt=' done'
+ echo -e '' done
done
+ _rc_status=0
+ for i in '"$@"'
+ case "$i" in
+ rc_reset
+ _rc_status=0
+ _rc_status_all=0
+ rc_check
+ _rc_status_ret=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ return 0
+ return 0
+ N=2
+ 2 -le 2 ]]
+ echo -n ' winxpfirmas: '
winxpfirmas: + su vbox -c '/usr/lib/virtualbox/VBoxManage -q controlvm winxpfirmas savestate'
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
+ RETVAL=0
+ echo -n ' Shutting down virtual machine: winxpfirmas (user: vbox)'
Shutting down virtual machine: winxpfirmas (user: vbox)+ 0 == 0 ]]
+ rc_status -v -r
+ rc_check
+ _rc_status_ret=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ test 0 -gt 7
+ _rc_status_ret=0
+ case "$_rc_todo" in
+ test 0 -eq 7
+ local i
+ for i in '"$@"'
+ case "$i" in
+ local vrt=
+ local out=1
+ local opt=en
+ test -n ''
+ opt=e
+ case "$_rc_status" in
+ vrt=' done'
+ echo -e '' done
done
+ _rc_status=0
+ for i in '"$@"'
+ case "$i" in
+ rc_reset
+ _rc_status=0
+ _rc_status_all=0
+ rc_check
+ _rc_status_ret=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ return 0
+ return 0
+ N=3
+ 3 -le 2 ]]
Both virtual machines savestate fine now! but if I shutdonw or reboot the server, both machines wont savestate. could it be what **Tsu2 **says? (will try to undertand that :sarcastic:)
Thank you very much for the free help you are giving!