Author Topic: Zenity Script Help for getvirtualbox.  (Read 8094 times)

Offline travisN000

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1758
Re: Zenity Script Help for getvirtualbox.
« Reply #15 on: June 06, 2010, 11:58:56 PM »
At any place in the script where zenity is called, this script should be added. That would be in about 6 or 7 places, I think.



# download VirtualBox
#=================================================
# maybe here?
if [ $? = 1 ];
then exit 0
fi
MSG=$"Downloading VirtualBox (53mb). Please be patient..."
( wget $source ) 2>&1 | $ZEN2 --width 500 --title="$TITLE" --progress --text "$MSG" --pulsate --auto-close

# maybe here?
if [ $? = 1 ];
then exit 0
fi

nope neither works...??? I dunno...   :'(



...has anyone tried adding the --auto-kill option on that progress dialog?  It is suppose to kill the parent process.

I've got a few other ideas, but I think it will be a few days until I can spend any real time on it. :-\

Offline pinoc

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2837
    • other projects...
Re: Zenity Script Help for getvirtualbox.
« Reply #16 on: June 07, 2010, 03:51:43 AM »
just to avoid duplicated efforts, looking into it right now and added/changed things as needed. So far works well and should be ready soon after some more refinements.
-p.

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Zenity Script Help for getvirtualbox.
« Reply #17 on: June 07, 2010, 05:52:25 AM »
I awaken from sleep, and what do I find? Tex thinks I'm blind. ;D Galen thinks I left out the closing empty line. ;D Travis suggests --auto-kill. ;D And Pinoc has the script working. ;D

So what's the moral of the story? -->
Amazing things happen around here. Don't fall asleep, or you'll miss 'em. ;D ;D ;D

 

Offline menotu

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 15279
  • ┌∩┐(◕_◕)┌∩┐
Re: Zenity Script Help for getvirtualbox.
« Reply #18 on: June 07, 2010, 05:56:27 AM »
Thats Zen for you
PCLinuxOS 32bit KDE 4.10.1; kernel-3.4.11-pclos1.bfs & 64bit 3.2.18bfs; NVidia GeForce 8400GS 1GB 310.19 driver

Sony Vaio SVE1513A4ESI Laptop, Intel Core i5, 2.6GHz, 6GB RAM, 750GB, 15.6" Intel HD Graphics 4000

Offline Village Idiot

  • Hero Member
  • *****
  • Posts: 2345
  • Have A Nice Day.
Re: Zenity Script Help for getvirtualbox.
« Reply #19 on: June 07, 2010, 10:20:52 AM »
I awaken from sleep, and what do I find? Tex thinks I'm blind. ;D Galen thinks I left out the closing empty line. ;D Travis suggests --auto-kill. ;D And Pinoc has the script working. ;D

So what's the moral of the story? -->
Amazing things happen around here. Don't fall asleep, or you'll miss 'em. ;D ;D ;D

 

You snooze, you lose!   ;D

$ fortune
No Microsoft products were used in any way for the creation of this message.
If you are using a Microsoft product to view it, BEWARE! - I'm not
responsible for any harm you might encounter as a result.

Offline travisN000

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1758
Re: Zenity Script Help for getvirtualbox.
« Reply #20 on: June 07, 2010, 12:54:07 PM »
just to avoid duplicated efforts, looking into it right now and added/changed things as needed. So far works well and should be ready soon after some more refinements.
-p.

..maybe when this is done we can also put together a VMware version; IIRC it uses a similar .run install script.  ???


With all of these GetXXX scripts, would it be a good idea to put together some sort of dummy metapackage for the main repo that could auto-launch the script (or notify the user) when its version/release is updated in the repo's; it could possibly be used be used to force a re-install / rebuild of kernel modules when kernels change, etc.  

I played with this sort of idea for another package awhile ago..  putting a zenity dialog / bash script in the spec file %pre or %post sections does work, and can be used to create an interactive install or update experience.

..a short script in the %pre section might check if VBox is already installed; in which case it could be assumed that the updated metapackage signals a new version avialable and prompt the user; dealing with kernel changes is more tricky.. perhaps the getVBox script could log kernel at VBox install and the %pre scripts could also check this.  This might be better handled by an kernel checking script integrated into the .desktop launcher.
« Last Edit: June 07, 2010, 02:33:08 PM by travisn000 »

Offline Texstar

  • Administrator
  • Super Villain
  • *****
  • Posts: 12490
Re: Zenity Script Help for getvirtualbox.
« Reply #21 on: June 07, 2010, 06:43:57 PM »
just to avoid duplicated efforts, looking into it right now and added/changed things as needed. So far works well and should be ready soon after some more refinements.
-p.


Yes but I wanted to avoid xterm because it is butt ugly. Here is my updated code that shows a progress bar while downloading the file. Still need to fix the cancel buttons.
 
changelog
- show progress bar with download speed and time left when downloading package
- add usb group in case it doesn't exist
- add user to usb group as well so they get usb support


Code: [Select]
#!/bin/bash -l

# getvirtualbox
#
# 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.2"
package="VirtualBox-3.2.2-62298-Linux_x86.run"
source="http://download.virtualbox.org/virtualbox/3.2.2/"$package
ZEN2="zenity"


# check for working internet connection
#=================================================
cd /tmp
/bin/rm -f index.html inet.log
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"
exit 0
fi

# clean up and make sure no partial downloads exist in /tmp
/bin/rm -f index.html inet.log VirtualBox*


# download VirtualBox
#=================================================
#MSG=$"Downloading VirtualBox (53mb). Please be patient..."
wget $source 2>&1 | sed -u 's/.* \([0-9]\+%\)\ \+\([0-9.]\+.\) \(.*\)/\1\n# Downloading at \2\/s, ETA \3/' | $ZEN2 --width 500 --progress --title="$TITLE" --auto-close


#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 -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

« Last Edit: June 07, 2010, 06:50:18 PM by Texstar »

Thanks to everyone who donates. You keep the servers running.

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Zenity Script Help for getvirtualbox.
« Reply #22 on: June 07, 2010, 07:12:53 PM »
Added a couple of things to your script. Cancel now works.
Code: [Select]
#!/bin/bash -l

# getvirtualbox
#
# 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.2"
package="VirtualBox-3.2.2-62298-Linux_x86.run"
source="http://download.virtualbox.org/virtualbox/3.2.2/"$package
ZEN2="zenity"
exit1=--kill-all

# check for working internet connection
#=================================================
cd /tmp
/bin/rm -f index.html inet.log
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"
exit 0
fi

# clean up and make sure no partial downloads exist in /tmp
/bin/rm -f index.html inet.log VirtualBox*

if [ $? = 1 ];
then $exit1
fi

# download VirtualBox
#=================================================
#MSG=$"Downloading VirtualBox (53mb). Please be patient..."
wget $source 2>&1 | sed -u 's/.* \([0-9]\+%\)\ \+\([0-9.]\+.\) \(.*\)/\1\n# Downloading at \2\/s, ETA \3/' | $ZEN2 --width 500 --progress --title="$TITLE" --auto-close


#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 -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

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Zenity Script Help for getvirtualbox.
« Reply #23 on: June 07, 2010, 07:18:33 PM »
After multiple attempts to get the script
Code: [Select]
if [ $? = 1 ];
then exit
fi
to work -- various places, etc -- the idea occurred to me: If the script isn't working, rewrite it. So I did. :D

Sad, isn't it, that it took two days to think of that?


Offline Texstar

  • Administrator
  • Super Villain
  • *****
  • Posts: 12490
Re: Zenity Script Help for getvirtualbox.
« Reply #24 on: June 07, 2010, 07:28:51 PM »
After multiple attempts to get the script
Code: [Select]
if [ $? = 1 ];
then exit
fi
to work -- various places, etc -- the idea occurred to me: If the script isn't working, rewrite it. So I did. :D

Sad, isn't it, that it took two days to think of that?



I'm sorry but that doesn't do anything other than close the zenity box. wget is still running, downloading the package unless I Control-C it in the konsole.


Thanks to everyone who donates. You keep the servers running.

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Zenity Script Help for getvirtualbox.
« Reply #25 on: June 07, 2010, 07:31:43 PM »
 :o :o ??? :o :o It stopped here. Sheep-dip! ??? :-[
Sorry, Tex, I thought I had it. ::) :(

Offline Texstar

  • Administrator
  • Super Villain
  • *****
  • Posts: 12490
Re: Zenity Script Help for getvirtualbox.
« Reply #26 on: June 07, 2010, 07:38:51 PM »
:o :o ??? :o :o It stopped here. Sheep-dip! ??? :-[
Sorry, Tex, I thought I had it. ::) :(


I almost got it now.. :D Except the script stops after downloading. The cancel works though! LOL

Edit: removed the exit 0 in the loopscript.

 

Code: [Select]
#!/bin/bash -l

# getvirtualbox
#
# 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.2"
package="VirtualBox-3.2.2-62298-Linux_x86.run"
source="http://download.virtualbox.org/virtualbox/3.2.2/"$package
ZEN2="zenity"


# check for working internet connection
#=================================================
cd /tmp
/bin/rm -f index.html inet.log
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"
exit 0
fi

# clean up and make sure no partial downloads exist in /tmp
/bin/rm -f index.html inet.log VirtualBox*


# download VirtualBox
#=================================================
#MSG=$"Downloading VirtualBox (53mb). Please be patient..."
wget $source 2>&1 | sed -u 's/.* \([0-9]\+%\)\ \+\([0-9.]\+.\) \(.*\)/\1\n# Downloading at \2\/s, ETA \3/' | $ZEN2 --width 500 --progress --title="$TITLE" --auto-close &

#Start a loop testing if zenity is running, and if not kill wget
RUNNING=0
while [ $RUNNING -eq 0 ]
do
if [ -z "$(pidof zenity)" ]
then
 pkill wget
 RUNNING=1
fi
done


#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
#=================================================
groupadd usb


# Virtualbox installer automatically adds vboxusers group
#=================================================


# 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
« Last Edit: June 08, 2010, 09:39:35 PM by Texstar »

Thanks to everyone who donates. You keep the servers running.

Offline parnote

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 4439
  • The truth is out there ... PCLinuxOS!
Re: Zenity Script Help for getvirtualbox.
« Reply #27 on: June 07, 2010, 07:42:13 PM »
I'm watching this ... I was having the same problem with gtkdialog this past week/weekend.

parnote
PCLinuxOS Magazine Chief Editor

Linux Registered User #485009

In a world without walls, who needs Windows?

PCLinuxOS Wiki: Contribute tips/tricks/how-to's!

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Zenity Script Help for getvirtualbox.
« Reply #28 on: June 07, 2010, 08:07:54 PM »
gtkdialog has given me difficulties recently. That's why I started learning (correction: trying to learn) zenity.

Offline travisN000

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1758
Re: Zenity Script Help for getvirtualbox.
« Reply #29 on: June 08, 2010, 02:45:53 AM »
I think I found a solution to killing wget (and other child processes) with the wget>sed>zenity pipe...  the nice thing about this solution is that it will not kill external wget processes (..from download managers, etc), it only kills processes that are started by the script.  This method should also be a little less resource intensive than the previous fix, as it does not create a continuously running loop.

I also modified the progress box slightly so that ETA is on a new line (..watching it bounce around in test after test was making me feel ill!  :-X :P :o)


(this is not the entire script..  just up through the pipe problem  ;))


EDIT: ..removed, will post full script momentarily.
« Last Edit: June 09, 2010, 12:25:40 AM by travisn000 »