Changes

Jump to navigation Jump to search
no edit summary
Line 1: Line 1:  +
Contributions below contain instructions on how to install VirtualBox version 4 on fresh install SME Server v8 beta 6. Plus configuring phpVirtualBox to control (create, edit, remove) your virtual machine on its web interface. In addition, scripts to automatically start the vbox service and the virtual machines in case of power failure can be found at the end of this article.
 +
 +
 
<ol>
 
<ol>
 
   <li>Setup SME Server v8 beta 6.</li>
 
   <li>Setup SME Server v8 beta 6.</li>
Line 109: Line 112:  
</ol>
 
</ol>
   −
===Automatically Start Virtual Machine in case Power Failure===
+
 
 +
 
 +
===Automatically Start Virtual Machine in case of Power Failure===
    
<ol>
 
<ol>
Line 121: Line 126:  
vbox code should look like this:
 
vbox code should look like this:
 
<pre>
 
<pre>
# Virtual box machines to autostart<br/>
+
# Virtual box machines to autostart
# Example to start 2 machines<br/>
+
# Example to start 2 machines
#      VBOX_AUTOSTART = "MachineName1 MachineName2"<br/>
+
#      VBOX_AUTOSTART = "MachineName1 MachineName2"
 
<br/>
 
<br/>
VBOX_AUTOSTART="vmXP"<br/>
+
VBOX_AUTOSTART="vmXP"
 
</pre>
 
</pre>
    
<li>Edit your vbox file located on /etc/init.d/</li>
 
<li>Edit your vbox file located on /etc/init.d/</li>
 
<pre>
 
<pre>
#!/bin/sh<br/>
+
#!/bin/sh
 
#<br/>
 
#<br/>
# chkconfig: - 91 35<br/>
+
# chkconfig: - 91 35
# description: Starts and stops vbox autostart VMs.<br/>
+
# description: Starts and stops vbox autostart VMs.
<br/>
+
 
### BEGIN INIT INFO<br/>
+
### BEGIN INIT INFO
# Provides: vbox<br/>
+
# Provides: vbox
# Required-Start: $network $named $vboxdrv<br/>
+
# Required-Start: $network $named $vboxdrv
# Required-Stop: $network $named<br/>
+
# Required-Stop: $network $named
# Default-Start:<br/>
+
# Default-Start:
# Default-Stop: 0 1 2 3 4 5 6<br/>
+
# Default-Stop: 0 1 2 3 4 5 6
# Short-Description: Autostart some Virtual Box VMs<br/>
+
# Short-Description: Autostart some Virtual Box VMs
# Description: Autostart some Virtual Box VMs that are mentioned in /etc/sysconfig/vbox file<br/>
+
# Description: Autostart some Virtual Box VMs that are mentioned in /etc/sysconfig/vbox file
# Written by Alex Amiryan<br/>
+
# Written by Alex Amiryan
### END INIT INFO<br/>
+
### END INIT INFO
<br/>
+
 
. /etc/rc.d/init.d/functions<br/>
+
. /etc/rc.d/init.d/functions
<br/>
+
 
MANAGE_CMD=vboxmanage<br/>
+
MANAGE_CMD=vboxmanage
<br/>
+
 
[ -r /etc/sysconfig/vbox ] && . /etc/sysconfig/vbox<br/>
+
[ -r /etc/sysconfig/vbox ] && . /etc/sysconfig/vbox
<br/>
+
 
prog=$"Virtual Box Machines"<br/>
+
prog=$"Virtual Box Machines"
<br/>
+
 
start()<br/>
+
start()
{<br/>
+
{
         echo -n $"Starting $prog: "<br/>
+
         echo -n $"Starting $prog: "
         RETVAL=0<br/>
+
         RETVAL=0
<br/>
+
 
         for vbox_name in ${VBOX_AUTOSTART}<br/>
+
         for vbox_name in ${VBOX_AUTOSTART}
         do<br/>
+
         do
             SERVS=1<br/>
+
             SERVS=1
             echo -n "${vbox_name} "<br/>
+
             echo -n "${vbox_name} "
             daemon $MANAGE_CMD startvm "${vbox_name}" -type headless >/dev/null 2>&1<br/>
+
             daemon $MANAGE_CMD startvm "${vbox_name}" -type headless >/dev/null 2>&1
             RETVAL=$?<br/>
+
             RETVAL=$?
             [ "$RETVAL" -eq 0 ] || break<br/>
+
             [ "$RETVAL" -eq 0 ] || break
         done<br/>
+
         done
         if [ -z "$SERVS" ]; then<br/>
+
         if [ -z "$SERVS" ]; then
             echo -n "no virtual machines configured "<br/>
+
             echo -n "no virtual machines configured "
             failure<br/>
+
             failure
             RETVAL=6<br/>
+
             RETVAL=6
         else<br/>
+
         else
             if [ "$RETVAL" -eq 0 ]; then<br/>
+
             if [ "$RETVAL" -eq 0 ]; then
                 success $"vbox startup"<br/>
+
                 success $"vbox startup"
                 touch /var/lock/subsys/vbox<br/>
+
                 touch /var/lock/subsys/vbox
             else<br/>
+
             else
                 failure $"vbox start"<br/>
+
                 failure $"vbox start"
             fi<br/>
+
             fi
         fi<br/>
+
         fi
         echo<br/>
+
         echo
         return "$RETVAL"<br/>
+
         return "$RETVAL"
}<br/>
+
}
<br/>
+
 
stop()<br/>
+
stop()
{<br/>
+
{
         echo -n $"Shutting down $prog: "<br/>
+
         echo -n $"Shutting down $prog: "
         for vbox_name in ${VBOX_AUTOSTART}<br/>
+
         for vbox_name in ${VBOX_AUTOSTART}
         do<br/>
+
         do
             echo -n "${vbox_name} "<br/>
+
             echo -n "${vbox_name} "
             runuser root -c "$MANAGE_CMD -q controlvm "${vbox_name}" savestate" >/dev/null 2>&1<br/>
+
             runuser root -c "$MANAGE_CMD -q controlvm "${vbox_name}" savestate" >/dev/null 2>&1
         done<br/>
+
         done
         RETVAL=$?<br/>
+
         RETVAL=$?
         [ "$RETVAL" -eq 0 ] && success $"vbox shutdown" || \<br/>
+
         [ "$RETVAL" -eq 0 ] && success $"vbox shutdown" || \
             failure $"vbox shutdown"<br/>
+
             failure $"vbox shutdown"
         echo<br/>
+
         echo<
         [ "$RETVAL" -eq 0 ] && rm -f /var/lock/subsys/vbox<br/>
+
         [ "$RETVAL" -eq 0 ] && rm -f /var/lock/subsys/vbox
         return "$RETVAL"<br/>
+
         return "$RETVAL"
}<br/>
+
}
<br/>
+
 
status()<br/>
+
status()
{<br/>
+
{
         for vbox_name in ${VBOX_AUTOSTART}<br/>
+
         for vbox_name in ${VBOX_AUTOSTART}
         do<br/>
+
         do
             echo -n "${vbox_name} "<br/>
+
             echo -n "${vbox_name} "
             $MANAGE_CMD showvminfo "${vbox_name}"|grep "^State:\s*.*$"<br/>
+
             $MANAGE_CMD showvminfo "${vbox_name}"|grep "^State:\s*.*$"
         done<br/>
+
         done
}<br/>
+
}
<br/>
+
 
case "$1" in<br/>
+
case "$1" in
   start)<br/>
+
   start)
         start<br/>
+
         start
         ;;<br/>
+
         ;;
   stop)<br/>
+
   stop)
         stop<br/>
+
         stop
         ;;<br/>
+
         ;;
   restart|force-reload)<br/>
+
   restart|force-reload)
         stop<br/>
+
         stop
         start<br/>
+
         start
         ;;<br/>
+
         ;;
   status)<br/>
+
   status)
         status<br/>
+
         status
         ;;<br/>
+
         ;;
   *)<br/>
+
   *)
         echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2<br/>
+
         echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
         exit 3<br/>
+
         exit 3
         ;;<br/>
+
         ;;
esac<br/>
+
esac
 
</pre>
 
</pre>
 
</ol>
 
</ol>
75

edits

Navigation menu