Skip to content

Instantly share code, notes, and snippets.

@LoveIsGrief
Created March 29, 2017 08:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LoveIsGrief/9d18a5efa36dc1f5e6b3dd2c06953ed1 to your computer and use it in GitHub Desktop.
Save LoveIsGrief/9d18a5efa36dc1f5e6b3dd2c06953ed1 to your computer and use it in GitHub Desktop.
The beginnings of a script to keep firefox-nightly up to date using cron. (Maybe not necessary if firefox nightly does that itself)
#!/usr/bin/env bash
# Unofficial bash strict mode http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'
url="https://download.mozilla.org/?product=firefox-nightly-latest-ssl&os=linux64&lang=en-US"
dir=~/programs/firefox/nightly
version=`curl -s "${url}" | sed -E 's/.*firefox-(.*)\.linux.*/\1/g'`
versionDir="${dir}/${version}"
mkdir -p ${dir}
cd "${dir}"
if [[ -e "${versionDir}" ]] ; then
echo "Version ${version} exists already @ ${versionDir}"
else
echo "Getting firefox-nightly ${version} into ${dir}"
wget --quiet -O - "${url}" | cat | tar xjvf -
mv firefox ${version}
fi
if ! ps faux | grep -v grep | grep "${dir}/current" ; then
if [[ -e "current" ]] ; then
rm current
fi
echo "updating current to ${version}"
ln -s ${version} current
else
echo "firefox nightly is running. won't upgrade yet..."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment