- experimental support for launching VDIs with VirtualBox (which support multiple...
authorJosef Spillner <josef@bomba-ssd>
Sun, 13 Apr 2014 16:21:29 +0000 (18:21 +0200)
committerJosef Spillner <josef@bomba-ssd>
Sun, 13 Apr 2014 16:21:29 +0000 (18:21 +0200)
createvbox.sh [deleted file]
integration/createvbox.sh [new file with mode: 0755]
integration/nubigate
integration/run-nubigate-vm.sh

diff --git a/createvbox.sh b/createvbox.sh
deleted file mode 100755 (executable)
index dd425e9..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-#!/bin/sh
-#
-# Syntax: createvbox.sh [<vdi>] [<name>] [start]
-
-vdi=$PWD/nubigate-unreleased.vdi
-img=$PWD/nubigate-unreleased.img
-vmname="NubiGate Unreleased"
-if [ ! -z $1 ] && [ "$1" != "start" ]; then
-       vdi=$1
-       shift
-fi
-if [ ! -z $1 ] && [ "$1" != "start" ]; then
-       vmname=$1
-       shift
-fi
-autostart=$1
-
-if [ "$vdi" = "$PWD/nubigate-unreleased.vdi" ]; then
-       if [ -f $img ]; then
-               mustconvert=1
-               if [ -f $vdi ]; then
-                       stampvdi=`stat --format=%Y $vdi`
-                       stampimg=`stat --format=%Y $img`
-                       if [ $stampimg -lt $stampvdi ]; then
-                               mustconvert=0
-                       fi
-               fi
-               if [ $mustconvert -eq 1 ]; then
-                       rm -f $vdi
-                       VBoxManage convertfromraw -format VDI "$img" "$vdi"
-               fi
-       else
-               echo "Error: Raw image file $img not found. Need to run createimg.sh or download script first." >&2
-               exit 1
-       fi
-fi
-
-# redir(protocol,guestport,hostport)
-redir()
-{
-       adapter=e1000 # pcnet
-
-       VBoxManage setextradata "$vmname" "VBoxInternal/Devices/$adapter/0/LUN#0/Config/$1/Protocol" TCP
-       VBoxManage setextradata "$vmname" "VBoxInternal/Devices/$adapter/0/LUN#0/Config/$1/GuestPort" $2
-       VBoxManage setextradata "$vmname" "VBoxInternal/Devices/$adapter/0/LUN#0/Config/$1/HostPort" $3
-}
-
-VBoxManage list vms | grep -q "$vmname"
-if [ $? -ne 0 ]; then
-       # FIXME: Debian_64 depending on the architecture
-       VBoxManage createvm --name "$vmname" --ostype Debian_64 --register
-       VBoxManage modifyvm "$vmname" --memory 2048 --cpus 4
-       VBoxManage storagectl "$vmname" --name SATA-Controller --add sata
-
-       baseport=10000
-       if [ -f ~/.vboxautoconfig ]; then
-               baseport=`cat ~/.vboxautoconfig`
-       fi
-       VBoxManage modifyvm "$vmname" --vrdeauthtype external
-       VBoxManage modifyvm "$vmname" --vrdeport $((baseport))
-       redir ssh 22 $(($baseport+1))
-       redir web 80 $(($baseport+2))
-       redir tomcat 8080 $(($baseport+3))
-       baseport=$(($baseport+10))
-       echo $baseport > ~/.vboxautoconfig
-else
-       VBoxManage discardstate "$vmname"
-       VBoxManage storageattach "$vmname" --storagectl SATA-Controller --port 0 --device 0 --medium none
-       VBoxManage closemedium disk $vdi
-fi
-
-VBoxManage storageattach "$vmname" --storagectl SATA-Controller --port 0 --device 0 --medium "$vdi" --type hdd
-
-if [ "$autostart" = "start" ]; then
-       ps a | grep -v grep | grep -q /usr/bin/X
-       if [ $? = 0 ]; then
-               virtualbox --fullscreen --startvm "$vmname"
-       else
-               VBoxHeadless --startvm "$vmname"
-       fi
-fi
diff --git a/integration/createvbox.sh b/integration/createvbox.sh
new file mode 100755 (executable)
index 0000000..dd425e9
--- /dev/null
@@ -0,0 +1,81 @@
+#!/bin/sh
+#
+# Syntax: createvbox.sh [<vdi>] [<name>] [start]
+
+vdi=$PWD/nubigate-unreleased.vdi
+img=$PWD/nubigate-unreleased.img
+vmname="NubiGate Unreleased"
+if [ ! -z $1 ] && [ "$1" != "start" ]; then
+       vdi=$1
+       shift
+fi
+if [ ! -z $1 ] && [ "$1" != "start" ]; then
+       vmname=$1
+       shift
+fi
+autostart=$1
+
+if [ "$vdi" = "$PWD/nubigate-unreleased.vdi" ]; then
+       if [ -f $img ]; then
+               mustconvert=1
+               if [ -f $vdi ]; then
+                       stampvdi=`stat --format=%Y $vdi`
+                       stampimg=`stat --format=%Y $img`
+                       if [ $stampimg -lt $stampvdi ]; then
+                               mustconvert=0
+                       fi
+               fi
+               if [ $mustconvert -eq 1 ]; then
+                       rm -f $vdi
+                       VBoxManage convertfromraw -format VDI "$img" "$vdi"
+               fi
+       else
+               echo "Error: Raw image file $img not found. Need to run createimg.sh or download script first." >&2
+               exit 1
+       fi
+fi
+
+# redir(protocol,guestport,hostport)
+redir()
+{
+       adapter=e1000 # pcnet
+
+       VBoxManage setextradata "$vmname" "VBoxInternal/Devices/$adapter/0/LUN#0/Config/$1/Protocol" TCP
+       VBoxManage setextradata "$vmname" "VBoxInternal/Devices/$adapter/0/LUN#0/Config/$1/GuestPort" $2
+       VBoxManage setextradata "$vmname" "VBoxInternal/Devices/$adapter/0/LUN#0/Config/$1/HostPort" $3
+}
+
+VBoxManage list vms | grep -q "$vmname"
+if [ $? -ne 0 ]; then
+       # FIXME: Debian_64 depending on the architecture
+       VBoxManage createvm --name "$vmname" --ostype Debian_64 --register
+       VBoxManage modifyvm "$vmname" --memory 2048 --cpus 4
+       VBoxManage storagectl "$vmname" --name SATA-Controller --add sata
+
+       baseport=10000
+       if [ -f ~/.vboxautoconfig ]; then
+               baseport=`cat ~/.vboxautoconfig`
+       fi
+       VBoxManage modifyvm "$vmname" --vrdeauthtype external
+       VBoxManage modifyvm "$vmname" --vrdeport $((baseport))
+       redir ssh 22 $(($baseport+1))
+       redir web 80 $(($baseport+2))
+       redir tomcat 8080 $(($baseport+3))
+       baseport=$(($baseport+10))
+       echo $baseport > ~/.vboxautoconfig
+else
+       VBoxManage discardstate "$vmname"
+       VBoxManage storageattach "$vmname" --storagectl SATA-Controller --port 0 --device 0 --medium none
+       VBoxManage closemedium disk $vdi
+fi
+
+VBoxManage storageattach "$vmname" --storagectl SATA-Controller --port 0 --device 0 --medium "$vdi" --type hdd
+
+if [ "$autostart" = "start" ]; then
+       ps a | grep -v grep | grep -q /usr/bin/X
+       if [ $? = 0 ]; then
+               virtualbox --fullscreen --startvm "$vmname"
+       else
+               VBoxHeadless --startvm "$vmname"
+       fi
+fi
index 810edef..0693505 100755 (executable)
@@ -53,9 +53,11 @@ class NubiGatePanel(QtGui.QDialog):
                vlayout.addLayout(hlayout)
                vlayout.addWidget(self.button_stop)
 
-               self.path_system = "/var/lib/nubigate/nubigate-unreleased.img"
+               #self.imagefile = "nubigate-unreleased.img"
+               self.imagefile = "nubigate-unreleased.vdi"
+               self.path_system = "/var/lib/nubigate/" + self.imagefile
                self.dir_user = os.path.join(os.getenv("HOME"), ".nubigate")
-               self.path_user = os.path.join(self.dir_user, "nubigate-unreleased.img")
+               self.path_user = os.path.join(self.dir_user, self.imagefile)
                self.path = None
 
                if os.path.isfile(self.path_user):
@@ -131,7 +133,7 @@ class NubiGatePanel(QtGui.QDialog):
 
                self.nam = QtNetwork.QNetworkAccessManager()
 
-               self.req = self.nam.get(QtNetwork.QNetworkRequest(QtCore.QUrl("http://nubisave.org/downloads/nubigate-unreleased.img")))
+               self.req = self.nam.get(QtNetwork.QNetworkRequest(QtCore.QUrl("http://nubisave.org/downloads/" + self.imagefile)))
                self.connect(self.req, QtCore.SIGNAL("finished()"), self, QtCore.SLOT("slot_finished()"))
                self.connect(self.req, QtCore.SIGNAL("downloadProgress(qint64,qint64)"), self, QtCore.SLOT("slot_progress(qint64,qint64)"))
                self.connect(self.req, QtCore.SIGNAL("readyRead()"), self, QtCore.SLOT("slot_ready()"))
index 8905d31..b099c16 100755 (executable)
@@ -1,13 +1,15 @@
 #!/bin/sh
 
 img=$1
+baseimg=`basename $1`
+
 if [ ! -f $img ] || [ -z $img ]; then
        echo "VM $img not found; trying next"
-       img=/var/cache/nubigate/nubigate-unreleased.img
+       img=/var/cache/nubigate/$baseimg
 fi
 if [ ! -f $img ]; then
        echo "VM $img not found; trying next"
-       img=$HOME/.nubigate/nubigate-unreleased.img
+       img=$HOME/.nubigate/$baseimg
 fi
 if [ ! -f $img ]; then
        echo "VM $img not found; giving up"
@@ -15,21 +17,27 @@ if [ ! -f $img ]; then
 fi
 echo "Booting VM $img..."
 
-bridging=0
-
-if [ "$bridging" = "1" ]; then
-       sudo /sbin/brctl addbr br0
-       mac=`printf 'DE:AD:BE:EF:%02X:%02X\n' $((RANDOM%256)) $((RANDOM%256))`
-fi
+isvdi=`echo $baseimg | grep -q vdi`
 
-if [ "$bridging" = "1" ]; then
-       kvm -smp 2 -m 1024 \
-               -device e1000,netdev=net0,mac=$mac -netdev tap,id=net0,script=$PWD/qemu-ifup \
-               $img
+if [ $isvdi -eq 0 ]; then
+       $PWD/createvbox.sh $img start
 else
-       kvm -smp 2 -m 1024 \
-               -device e1000,netdev=user.0 -netdev user,id=user.0,hostfwd=tcp::10080-:80 \
-               $img
+       bridging=0
+
+       if [ "$bridging" = "1" ]; then
+               sudo /sbin/brctl addbr br0
+               mac=`printf 'DE:AD:BE:EF:%02X:%02X\n' $((RANDOM%256)) $((RANDOM%256))`
+       fi
+
+       if [ "$bridging" = "1" ]; then
+               kvm -smp 2 -m 1024 \
+                       -device e1000,netdev=net0,mac=$mac -netdev tap,id=net0,script=$PWD/qemu-ifup \
+                       $img
+       else
+               kvm -smp 2 -m 1024 \
+                       -device e1000,netdev=user.0 -netdev user,id=user.0,hostfwd=tcp::10080-:80 \
+                       $img
+       fi
 fi
 
 #      -device e1000,netdev=user.0 -netdev user,id=user.0,hostfwd=tcp::10022-:22 \