Jump to content
pyth0n3

Linux Latest Firefox Installer [getfox.py Updated]

Recommended Posts

Features Added :

-Progress bar while downloanding

-Support for the latest US Firefox version

Tested on: Debian, Fedora

Should work also under other distro

Note:

If you create an entry in crontab it will upgrade firefox automatically

#!/usr/bin/python
#Date:Jan 10 2012 Updated
#Purpose: Download and install latest US firefox version in Linux
#Author: pyth0n3
#Blog: http://pyth0n3.blogspot.com/

import os
import ftplib
import glob
import tarfile
import shutil
import time
import sys
import threading



print "[+]This script will download && install the latest firefox US version for Linux"

var = raw_input ("Do you want to continue?Type |yes/no| : ")
if var.lower() == "no":
sys.exit()
elif var.lower() == 'yes' :
###making a temp directory in local
print "[+]Creating a temporary directory for work.. "
time.sleep(2)
if not os.path.exists("/tmp/firefox"):
os.mkdir("/tmp/firefox")

os.chdir("/tmp/firefox/")

print "[+]Connecting..."
ftp = ftplib.FTP("releases.mozilla.org")
ftp.login("anonymous", "anonymous")

directory = '/pub/mozilla.org/firefox/releases/latest/linux-i686/en-US/'

match = '*.bz2'

ftp.cwd(directory)

print "[+]Searching the latest version..."

for f1 in ftp.nlst(match):
var = open(f1, 'wb')

class loading_bar(threading.Thread):
def run(self):
global stop, kill
sys.stdout.write("[+]Downloading"+ " "+ f1 +" "+"Please wait...")
sys.stdout.flush()
type = 0
while stop != True:
if type == 0: sys.stdout.write("\b/")
if type == 1: sys.stdout.write("\b-")
if type == 2: sys.stdout.write("\b\\")
if type == 3: sys.stdout.write("\b|")
type += 1
if type == 4: type = 0
sys.stdout.flush()
time.sleep(0.2)
if kill == True: print "\b\b\b\b [+]Aborting!"
else: print "\b\b[+]Download done!"
stop = kill = False
loading_bar_control = loading_bar()
loading_bar_control.start()
try:
ftp.retrbinary('RETR ' + f1, var.write)
var.close()
except KeyboardInterrupt or EOFError:
kill = True; stop = True
stop = True


print "[+]Extracting files... "
def extract_file(path, dst='/usr/lib/'):
if path.endswith('.tar.bz2'):
opener, mode = tarfile.open, 'r:bz2'

cwd = os.getcwd()
os.chdir(dst)

try:
file = opener(path, mode)
try: file.extractall()
finally: file.close()
finally:
os.chdir(cwd)


var1 = glob.glob('/tmp/firefox/*.bz2')
var2 = ','.join(var1)

extract_file (var2)
print "[+]Setting up the browser..."
time.sleep(3)
if os.path.islink("/usr/bin/firefox"):
os.remove("/usr/bin/firefox")
os.symlink("/usr/lib/firefox/firefox", "/usr/bin/firefox")
print "[+]Removing temporary files..."
shutil.rmtree("/tmp/firefox")
print '[+]Done'
sys.exit()


#END#

Download

wget http://sprunge.us/YaVg -O getfox.py

Work's on 32 bit system only, for 64 bit must change the url

This part of code

directory = '/pub/mozilla.org/firefox/releases/latest/linux-i686/en-US/'

To

directory = '/pub/mozilla.org/firefox/releases/latest/linux-x86_64/en-US/'

Old Version , supports only 3.6.x version

Edited by pyth0n3
  • Upvote 1
Link to comment
Share on other sites

Eu am crezut, pana acum ca pyth0n3 == cmin.

Pot sa spun, fara nici o umbra de indoiala, ca toti de aici care au invatat python sau au de gand sa invete, au fost indrumati de unul din voi.

Cand am venit pe forum, am vorbit pe messenger cu unul din voi care mi-a vorbit atat de frumos despre python, incat ma hotarasem ca daca nu ajung sa gandesc in python, trebuie sa ma las de toate.

Au venit problemele(responsabilitati noi,facultate) si tot nu am trecut de bariera sintaxei.Dar nu ma las!

Link to comment
Share on other sites

Suntem 2 persoane diferite cu arii de exploatare diferite, totusi e de ajuns sa cauti prin search dupa Python si gasesti multe posturi pe care le citesti de placere indiferent daca ai sau nu vreo tangenta cu programarea. E cam singurul limbaj in care iti permiti sa prosperi cu ceva in lumea virtuala, sa te faci cumva remarcat si sa poti atinge aproape instantaneu placerea aia a programarii pe care altii nu o vad nici cand se angajeaza.

Imi aduc aminte si acum ... ca aveam cont pe Mortal-Team (care devenise insecurity) si faceam scripturi/automatizari simple in batch @ win si mi-a zis cineva, nu mai stiu daca tw8, nosferatu sau HrN sau cine era, oricum postase unul din ei in threadul ala in care vorbeam eu de un loop of death sau si de alte lucruri in batch (nu e postul asta de pe rst, e altul mai vechi care era si pe insecurity dar disparuse la un moment dat) si mi-a zis sa ma apuc de un limbaj de programare, am ceva potential numai ca in batch sunt "ca un leu in cusca", citatul il tin minte si acum, inca nu am gasit postul in cache in ceva, oricum ii multumesc aceluia, si tot am cautat pana am dat de Python. Conteaza foarte mult prima "iubire" :) iti decide istoria.

Edited by cmiN
Link to comment
Share on other sites

Suntem 2 persoane diferite cu arii de exploatare diferite, totusi e de ajuns sa cauti prin search dupa Python si gasesti multe posturi pe care le citesti de placere indiferent daca ai sau nu vreo tangenta cu programarea. E cam singurul limbaj in care iti permiti sa prosperi cu ceva in lumea virtuala, sa te faci cumva remarcat si sa poti atinge aproape instantaneu placerea aia a programarii pe care altii nu o vad nici cand se angajeaza.

Imi aduc aminte si acum ... ca aveam cont pe Mortal-Team (care devenise insecurity) si faceam scripturi/automatizari simple in batch @ win si mi-a zis cineva, nu mai stiu daca tw8, nosferatu sau HrN sau cine era, oricum postase unul din ei in threadul ala in care vorbeam eu de un loop of death sau si de alte lucruri in batch (nu e postul asta de pe rst, e altul mai vechi care era si pe insecurity dar disparuse la un moment dat) si mi-a zis sa ma apuc de un limbaj de programare, am ceva potential numai ca in batch sunt "ca un leu in cusca", citatul il tin minte si acum, inca nu am gasit postul in cache in ceva, oricum ii multumesc aceluia, si tot am cautat pana am dat de Python. Conteaza foarte mult prima "iubire" :) iti decide istoria.

V-am spus eu!

Cum sa nu te apuci de python cand auzi asa ceva!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...