Here is the latest script to download and install Virtualbox 3.2.4 non-ose version with USB support. Need to fix the the exit message if a user presses cancel during the download.
#!/bin/bash -l
# getvirtualbox
#
# Purpose: install the latest VirtualBox into PCLinuxOS
#
# Requirements:
# - PCLinuxOS installation
# - working apt-get & Internet connection (not for removal)
# - zenity, wget, libpython2.5-devel
#
# Version: 3.2.4 (2010-06-09)
#
# Copyright (C) 2010 Bill Reynolds <texstar@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# define some variables
#=================================================
TITLE="GetVirtualBox 3.2.4"
package="VirtualBox-3.2.4-62467-Linux_x86.run"
source="http://download.virtualbox.org/virtualbox/3.2.4/"$package
ZEN2="zenity"
SCRIPT_PID=$$
# Function to kill child processes of this script (wget, sed, zenity, etc)
# ..naming it kill_child just doesn't seem right ;)
#=================================================
function exit_kill {
echo "Killing all child processes of script.. (script pid: $SCRIPT_PID)"
# check output of ps command for pids that have parent pids (ppid) matching this scripts pid
for child in $(ps axo ucmd,pid,ppid | awk "{ if ( \$3 == $SCRIPT_PID ) { print \$2 }}")
do
echo "Killing child process $child because ppid = $SCRIPT_PID"
kill -9 $child 2>/dev/null
done
}
# check for working internet connection
#=================================================
cd /tmp
/bin/rm -f index.html inet.log VirtualBox*
MSG=$"Testing your Internet connection..."
( wget --timeout=15 http://www.google.com/index.html -o inet.log ) 2>&1 | $ZEN2 --title="$TITLE" --progress --text "$MSG" --pulsate --auto-close
if [ ! -f /tmp/index.html ]; then
MSG=$"No Internet connection found.\n\nExiting..."
$ZEN2 --title="$TITLE" --error --text "$MSG"
/bin/rm -f index.html inet.log
exit 0
fi
# clean up and make sure no partial downloads exist in /tmp
/bin/rm -f index.html inet.log VirtualBox*
# download VirtualBox
#=================================================
wget $source 2>&1 | sed -u 's/.* \([0-9]\+%\)\ \+\([0-9.]\+.\) \(.*\)/\1\n# Downloading at \2\/s\\nETA \3/' | (if `$ZEN2 --width 400 --progress --title="$TITLE" --auto-close`;
then
echo 'Job completed'
else
exit_kill $SCRIPT_PID
# for less verbosity, the following one-liner could replace the exit_kill function:
# kill -9 `ps axo ucmd,pid,ppid | awk "{ if ( \$3 == $THIS_PID ) { print \$2 }}"`
fi)
#make file executable
#=================================================
chmod a+x $package
# run the installer
#=================================================
MSG=$"Installing VirtualBox. Please be patient..."
( sh $package ) 2>&1 | $ZEN2 --width 500 --title="$TITLE" --progress --text "$MSG" --pulsate --auto-close
# Create usb group if it doesn't exist, won't hurt if usb group already exists
#=================================================
groupadd usb
# Virtualbox installer automatically adds vboxusers group, yaa
#=================================================
# add users to group vboxusers and usb
#=================================================
SYSUSERS=`cat /etc/passwd | grep "/home/.*/bash" |grep "[0-9][0-9][0-9]" |cut -d: -f1`
for idx in $SYSUSERS; do usermod -a -G vboxusers,usb $idx; done
# Remove created symlink and make actual desktop file
#=================================================
if [ -f /usr/share/applications/virtualbox.desktop ]; then
/bin/rm -rf /usr/share/applications/virtualbox.desktop
fi
# create menu entry for PCLinuxOS
#=================================================
cat >/usr/share/applications/virtualbox.desktop << EOF
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Name=Oracle VM VirtualBox
GenericName=Virtual Machine
Type=Application
Exec=VirtualBox
TryExec=VirtualBox
DocPath=file:///opt/VirtualBox/UserManual.pdf
Icon=VBox
Categories=Emulator;System;X-MandrivaLinux-MoreApplications-Emulators;
Comment=Run several virtual systems on a single host computer
EOF
# clean up
#=================================================
/bin/rm -f $package
# the end
#=================================================
MSG=$"VirtualBox is now available from the menu under\nPCmenu -> More Applications -> Emulators.\n\nHave fun\!"
$ZEN2 --width 500 --title="$TITLE" --info --text="$MSG"
exit 0