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 <[email protected]>
- # Fabien Tassin <[email protected]>
- # Steve Langasek <[email protected]>
- # Modified for Thunderbird by:
- # Micah Gersten <[email protected]>
- # 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
- # We always move the thunderbird 2 profile ($HOMEDIR/.mozilla-thunderbird)
- # to $HOMEDIR/.thunderbird
- # if there exists a beta profile (first found: $HOMEDIR/.thunderbird-3.0)
- # and there is a standard thunderbird profile as well, ask the
- # user what to do. In case he decides to import the thunderbird 2.0 profile
- # settings, we keep the imported 2.0 profile, but rename the beta
- # profile by appending the suffix |.abandoned|. In case the user decides to
- # keep using the thunderbird 3.0 profile, we rename the original thunderbird profile
- # to .thunderbird-2.0-replaced and rename the beta profile to be |.thunderbird|.
- #
- # as a third option the user can defer his final decision. This will leave the
- # beta directories untouched, thus making the user use thunderbird 2 by default.
- #
- 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 != "" -a ! -d $HOMEDIR/$CURRENT.upstream ] ; then
- mv $HOMEDIR/$CURRENT $HOMEDIR/$CURRENT.upstream
- fi
- # Migrate only if $CURRENT isn't there (Only do this once)
- # If it exists, probably means that they already migrated
- if [ ! -d $HOMEDIR/$CURRENT ] ; then
- mv $HOMEDIR/$OLD_DIR $HOMEDIR/$CURRENT
- 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 thunderbird for run-mozilla.sh
- CMDNAME_USER=thunderbird sh $LIBDIR/run-mozilla.sh $GDB "$LIBDIR/$META_NAME" -x $tmpfile
- exit $?
- else
- # force command name to be thunderbird for run-mozilla.sh
- CMDNAME_USER=thunderbird exec $LIBDIR/$META_NAME "$@"
- fi
Advertisement
Add Comment
Please, Sign In to add comment