Author |
Message |
01micko

Joined: 11 Oct 2008 Posts: 8787 Location: qld
|
Posted: Wed 30 Nov 2011, 07:01 Post subject:
Mozilla browser downloader Subject description: a script to get the latest firefox or seamonkey in your language |
|
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 )
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 )
Code: | #!/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!
Description |
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!
|

Download |
Filename |
get_mozilla_browser-0.2.pet |
Filesize |
2.93 KB |
Downloaded |
622 Time(s) |
Description |
this NEEDS the above main script to function, else just errors out
|

Download |
Filename |
browser_installer2-0.1-demo.pet |
Filesize |
1.46 KB |
Downloaded |
556 Time(s) |
Description |
|
Filesize |
12.27 KB |
Viewed |
1566 Time(s) |

|
Description |
|

Download |
Filename |
get_mozilla_browser.gz |
Filesize |
1.84 KB |
Downloaded |
497 Time(s) |
_________________ Puppy Linux Blog - contact me for access
Last edited by 01micko on Thu 01 Dec 2011, 01:40; edited 4 times in total
|
Back to top
|
|
 |
sc0ttman

Joined: 16 Sep 2009 Posts: 2806 Location: UK
|
Posted: Wed 30 Nov 2011, 12:16 Post subject:
Re: Mozilla browser downloader Subject description: a script to get the latest firefox or seamonkey in your language |
|
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 ) |
Lovely stuff, I just upgraded to FF7.0.1 (before seeing this) ... This will be of great use to me! 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}
_________________ Pkg, mdsh, Woofy, Akita, VLC-GTK, Search
|
Back to top
|
|
 |
Tman

Joined: 22 Jan 2011 Posts: 815 Location: Toronto
|
Posted: Wed 30 Nov 2011, 13:59 Post subject:
|
|
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 )
|
Back to top
|
|
 |
01micko

Joined: 11 Oct 2008 Posts: 8787 Location: qld
|
Posted: Thu 01 Dec 2011, 01:16 Post subject:
|
|
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: | # 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
|
Back to top
|
|
 |
L18L

Joined: 19 Jun 2010 Posts: 3493 Location: www.eussenheim.de/
|
Posted: Fri 02 Dec 2011, 07:00 Post subject:
Mozilla browser downloader Subject description: using wary52190 |
|
01micko wrote: | Ok, I i18n'd the script with L18L's method, works good with a rough Spanish trans. |
Not OK in wary52190
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
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
|
Back to top
|
|
 |
01micko

Joined: 11 Oct 2008 Posts: 8787 Location: qld
|
Posted: Fri 02 Dec 2011, 08:00 Post subject:
|
|
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
|
Back to top
|
|
 |
L18L

Joined: 19 Jun 2010 Posts: 3493 Location: www.eussenheim.de/
|
Posted: Fri 02 Dec 2011, 08:28 Post subject:
Mozilla browser downloader Subject description: wary52, empty /usr/lib |
|
I have prepared the script for t12s method.
But...
Quote: | # ./browser-installer -h
ash: bad number
connection ok
...
|
and again:
Quote: | # ./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
Quote: | # 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...
Description |
delete .gz
|

Download |
Filename |
browser-installer.prepared.gz |
Filesize |
4.73 KB |
Downloaded |
460 Time(s) |
|
Back to top
|
|
 |
L18L

Joined: 19 Jun 2010 Posts: 3493 Location: www.eussenheim.de/
|
Posted: Fri 02 Dec 2011, 10:11 Post subject:
Re: Mozilla browser downloader Subject description: re-prepared for t12s |
|
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
Description |
copy to browser-installer (without .gz)
|

Download |
Filename |
browser-installer.prepared.gz |
Filesize |
4.86 KB |
Downloaded |
426 Time(s) |
|
Back to top
|
|
 |
L18L

Joined: 19 Jun 2010 Posts: 3493 Location: www.eussenheim.de/
|
Posted: Fri 09 Dec 2011, 14:58 Post subject:
Mozilla browser downloader Subject description: i18n GUI |
|
using latest t12s, download from
http://www.murga-linux.com/puppy/viewtopic.php?mode=attach&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: |
#!/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: | _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"
|
Description |
|
Filesize |
10.87 KB |
Viewed |
1365 Time(s) |

|
Last edited by L18L on Sat 10 Dec 2011, 17:57; edited 1 time in total
|
Back to top
|
|
 |
Bert

Joined: 30 Jun 2006 Posts: 1107
|
Posted: Fri 09 Dec 2011, 17:34 Post subject:
|
|
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: 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
_________________

|
Back to top
|
|
 |
B.K. Johnson
Joined: 12 Oct 2009 Posts: 810
|
Posted: Tue 05 Jul 2016, 23:48 Post subject:
|
|
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.
_________________ 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
|
Back to top
|
|
 |
|