daily pastebin goal
17%
SHARE
TWEET

micah

a guest Feb 12th, 2010 37 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. # Firefox launcher containing a Profile migration helper for
  4. # temporary profiles used during alpha and beta phases.
  5.  
  6. # Original Authors:
  7. #  Alexander Sack <asac@jwsdot.com>
  8. #  Fabien Tassin <fta@sofaraway.org>
  9. #  Steve Langasek <steve.langasek@canonical.com>
  10.  
  11. # Modified for Thunderbird by:
  12. #  Micah Gersten <micahg@ubuntu.com>
  13. # License: GPLv2 or later
  14.  
  15. # If there's a ~/.mozilla-thunderbird profile, copy to .thunderbird
  16. # If nothing is found, we'll go for a fresh run and let thunderbird create a
  17. # default profile for us.
  18.  
  19. HOMEDIR=$HOME
  20. LIBDIR=@LIBDIR@
  21. APPVER=@APPVER@
  22. META_NAME=@META_NAME@
  23. GDB=/usr/bin/gdb
  24. DROPPED=abandoned
  25.  
  26. NAME=`which "$0"`
  27. if [ "x$META_NAME" != "x" ] ; then
  28.   NAME="${NAME%%-$APPVER}"
  29. fi
  30. APPNAME="$(basename "$NAME")"
  31.  
  32. while [ ! -f "$LIBDIR/$APPNAME" ] && [ -L "$NAME" ]; do
  33.   TARGET="$(readlink "$NAME")"
  34.   if [ "x$TARGET" = "x$(basename "$TARGET")" ]; then
  35.     TARGET="$(dirname "$NAME")/$TARGET"
  36.   fi
  37.   if [ "x$META_NAME" != "x" ] ; then
  38.     TARGET=${TARGET%%-$APPVER}
  39.   fi
  40.   NAME="$TARGET"
  41.   APPNAME="$(basename "$NAME")"
  42.   if [ "x$APPNAME" = "xthunderbird.sh" ]; then
  43.     APPNAME=thunderbird
  44.     break
  45.   fi
  46. done
  47.  
  48. usage () {
  49.   $LIBDIR/$APPNAME -h | sed -e 's,/.*/,,'
  50.   echo
  51.   echo "        -g or --debug           Start within $GDB (Must be first)"
  52. }
  53.  
  54. want_debug=0
  55. while [ $# -gt 0 ]; do
  56.   case "$1" in
  57.     -h | --help | -help )
  58.       usage
  59.       exit 0 ;;
  60.     -g | --debug )
  61.       want_debug=1
  62.       shift ;;
  63.     -- ) # Stop option prcessing
  64.       shift
  65.       break ;;
  66.     * )
  67.       break ;;
  68.   esac
  69. done
  70.  
  71. # if there exists a beta profile (first found: $HOMEDIR/firefox-3.5,
  72. # $HOMEDIR/firefox-3.1) and there is a standard firefox profile as well, ask the
  73. # user what to do. In case he decides to import the firefox 3.0 profile
  74. # settings, we keep the firefox directory untouched, but rename the beta
  75. # profile by appending the suffix |.abandoned|. In case the user decides to
  76. # keep using the thunderbird 2.0 profile, we rename the original firefox profile to
  77. # firefox.3.0-replaced and rename the beta profile to be |.mozilla/firefox|.
  78. #
  79. # as a third option the user can defer his final decision. This will leave the
  80. # directories untouched, thus making the user use the old firefox profile by
  81. # default.
  82. #
  83. # in addition, even older profiles are renamed too, by appending |.abandoned|
  84. # to their name.
  85.  
  86. FOUND_OLD=""
  87. OLD_DIR=.mozilla-thunderbird
  88. if [ -d $HOMEDIR/$OLD_DIR ] ; then
  89.   FOUND_OLD=$OLD_DIR;
  90. fi
  91.  
  92. CURRENT=.thunderbird
  93. FOUND_CURRENT=""
  94. if [ -d $HOMEDIR/$CURRENT] ; then
  95.   FOUND_CURRENT=$CURRENT
  96. fi
  97.  
  98. FOUND_BETA=""
  99. BETA_LIST=""
  100. for betaname in .thunderbird-3.0; do
  101.   if [ -d $HOMEDIR/$betaname ]; then
  102.     BETA_LIST="$BETA_LIST $betaname"
  103.     FOUND_BETA=$betaname
  104.   fi
  105. done
  106.  
  107. if [ "$FOUND_OLD" != "" ] ; then
  108.         if [ $FOUND_CURRENT != "" ] ; then
  109.                 if [ ! -d $HOMEDIR/$CURRENT.upstream ] ; then
  110.                         mv $HOMEDIR/$CURRENT $HOMEDIR/$CURRENT.upstream
  111.                 else
  112.                         mv $HOMEDIR/$CURRENT $HOMEDIR/$CURRENT.$$
  113.                 fi
  114.         fi
  115. fi
  116.  
  117. if [ "$FOUND_BETA" != "" ] ; then
  118.   echo -n "Found Beta Participation ..."
  119.   $LIBDIR/tb-beta-profile-migration-dialog
  120.   result=$?
  121.   if [ $result = 1 ]; then
  122.         if [ $FOUND_CURRENT != "" ] ; then
  123.                 if [ ! -d $HOMEDIR/$CURRENT-2.0-replaced ] ; then
  124.                         mv $HOMEDIR/$CURRENT $HOMEDIR/$CURRENT-2.0-replaced
  125.                 else
  126.                         mv $HOMEDIR/$CURRENT $HOMEDIR/$CURRENT.$$
  127.                 fi
  128.         fi
  129.      mv $HOMEDIR/$FOUND_BETA $HOMEDIR/$CURRENT
  130.      for beta in $BETA_LIST ; do
  131.        if [ $beta != $FOUND_BETA ] ; then
  132.          mv $HOMEDIR/$beta $HOMEDIR/$beta.$DROPPED
  133.        fi
  134.      done
  135.      echo " keep beta profile."
  136.   elif [ $result = 2 ]; then
  137.      #TB2 Profile already imported, so just move Beta profile out of the way
  138.      for beta in $BETA_LIST ; do
  139.        mv $HOMEDIR/$beta $HOMEDIR/$beta.$DROPPED
  140.      done
  141.      echo " use thunderbird 2.0 profile."
  142.   else
  143.      echo " use thunderbird 2.0 profile, but will ask again next time."
  144.   fi
  145.   echo " ... will check again next time."
  146. fi
  147.  
  148. if [ $want_debug -eq 1 ] ; then
  149.   if [ ! -x $GDB ] ; then
  150.     echo "Sorry, can't find usable $GDB. Please install it."
  151.     exit 1
  152.   fi
  153.   tmpfile=`mktemp /tmp/mozargs.XXXXXX` || { echo "Cannot create temporary file" >&2; exit 1; }
  154.   trap " [ -f \"$tmpfile\" ] && /bin/rm -f -- \"$tmpfile\"" 0 1 2 3 13 15
  155.   echo "set args ${1+"$@"}" > $tmpfile
  156.   echo "sh $LIBDIR/run-mozilla.sh $GDB "$LIBDIR/$META_NAME"-bin -x $tmpfile"
  157.   # force command name to be firefox for run-mozilla.sh
  158.   # see abrowser_run_mozilla.patch
  159.   CMDNAME_USER=thunderbird sh $LIBDIR/run-mozilla.sh $GDB "$LIBDIR/$META_NAME" -x $tmpfile
  160.   exit $?
  161. else
  162.   # force command name to be firefox for run-mozilla.sh
  163.   # see abrowser_run_mozilla.patch
  164.   CMDNAME_USER=thunderbird exec $LIBDIR/$META_NAME "$@"
  165. fi
RAW Paste Data
Top