Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save emersonbarros/88ccc3edb2fed152a5f59456680c29ae to your computer and use it in GitHub Desktop.
Save emersonbarros/88ccc3edb2fed152a5f59456680c29ae to your computer and use it in GitHub Desktop.
a script that downloads a certain Firefox or Thunderbird version and installs it in an extra folder to create an independent and portable App for Linux. source: http://portableapps.com/node/16344
#!/bin/sh
# Configure the following default variables according to your requirements
language="en-US" # e.g. "de" or "en-US"
if [ ! "$1" ]; then
# default if no argument is set:
version="53.0" # chose from http://download.cdn.mozilla.net/pub/mozilla.org/firefox/releases/
application="firefox" # "thunderbird" or "firefox" but file extension, archive extraction, and binary ########################################################
fi
if [ "$1" = "--help" ] || [ "$1" = "-h" ] ; then
echo 'Usage: $0 [application] [version]'
echo
echo Usage:
echo " for example"
echo " $0 mozilla 24.6.0esr"
echo ' -h --help display this help'
exit 0
fi
if [ "$1" ] ; then
application="$1"
fi
if [ "$2" ] ; then
version="$2"
fi
echo result $0 $application $version
echo "This script downloads
--
$application Version $version
--
If you want to install another version press Ctrl+C and call this program with other options, for
example: $0 $application 24.6.0esr"
echo
read -n1 -r -p "Press space to continue..." key
file="$application-$version.tar.bz2"
url="http://download.cdn.mozilla.net/pub/mozilla.org/$application/releases/$version/linux-i686/$language/$file"
# or example for firefox nightly:
#file=firefox-32.0a2.en-US.linux-i686.tar.bz2
#url=http://download.cdn.mozilla.net/pub/mozilla.org/firefox/nightly/latest-mozilla-aurora/$file
dir="$application-portable-$version"
mkdir "$dir"
cd "$dir"
wget $url
echo "Extracting archive, please wait..."
tar xfj $file
rm $file
mv $application app
mkdir data
echo 'user_pref("app.update.auto", false);' > data/prefs.js
echo 'user_pref("app.update.url", "");' >> data/prefs.js
echo '#!/bin/sh' > "${application}-portable"
echo 'dir=${0%/*}' >> "${application}-portable"
echo 'if [ "$dir" = "$0" ]; then' >> "${application}-portable"
echo ' dir="."' >> "${application}-portable"
echo 'fi' >> "${application}-portable"
echo 'cd "$dir/app"' >> "${application}-portable"
echo './firefox -profile ../data' >> "${application}-portable"
chmod +x "$application-portable"
echo ... finished
echo "#close all running instances of another $application version:"
echo killall $application
echo "#change into the directory"
echo "# and start the application there"
echo cd "$dir"
echo ./"$application-portable"
@ivan-pinatti
Copy link

Emerson,

You could use just one call using cat with EOM instead of multiple echo calls, one example of the block between the lines 68-74 would be something like this:

cat <<EOM
... finished
"#close all running instances of another $application version:"
killall $application
"#change into the directory"
"# and start the application there"
cd "$dir"
./"$application-portable"
EOM

@rubo77
Copy link

rubo77 commented Mar 2, 2020

@ivan-pinatti: thx, I added it in my source at:
https://gist.github.com/rubo77/b999c1bc6d10ab802536

@emersonbarros: what is your change doing in line 56?

echo 'user_pref("app.update.auto", false);' > data/prefs.js
echo 'user_pref("app.update.url", "");' >> data/prefs.js

seems like you disable auto update, but why change the url?

@emersonbarros
Copy link
Author

@ivan-pinatti great! thanks!

@rubo77 It's just to force do not update after install.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment