Mozilla browser downloader

Browsers, email, chat, etc.
Post Reply
Message
Author
User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

Mozilla browser downloader

#1 Post by 01micko »

Yet another command line tool

This tool will download and install (with menu entry) Firefox or Seamonkey in your language automatically, or you can override and get English (en-US)

This one has potential though. It could well be the backend for some smart looking GUI to grab the latest stable Firefox or Seamonkey direct from your closest Mozilla mirror. (sc0ttman, stu90, Tman.. whoever.. I'm tossing you guys a bone :wink: )

It uses the curl application to parse web pages and download the goods.

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

EDIT 111201:

I have i18n'd the script and also made a very simple gui add on NOTE: if you get the GUI you absolutely need the main package! GUI is i18n'd too, crude Spanish trans included (did I mention it's crude?)

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

TODO: localise the script (might be a good one for L18L's tool 8) )

Code: Select all

#!/bin/ash
#script to get firefox or seamonkey
#01micko GPL3 111130
#v0.1
#sizecheck
SIZEAVAIL=$(cat /tmp/pup_event_sizefreem)
[ "$SIZEAVAIL" -lt "60" ] && echo "not enough space.. exiting" && exit 0

#usage
usagefunc(){
echo "get_mozilla_browser-0.1
Invoke with \"get_mozilla_browser\" and you are offered a choice of 
\"firefox\" or \"seamonkey\" latest stable browsers direct from mozilla 
in your default locale if it exists.
	firefox [Firefox is the choice]
	seamonkey [Seamonkey is the choice]
	-h|--help [shows this message]
	-o|--override [overrides auto locale choice, gets en-US]
"
exit 0
}

#choose
choosefunc(){
echo -en "Choices \n1. Firefox \n2. Seamonkey \n\nChoose 1 or 2 to download \n"
	read WHICH
	case "$WHICH" in
	1)PACKAGE=firefox ;;
	2)PACKAGE=seamonkey ;;
	esac
}
#check net
ping -c1 -q 8.8.8.8 >/dev/null 2>&1
if [ "$?" -eq "0" ];then echo "connection ok"
  else echo "ERROR: not connected to the internet" && exit 0
fi
echo
#get locale
BRLANG=$(echo "$LANG"|cut -d '_' -f1)


if [ ! "$1" ];then
	choosefunc
  else
	case "$1" in
	firefox)PACKAGE=firefox ;;
	seamonkey)PACKAGE=seamonkey ;;
	*-h*)usagefunc ;;
	-o|--override)choosefunc
	echo "$PACKAGE en-US will be downloaded "
	BRLANG2=US ;;
	*)usagefunc ;;
	esac
fi

[ ! -d /tmp/mozilla_dld ] && mkdir /tmp/mozilla_dld
DLOADDIR=/tmp/mozilla_dld
#make sure temp is clear incase aborted
rm -rf $DLOADDIR/* 2>/dev/null

case  "$PACKAGE" in #note that 'curl' doesn't like quotes ""
firefox)HOMEPAGE=http://www.mozilla.org/en-US/firefox/all.html ;;
seamonkey)HOMEPAGE=http://www.seamonkey-project.org/releases/ ;;
esac

#get URLs
curl -s $HOMEPAGE > $DLOADDIR/page1
cd $DLOADDIR
if [ "$PACKAGE" = "firefox" ];then	#parse page1
	grep -i $PACKAGE ./page1|grep "linux"|grep lang|awk '{print $3}'| \
	sed -e's%^href=%%g' -e 's%amp;%%g'|tr -d '"'|grep -v "^onclick" > page2
	DEFAULT=$(grep "en\-" page2|head -n1|sed 's%[A-Z][A-Z]$%US%')
	echo $DEFAULT >> page2 #hack for US
  else #seamonkey
	grep -i $PACKAGE ./page1|grep "linux"|grep lang|awk '{print $2}'|\
	sed -e's%^href=%%g' -e  's%amp;%%g'|tr -d '"' > page2
fi  
if [ "$BRLANG2" = "US" ];then
  DLDURL=$(grep $BRLANG2 ./page2)
  else
  echo "$PACKAGE $BRLANG will be downloaded"
  LIST=`cat page2`
  for b in $LIST
   do 
    if [ "`echo $b|grep $BRLANG`" ];then
     echo $b >> page3
    fi
   done
  WCOUNT=$(wc -l ./page3|cut -d ' ' -f1)
  if [ "$WCOUNT" -gt "1" ];then
	 a=1
	 for i in `cat page3`;do
	 LINE=`echo $i|tail -c6`
	 echo "$a $LINE" >> page4
	 a=$((a+1))
	 done
	 LOCCHOICES=`cat page4`
	 echo
	 echo "locales found.."
	 echo "$LOCCHOICES"
	 echo "choose 1 - $WCOUNT above"
	 read CHOSEN
	 if [ "$CHOSEN" ];then BRLANG2=$(grep "^${CHOSEN}" ./page4|cut -d '-' -f2)
		else echo "no valid choice, start again" && exit 1
	 fi
  fi
  if [ "$BRLANG2" ];then DLDURL=$(grep $BRLANG ./page2|grep $BRLANG2)
	else DLDURL=$(grep $BRLANG ./page2)
  fi
fi
#download
echo "downloading $PACKAGE"
curl -L -O $DLDURL
#extract
TARBALL=$(ls|grep $PACKAGE)
mv -f ./$TARBALL ./${PACKAGE}.tar.bz2
echo "extracting $PACKAGE"
tar -xf ${PACKAGE}.tar.bz2
[ "$?" -ne "0" ] && echo "failed to download and extract $PACKAGE"
#install
echo "installing $PACKAGE"
[ -d /usr/lib/$PACKAGE ] && rm -rf /usr/lib/$PACKAGE #saves space ovver "cp"
mv -f $PACKAGE /usr/lib/
echo "#!/bin/sh
exec /usr/lib/$PACKAGE/$PACKAGE" > /usr/bin/$PACKAGE
chmod 755 /usr/bin/$PACKAGE
#menu
#icon
if [ "$PACKAGE" = "firefox" ];then
  cp -f /usr/lib/firefox/icons/mozicon128.png /usr/share/icons/firefox.png
  NAME=Firefox
  else #seamonkey
  cp -f /usr/lib/seamonkey/chrome/icons/default/default.png \
  /usr/share/icons/seamonkey.png
  NAME=Seamonkey
fi
echo "[Desktop Entry]
Encoding=UTF-8
Name=$NAME web browser
Icon=/usr/share/icons/$PACKAGE.png
Comment=$NAME web browser
Exec=$PACKAGE
Terminal=false
Type=Application
Categories=X-Internet
GenericName=$NAME web browser
" > /usr/share/applications/${PACKAGE}.desktop
fixmenus
[ "`pidof jwm`" ] && echo "restarting jwm" && jwm -restart
#cleanup
echo "cleaning temp files"
rm -r $DLOADDIR
echo "done!"
cd $HOME
echo "Hit enter to quit"
read yeah
Have fun!
Attachments
get_mozilla_browser-0.2.pet
MAIN script, you don't need the GUI with this. I suggest NOT getting the GUI.
It saves cluttering your menu, but if you are allergic to prompts by all means..
get the GUI!
(2.93 KiB) Downloaded 592 times
browser_installer2-0.1-demo.pet
this NEEDS the above main script to function, else just errors out
(1.46 KiB) Downloaded 532 times
GUI.png
(12.27 KiB) Downloaded 1560 times
get_mozilla_browser.gz
(1.84 KiB) Downloaded 472 times
Last edited by 01micko on Thu 01 Dec 2011, 05:40, edited 4 times in total.
Puppy Linux Blog - contact me for access

User avatar
sc0ttman
Posts: 2812
Joined: Wed 16 Sep 2009, 05:44
Location: UK

Re: Mozilla browser downloader

#2 Post by sc0ttman »

01micko wrote:This tool will download and install (with menu entry) Firefox or Seamonkey in your language automatically, or you can override and get English (en-US) ...It could well be the backend for some smart looking GUI to grab the latest stable Firefox or Seamonkey direct from your closest Mozilla mirror. (sc0ttman.. I'm tossing you guys a bone :wink: )
Lovely stuff, I just upgraded to FF7.0.1 (before seeing this) ... This will be of great use to me! :D Cheers mick

EDIT:: Gripe coming: I hope the latest FF, SM etc use libc6 2.10 (like wary)... I find it a real pain Barry went for 2.10 when Lupu had already gone for 2.11.. As well as chrome, and many other svn/nightly builds needing 2.11 :(

About localising, PLEASE dont use gettext, its such a pain - once the english is updated, all other locales break... Do it Technos way:

var="french stuff"
${var:-english stuff}


:D
[b][url=https://bit.ly/2KjtxoD]Pkg[/url], [url=https://bit.ly/2U6dzxV]mdsh[/url], [url=https://bit.ly/2G49OE8]Woofy[/url], [url=http://goo.gl/bzBU1]Akita[/url], [url=http://goo.gl/SO5ug]VLC-GTK[/url], [url=https://tiny.cc/c2hnfz]Search[/url][/b]

User avatar
Tman
Posts: 808
Joined: Sat 22 Jan 2011, 21:39
Location: Toronto

#3 Post by Tman »

Thank you, Mick.
It looks like it will be very useful for me as well. I got too much stuff going on to look at it in detail at the moment, but I will see if I can implement your code into my downloader at a later time. For now I will stick to what works for me. But I see the potential of your code saving a lot of time in the future, if I don't have to manually make packages for Seamonkey. I will still be making them for Firefox, though.
( Fluffy catches the bone and dashes away :wink: )

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#4 Post by 01micko »

Ok, I i18n'd the script with L18L's method, works good with a rough Spanish trans. Also added the ability to use -o option with a browser option.

Also knocked up a demo gui to show how to use the script backend with a gtkdialog frontend. You could use YAD or Xdialog or whatever gui tool, even xmessage (yes xmessage!)

See main post

Code: Select all

# LANG=es_ES
# get_mozilla_browser -h
conexión se puede

get_mozilla_browser-0.2
Invocar con "get_mozilla_browser" y se le ofrece una selección de
"firefox" o "seamonkey" más estable navegadores directamente desde Mozilla
en su entorno local por omisión, si existe.
	firefox [Firefox es la elección]
	seamonkey [Seamonkey es la elección]
	-h | - help [muestra este mensaje]
	-o | - override [auto anula la elección local, se en-US]
Puppy Linux Blog - contact me for access

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Mozilla browser downloader

#5 Post by L18L »

01micko wrote:Ok, I i18n'd the script with L18L's method, works good with a rough Spanish trans.
Not OK in wary52190 :cry:
Now in wary52 (my important files in /mnt/home)

I have started the script and have seen the question
then I wanted to open a terminal, inspect code in geany....not possible :roll:

restarted using save_file : kernel panic

restarted without using save_file : I found:
-sh: error while loading shared libraries: libreadline.so.5: cannot open shared object file: No such file or directory

Keep the faith :)

----
edited
I will try it in wary52 now (/usr/lib/readline.so.5 exists)
-----
edited
It works:

# ./brow*
connection ok

Choices
1. Firefox
2. Seamonkey

Choose 1 or 2 to download
1
firefox de will be downloaded
downloading firefox
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 15.2M 100 15.2M 0 0 638k 0 0:00:24 0:00:24 --:--:-- 689k
extracting firefox
installing firefox
Generating /root/.icewm/menu...
Generating /root/.jwmrc...
restarting jwm
cleaning temp files
done!
Hit enter to quit

Firefox is in menu but did not start
in console:

# firefox
Couldn't load XRE functions.
#

Hope that helps :)

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#6 Post by 01micko »

sc0ttman wrote:EDIT:: Gripe coming: I hope the latest FF, SM etc use libc6 2.10 (like wary)... I find it a real pain Barry went for 2.10 when Lupu had already gone for 2.11.. As well as chrome, and many other svn/nightly builds needing 2.11
L18L wrote:Not OK in wary52190 [and (re wary52)]Couldn't load XRE functions.
Hmm.. likely sc0ttman's issue. I tested only in Slacko but I expect it would work in Lupu, Dpup. hoping for Wary/Racy. However I should have tested for dbus too, as it is not in Wary/Racy.
Puppy Linux Blog - contact me for access

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Mozilla browser downloader

#7 Post by L18L »

I have prepared the script for t12s method.

But...
# ./browser-installer -h
ash: bad number
connection ok
...
and again:
# ./t12s
/bin/sh: error while loading shared libraries: libreadline.so.5: cannot open shared object file: No such file or directory
#
Cannot open new console now
# ls -la /usr/lib
total 36
drwxr-xr-x 69 root root 32768 Dec 2 14:11 .
drwxr-xr-x 32 root root 4096 Oct 28 15:24 ..
#
Maybe cleaning temp files did clean too much ???

browser-installer-prepared attached
it was working with t12s before ´Execute´

Keep the faith :)

I am going now to revive my /usr/lib...
Attachments
browser-installer.prepared.gz
delete .gz
(4.73 KiB) Downloaded 438 times

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: Mozilla browser downloader

#8 Post by L18L »

L18L wrote:I have prepared the script for t12s method.
Now in slacko53MAIN

Re-prepared script browser-install for t12s
changes with new lines
translator should not mess up with new lines
(yad uses new lines for separating columns)

working in slacko here :)

# ./browser-installer
Verbindung ok

Auswahl
1. Firefox
2. Seamonkey

Wähle 1 oder 2 zum Herunterladen
Attachments
browser-installer.prepared.gz
copy to browser-installer (without .gz)
(4.86 KiB) Downloaded 403 times

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Mozilla browser downloader

#9 Post by L18L »

using latest t12s, download from
http://www.murga-linux.com/puppy/viewto ... h&id=49619 and rename to t12s (without .gz)
I have added i18n of "get_mozilla_browser is not installed"
that was just changed
[ ! `which get_mozilla_browser` ] && echo "get_mozilla_browser is not installed"
to
[ ! `which get_mozilla_browser` ] && echo "${_M_:-get_mozilla_browser is not installed}"
then running t12s and number 5 has automatically been created

Code: Select all

#!/bin/ash
#gui for get_mozilla_browser, demo

# changed _Mn to _ M_n, _ M_5 added

############################# copy this block into any other script that...
app=`basename $0`
T=/usr/share/locales # TEXTDOMAINDIR
# a one-liner to find existing translation file LOCALES
[ ! -f ${T}/${LANG%.*}/${app} ] && LOCALES=${T}/${LANG%_*}/${app} || LOCALES=${T}/${LANG%.*}/${app}
# load translation file
[ -f $LOCALES ] && . $LOCALES
############################# ... uses this method of internationalization


[ ! `which get_mozilla_browser` ] && echo "${_M_5:-get_mozilla_browser is not installed}"

[ -f /usr/share/icons/firefox.png ] && FFicon=/usr/share/icons/firefox.png || \
FFicon=/usr/local/lib/X11/mini-icons/mozilla.xpm
[ -f /usr/share/icons/seamonkey.png ] && SMicon=/usr/share/icons/seamonkey.png || \
SMicon=/usr/local/lib/X11/mini-icons/seamonkey16.xpm

export GUI='<window title="Browser Installer2">
 <vbox>
  <hbox height="100">
   <text><label>Firefox: '"${_M_1:-press icon to download}"'</label></text>
   <button relief="2">
    <height>32</height>
    <input file>'"$FFicon"'</input>
    <action type="exit">ff</action>
   </button>
  </hbox>
  <hbox height="100">
   <text><label>Seamonkey: '"${_M_1:-press icon to download}"'</label></text>
   <button relief="2">
    <height>32</height>
    <input file>'"$SMicon"'</input>
    <action type="exit">sm</action>
   </button>
  </hbox>
  <hbox>
   <checkbox>
    <label>'"${_M_2:-tick the box only to get US locale}"'</label>
    <variable>CB0</variable>
    <default>false</default>
   </checkbox>
  </hbox>
 </vbox>
</window>'
eval $(gtkdialog -p GUI -c)
case $CB0 in
false) OPT="" ;;
true) OPT="-o" ;;
esac
case $EXIT in
ff)touch /tmp/browser-installer2.flg
rxvt -bg lightblue -fg black -title "get Firefox" -e get_mozilla_browser $OPT firefox 
rm /tmp/browser-installer2.flg
[ -d /usr/lib/firefox ] && \
gtkdialog-splash -bg green -timeout 5 -close never -text "Firefox ${_M_3:-installed successfully}" ||\
gtkdialog-splash -bg red -timeout 5 -close never -text "Firefox ${_M_4:-failed to install}"
exit;;
sm)touch /tmp/browser-installer2.flg
rxvt -bg lightgreen -fg black -title "get Seamonkey" -e get_mozilla_browser $OPT seamonkey 
rm /tmp/browser-installer2.flg
[ -d /usr/lib/firefox ] && \
gtkdialog-splash -bg green -timeout 5 -close never -text "Seamonkey ${_M_3:-installed successfully}" ||\
gtkdialog-splash -bg red -timeout 5 -close never -text "Seamonkey ${_M_4:-failed to install}"
exit;;
*)exit ;;
esac
/usr/share/locales/de/browser-installer2:

Code: Select all

_M_1="Klick auf Icon zum Herunterladen"
_M_2="aktiviere Schaltfläche für englische Version"
_M_3="erfolgreich installiert"
_M_4="Installation fehlgeschlagen"
_M_5="get_mozilla_browser ist nicht installiert"
Attachments
browser-installer2.png
(10.87 KiB) Downloaded 1361 times
Last edited by L18L on Sat 10 Dec 2011, 21:57, edited 1 time in total.

User avatar
Bert
Posts: 1103
Joined: Fri 30 Jun 2006, 20:09

#10 Post by Bert »

Thanks Micko, great stuff!

(Remember all those discussions in the past, when users were complaining devs were not listening to their needs?...haha)

Two questions:

- Will the browser be able to auto-upgrade with your system?

- There must be a good reason you're offering this only for the Mozilla browsers. Would it technically be possible to add other browsers like Opera and the Chromium family to your script somewhere in the future?

Thanks again!

EDIT 12/12: :oops: :oops: that last one was a really stupid question, I now realize, Opera and Chrome-browsers have all languages aboard... Next time will try to think a little before adding noise to the forum :oops:
[url=http://pupsearch.weebly.com/][img]http://pupsearch.weebly.com/uploads/7/4/6/4/7464374/125791.gif[/img][/url]
[url=https://startpage.com/do/search?q=host%3Awww.murga-linux.com%2F][img]http://i.imgur.com/XJ9Tqc7.png[/img][/url]

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#11 Post by B.K. Johnson »

I just stumbled on 01micko's get_mozilla_browser and have been mucking around with it. Some things have changed; it is circa 2011 after all.

I need permanently placed graphics for firefox and seamonkey to replace non-existant files in tahr-6.0.5. The gui demo needs to have these icons.

/usr/share/icons/[firefox.png and seamonkey.png] - they do not exist
graphic files qfirefox.png and qseamonkey.png exists but what are they for? What application(s) use them? Are they guaranteed to be in later puppies?

/usr/local/lib/X11/mini-icons/[mozilla.xpm and seamonkey16.xpm] - they do not exist

My guess is that when firefox and seamonkey were in all breeds of puppies, the dev included the .xpm files and a graphic in /usr/share/icons/ that was always available, but they don't when the browser is not a part of the ootb puppy. Neither firefox or seamonkey is included in a pristine tahr-6.0.5.


I think I can get around the problem by:

1. including the requisite graphics in the pet and installing them to /usr/share/icons/ so the icons are available for the demo even when the browser does not come with the puppy.
2. using appropriately sized .png files instead of .xpm, including them in the pet and installing them to /usr/local/lib/X11/mini-icons/

But I have to learn to reconstruct the pets. I suppose the icons I'll add will be placed in /usr/ and then archive the lot. Any suggestions are welcomed.
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

Post Reply