Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Firefox launcher containing a Profile migration helper for
- # temporary profiles used during alpha and beta phases.
- # Original Authors:
- # Alexander Sack <asac@jwsdot.com>
- # Fabien Tassin <fta@sofaraway.org>
- # Steve Langasek <steve.langasek@canonical.com>
- # Modified for Thunderbird by:
- # Micah Gersten <micahg@ubuntu.com>
- # License: GPLv2 or later
- # If there's a ~/.mozilla-thunderbird profile, copy to .thunderbird
- # If nothing is found, we'll go for a fresh run and let thunderbird create a
- # default profile for us.
- HOMEDIR=$HOME
- LIBDIR=@LIBDIR@
- APPVER=@APPVER@
- META_NAME=@META_NAME@
- GDB=/usr/bin/gdb
- DROPPED=abandoned
- NAME=`which "$0"`
- if [ "x$META_NAME" != "x" ] ; then
- NAME="${NAME%%-$APPVER}"
- fi
- APPNAME="$(basename "$NAME")"
- while [ ! -f "$LIBDIR/$APPNAME" ] && [ -L "$NAME" ]; do
- TARGET="$(readlink "$NAME")"
- if [ "x$TARGET" = "x$(basename "$TARGET")" ]; then
- TARGET="$(dirname "$NAME")/$TARGET"
- fi
- if [ "x$META_NAME" != "x" ] ; then
- TARGET=${TARGET%%-$APPVER}
- fi
- NAME="$TARGET"
- APPNAME="$(basename "$NAME")"
- if [ "x$APPNAME" = "xthunderbird.sh" ]; then
- APPNAME=thunderbird
- break
- fi
- done
- usage () {
- $LIBDIR/$APPNAME -h | sed -e 's,/.*/,,'
- echo
- echo " -g or --debug Start within $GDB (Must be first)"
- }
- want_debug=0
- while [ $# -gt 0 ]; do
- case "$1" in
- -h | --help | -help )
- usage
- exit 0 ;;
- -g | --debug )
- want_debug=1
- shift ;;
- -- ) # Stop option prcessing
- shift
- break ;;
- * )
- break ;;
- esac
- done
- # if there exists a beta profile (first found: $HOMEDIR/firefox-3.5,
- # $HOMEDIR/firefox-3.1) and there is a standard firefox profile as well, ask the
- # user what to do. In case he decides to import the firefox 3.0 profile
- # settings, we keep the firefox directory untouched, but rename the beta
- # profile by appending the suffix |.abandoned|. In case the user decides to
- # keep using the thunderbird 2.0 profile, we rename the original firefox profile to
- # firefox.3.0-replaced and rename the beta profile to be |.mozilla/firefox|.
- #
- # as a third option the user can defer his final decision. This will leave the
- # directories untouched, thus making the user use the old firefox profile by
- # default.
- #
- # in addition, even older profiles are renamed too, by appending |.abandoned|
- # to their name.
- FOUND_OLD=""
- OLD_DIR=.mozilla-thunderbird
- if [ -d $HOMEDIR/$OLD_DIR ] ; then
- FOUND_OLD=$OLD_DIR;
- fi
- CURRENT=.thunderbird
- FOUND_CURRENT=""
- if [ -d $HOMEDIR/$CURRENT] ; then
- FOUND_CURRENT=$CURRENT
- fi
- FOUND_BETA=""
- BETA_LIST=""
- for betaname in .thunderbird-3.0; do
- if [ -d $HOMEDIR/$betaname ]; then
- BETA_LIST="$BETA_LIST $betaname"
- FOUND_BETA=$betaname
- fi
- done
- if [ "$FOUND_OLD" != "" ] ; then
- if [ $FOUND_CURRENT != "" ] ; then
- if [ ! -d $HOMEDIR/$CURRENT.upstream ] ; then
- mv $HOMEDIR/$CURRENT $HOMEDIR/$CURRENT.upstream
- else
- mv $HOMEDIR/$CURRENT $HOMEDIR/$CURRENT.$$
- fi
- fi
- fi
- if [ "$FOUND_BETA" != "" ] ; then
- echo -n "Found Beta Participation ..."
- $LIBDIR/tb-beta-profile-migration-dialog
- result=$?
- if [ $result = 1 ]; then
- if [ $FOUND_CURRENT != "" ] ; then
- if [ ! -d $HOMEDIR/$CURRENT-2.0-replaced ] ; then
- mv $HOMEDIR/$CURRENT $HOMEDIR/$CURRENT-2.0-replaced
- else
- mv $HOMEDIR/$CURRENT $HOMEDIR/$CURRENT.$$
- fi
- fi
- mv $HOMEDIR/$FOUND_BETA $HOMEDIR/$CURRENT
- for beta in $BETA_LIST ; do
- if [ $beta != $FOUND_BETA ] ; then
- mv $HOMEDIR/$beta $HOMEDIR/$beta.$DROPPED
- fi
- done
- echo " keep beta profile."
- elif [ $result = 2 ]; then
- #TB2 Profile already imported, so just move Beta profile out of the way
- for beta in $BETA_LIST ; do
- mv $HOMEDIR/$beta $HOMEDIR/$beta.$DROPPED
- done
- echo " use thunderbird 2.0 profile."
- else
- echo " use thunderbird 2.0 profile, but will ask again next time."
- fi
- echo " ... will check again next time."
- fi
- if [ $want_debug -eq 1 ] ; then
- if [ ! -x $GDB ] ; then
- echo "Sorry, can't find usable $GDB. Please install it."
- exit 1
- fi
- tmpfile=`mktemp /tmp/mozargs.XXXXXX` || { echo "Cannot create temporary file" >&2; exit 1; }
- trap " [ -f \"$tmpfile\" ] && /bin/rm -f -- \"$tmpfile\"" 0 1 2 3 13 15
- echo "set args ${1+"$@"}" > $tmpfile
- echo "sh $LIBDIR/run-mozilla.sh $GDB "$LIBDIR/$META_NAME"-bin -x $tmpfile"
- # force command name to be firefox for run-mozilla.sh
- # see abrowser_run_mozilla.patch
- CMDNAME_USER=thunderbird sh $LIBDIR/run-mozilla.sh $GDB "$LIBDIR/$META_NAME" -x $tmpfile
- exit $?
- else
- # force command name to be firefox for run-mozilla.sh
- # see abrowser_run_mozilla.patch
- CMDNAME_USER=thunderbird exec $LIBDIR/$META_NAME "$@"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement