[aklug] VirtualBox Scripts

From: James Tweet <jamestweet@yahoo.com>
Date: Fri Mar 06 2009 - 10:52:09 AKST

Here are a couple of scripts I created to help me with my VirtualBox drive images. Once I created the scripts. I used the Nautilus Actions Configuration utility to associate these scripts with VDI files. Now I can just right click on a VDI file and execute either of these scripts.

First script I called CopyVDI. It makes a copy of the VDI file so you can make a clone of a virtual machine. The cloned VDI file is called clone.vdi

################################################################
#! /bin/bash
file="$1";
dir="${file%/*}";

cd "$dir"
RT=""

/usr/lib/virtualbox/VBoxManage clonevdi "$file" clone.vdi >.err.txt;

if [ $? = 0 ]; then

    zenity --info --text="VDI Copy Complete"
else
    RT="VDI Copy Failed"
    while read line
    do
    RT=$RT"\n"$line
    done <.err.txt
    zenity --info --title="VDI Copy Failed" --no-wrap --text="$RT"
fi
unlink .err.txt
################################################################

The second script I called ImmutableVDI. This will convert the registration of a VDI file to immutable.

################################################################
#! /bin/bash
file="$1";
dir="${file%/*}";

cd "$dir"
RT=""

/usr/lib/virtualbox/VBoxManage unregisterimage disk "$file" >.err.txt;

if [ $? = 0 ]; then

    /usr/lib/virtualbox/VBoxManage registerimage disk "$file" -type immutable >>.err.txt;
    
    if [ $? = 0 ]; then
        zenity --info --text="VDI Immutable Complete"
    else
        RT="VDI Immutable Failed"
        while read line
        do
        RT=$RT"\n"$line
        done <.err.txt
        zenity --info --title="VDI Immutable Failed" --no-wrap --text="$RT"
    fi
else
    RT="VDI Immutable Failed"
    while read line
    do
    RT=$RT"\n"$line
    done <.err.txt
    zenity --info --title="VDI Immutable Failed" --no-wrap --text="$RT"
fi
unlink .err.txt
################################################################

I hope you will find these useful.

James

---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Fri Mar 6 10:52:19 2009

This archive was generated by hypermail 2.1.8 : Fri Mar 06 2009 - 10:52:19 AKST