- smaller fixed and improvements: correct web port, on-demand VDI conversion only
authorJosef Spillner <josef@bomba-ssd>
Sun, 13 Apr 2014 15:38:15 +0000 (17:38 +0200)
committerJosef Spillner <josef@bomba-ssd>
Sun, 13 Apr 2014 15:38:15 +0000 (17:38 +0200)
createvbox.sh

index 36907a0..6b26a91 100755 (executable)
@@ -3,7 +3,8 @@
 # Syntax: createvbox.sh [<vdi>] [<name>] [start]
 
 vdi=$PWD/nubigate-unreleased.vdi
 # Syntax: createvbox.sh [<vdi>] [<name>] [start]
 
 vdi=$PWD/nubigate-unreleased.vdi
-vmname="NubiGate"
+img=$PWD/nubigate-unreleased.img
+vmname="NubiGate Unreleased"
 if [ ! -z $1 ] && [ "$1" != "start" ]; then
        vdi=$1
        shift
 if [ ! -z $1 ] && [ "$1" != "start" ]; then
        vdi=$1
        shift
@@ -15,9 +16,19 @@ fi
 autostart=$1
 
 if [ "$vdi" = "$PWD/nubigate-unreleased.vdi" ]; then
 autostart=$1
 
 if [ "$vdi" = "$PWD/nubigate-unreleased.vdi" ]; then
-       if [ -f nubigate-unreleased.img ]; then
-               rm -f nubigate-unreleased.vdi
-               VBoxManage convertfromraw -format VDI nubigate-unreleased.img "$vdi"
+       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 nubigate-unreleased.vdi
+                       VBoxManage convertfromraw -format VDI "$img" "$vdi"
+               fi
        else
                echo "Error: Need to run createimg.sh first." >&2
                exit 1
        else
                echo "Error: Need to run createimg.sh first." >&2
                exit 1
@@ -48,7 +59,7 @@ if [ $? -ne 0 ]; then
        VBoxManage modifyvm "$vmname" --vrdeauthtype external
        VBoxManage modifyvm "$vmname" --vrdeport $((baseport))
        redir ssh 22 $(($baseport+1))
        VBoxManage modifyvm "$vmname" --vrdeauthtype external
        VBoxManage modifyvm "$vmname" --vrdeport $((baseport))
        redir ssh 22 $(($baseport+1))
-       redir web 22 $(($baseport+2))
+       redir web 80 $(($baseport+2))
        redir tomcat 8080 $(($baseport+3))
        baseport=$(($baseport+10))
        echo $baseport > ~/.vboxautoconfig
        redir tomcat 8080 $(($baseport+3))
        baseport=$(($baseport+10))
        echo $baseport > ~/.vboxautoconfig
@@ -68,4 +79,3 @@ if [ "$autostart" = "start" ]; then
                VBoxHeadless --startvm "$vmname"
        fi
 fi
                VBoxHeadless --startvm "$vmname"
        fi
 fi
-