- #!/bin/ash
- #110612 TazOC Based on install_virtualbox.sh by jamesbond 2011.02.11
- #110810 Improved the extension pack installer to dl the latest version
- #130311 Increased free space test to 220MiB
- #130319 TaZoC pfix=noautosave PUPMODE=14,15 (savefile writes on user request only.)
- APPTITLE="VirtualBox_Installer"
- APPNAME="virtualbox"
- ICON="/usr/share/icons/virtualbox.png"
- . /etc/DISTRO_SPECS
- . /etc/rc.d/PUPSTATE
- export LANG=C
- [ -f /etc/issue.net ] && [ "`grep Lighthouse /etc/issue.net`" ] && VERSION="`cat /etc/issue.net | tr -d '\n'`"
- [ -z "$VERSION" ] && VERSION="$DISTRO_NAME $DISTRO_VERSION"
- if [ -z "`echo $VERSION | grep 'Lighthouse64'`" ]; then # Test for L64 version
- ICON="/usr/local/lib/X11/pixmaps/info.xpm"
- MSG="\n This Pet requires Lighthouse 64.\n\n
- As $VERSION was detected the Pet \n may not work as intended and should be uninstalled\n with Puppy Package Manager. \n"
- Xdialog --title "$APPTITLE" --wmclass "$APPNAME" \
- --icon $ICON --left --cancel-label "Exit" \
- --left --msgbox "$MSG" 0 0 0
- exit
- fi
- f=`df -m / |tail -n1|tr -s ' ' | cut -d ' ' -f4`
- if [ $f -lt 220 ];then # TazOC #130311
- ICON="/usr/local/lib/X11/pixmaps/info.xpm"
- MSG="\n There is not enough free space to run $APPTITLE. \n\n Need: 220 MiB, have: $f MiB. \n"
- Xdialog --title "$APPTITLE" --wmclass $APPNAME --icon "$ICON" --left --msgbox "$MSG" 0 0 0
- exit 1
- fi
- if ! which make || ! which gcc; then
- Xdialog --title "$APPTITLE" --wmclass $APPNAME --icon "$ICON" --left --msgbox "\n make or gcc not found. Please install Devx-${DISTRO_FILE_PREFIX}_${DISTRO_VERSION}.sfs first. \n" 0 0 0
- exit 1
- fi
- if [ "$1" != "--noprompt" ]; then
- Xdialog --title "$APPTITLE" --wmclass $APPNAME --icon "$ICON" --no-buttons --left --yesno "\n Would you like to download and install the latest version? \n" 0 0 0
- case $? in
- 0) ;;
- 1) exit 0 ;; # Pressed cancel, end script
- 255) exit 0 ;; # Box closed, end script
- esac
- fi
- Xdialog --title "$APPTITLE" --wmclass $APPNAME --icon "$ICON" --no-buttons --left --msgbox "\n Downloading, please wait... \n" 0 0 0 &
- PID=$!
- cd /tmp
- TMPFILE=$(mktemp)
- wget -O $TMPFILE http://dlc.sun.com/virtualbox/LATEST.TXT
- VERSION=$(cat $TMPFILE)
- wget -O $TMPFILE http://dlc.sun.com/virtualbox/$VERSION/
- FILE=$(sed -n '/amd64\.run/ {s/^.*"\(V.*_amd64.run\)".*$/\1/;p}' $TMPFILE | tail -1)
- EXTPACK=$(sed -n '/vbox-extpack/ {s/^.*"\(O.*vbox-extpack\)".*$/\1/;p}' $TMPFILE | tail -1)
- rm $TMPFILE
- [ "`which zenity`" ] && kill $PID
- wget -nd -c --read-timeout=300 --retry-connrefused --header "Accept-Encoding: gzip,deflate" "http://dlc.sun.com/virtualbox/$VERSION/$EXTPACK" 2>&1 | sed -u 's/.*\ \([0-9]\+%\)\ /\1\n# Downloading /' | zenity --width 620 --progress --auto-close --title="Downloading $EXTPACK to /tmp..."
- sleep .1
- wget -nd -c --read-timeout=300 --retry-connrefused --header "Accept-Encoding: gzip,deflate" "http://dlc.sun.com/virtualbox/$VERSION/$FILE" 2>&1 | sed -u 's/.*\ \([0-9]\+%\)\ /\1\n# Downloading /' | zenity --width 620 --progress --auto-close --title="Downloading $FILE to /tmp..." &
- PID=$!
- sleep .2
- [ "$PID" = "" ] && PID=`pidof zenity`
- # If user exits zenity progress box, kill wget
- while [ "$(ps | sed -e 's%^ *%%' | grep "$PID" | grep -v 'grep')" ]
- do
- sleep 1
- done
- sleep .1
- WGET_PID="$(ps l | tr -s ' ' | grep -E "wget.*VirtualBox" | grep -v 'grep' | cut -f3 -d' ')"
- if [ "$WGET_PID" ]; then
- kill $WGET_PID
- Xdialog --title "$APPTITLE" --wmclass $APPTITLE --left --no-buttons --msgbox "\n The download was interrupted. \n\n The partial download can be resumed later by restarting the installer. \n" 0 0 0 &
- exit 1
- fi
- sync
- chmod +x $FILE
- if [ -e /tmp/${EXTPACK} ]; then
- rm -fR /opt/VirtualBox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack
- mkdir -p /opt/VirtualBox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack
- cd /opt/VirtualBox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack
- tar -zxf /tmp/${EXTPACK}
- sleep .1
- cd ..
- chown -R root:root .
- cd /tmp
- fi
- [ -z "`which zenity`" ] && kill $PID
- Xdialog --title "$APPTITLE" --wmclass $APPNAME --icon "$ICON" --left --no-buttons --msgbox "\n Installing, this will take a while... \n\n Please wait until the terminal window finishes, \n then click on it and press <Enter> to continue. \n" 0 0 0 &
- PID=$!
- ./$FILE
- kill $PID
- mkdir -p "$HOME/.VirtualBox"
- cp -f /usr/local/VirtualBox_Installer/virtualbox-uninstaller.desktop /usr/share/applications/
- if [ -z "$(echo $PUPMODE | grep -E '12|13|14|15')" ]; then #130319
- Xdialog --title "$APPTITLE" --wmclass $APPNAME --icon "$ICON" --left --msgbox "\n Done. The installer is stored at /tmp/$FILE \n in case you want to keep it. \n\n VirtualBox can be started from the System Menu | Oracle VM VirtualBox. \n" 0 0 0
- else
- Xdialog --title "$APPTITLE" --wmclass $APPNAME --icon "$ICON" --left --yesno "\n OK, the installer is stored at /tmp/$FILE \n in case you want to keep it. \n\n VirtualBox can be started from the System Menu | Oracle VM VirtualBox. \n\n Would you like use frugal-symlink to move and link '$HOME/.VirtualBox' outside \n the ${DISTRO_FILE_PREFIX}save file? This directory will contain a large .vdi (virtual disk image) \n for each OS to be installed. \n" 0 0 0
- retval=$?
- case $retval in
- 0) if [ -s /etc/${DISTRO_FILE_PREFIX}/frugal-symlink ]; then
- # If f-s was disabled prior, need to re-enable...
- [ "`head -1 /etc/${DISTRO_FILE_PREFIX}/frugal-symlink`" != 'YES' ] && frugal-symlink "$HOME/.VirtualBox" .VirtualBox --setup
- fi
- frugal-symlink "$HOME/.VirtualBox" .VirtualBox &
- sleep .3
- ;;
- 1) ;; # Pressed cancel
- 255) ;; # Box closed
- esac
- frugal-symlink /opt/VirtualBox VirtualBox &
- fi