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