Guest User

micah

a guest
Feb 14th, 2010
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.63 KB | None | 0 0
  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 <[email protected]>
  8. # Fabien Tassin <[email protected]>
  9. # Steve Langasek <[email protected]>
  10.  
  11. # Modified for Thunderbird by:
  12. # Micah Gersten <[email protected]>
  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. # We always move the thunderbird 2 profile ($HOMEDIR/.mozilla-thunderbird)
  72. # to $HOMEDIR/.thunderbird
  73. # if there exists a beta profile (first found: $HOMEDIR/.thunderbird-3.0)
  74. # and there is a standard thunderbird profile as well, ask the
  75. # user what to do. In case he decides to import the thunderbird 2.0 profile
  76. # settings, we keep the imported 2.0 profile, but rename the beta
  77. # profile by appending the suffix |.abandoned|. In case the user decides to
  78. # keep using the thunderbird 3.0 profile, we rename the original thunderbird profile
  79. # to .thunderbird-2.0-replaced and rename the beta profile to be |.thunderbird|.
  80. #
  81. # as a third option the user can defer his final decision. This will leave the
  82. # beta directories untouched, thus making the user use thunderbird 2 by default.
  83. #
  84.  
  85. FOUND_OLD=""
  86. OLD_DIR=.mozilla-thunderbird
  87. if [ -d $HOMEDIR/$OLD_DIR ] ; then
  88. FOUND_OLD=$OLD_DIR;
  89. fi
  90.  
  91. CURRENT=.thunderbird
  92. FOUND_CURRENT=""
  93. if [ -d $HOMEDIR/$CURRENT] ; then
  94. FOUND_CURRENT=$CURRENT
  95. fi
  96.  
  97. FOUND_BETA=""
  98. BETA_LIST=""
  99. for betaname in .thunderbird-3.0; do
  100. if [ -d $HOMEDIR/$betaname ]; then
  101. BETA_LIST="$BETA_LIST $betaname"
  102. FOUND_BETA=$betaname
  103. fi
  104. done
  105.  
  106. if [ "$FOUND_OLD" != "" ] ; then
  107. if [ $FOUND_CURRENT != "" -a ! -d $HOMEDIR/$CURRENT.upstream ] ; then
  108. mv $HOMEDIR/$CURRENT $HOMEDIR/$CURRENT.upstream
  109. fi
  110. # Migrate only if $CURRENT isn't there (Only do this once)
  111. # If it exists, probably means that they already migrated
  112. if [ ! -d $HOMEDIR/$CURRENT ] ; then
  113. mv $HOMEDIR/$OLD_DIR $HOMEDIR/$CURRENT
  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 thunderbird for run-mozilla.sh
  158. CMDNAME_USER=thunderbird sh $LIBDIR/run-mozilla.sh $GDB "$LIBDIR/$META_NAME" -x $tmpfile
  159. exit $?
  160. else
  161. # force command name to be thunderbird for run-mozilla.sh
  162. CMDNAME_USER=thunderbird exec $LIBDIR/$META_NAME "$@"
  163. fi
  164.  
Advertisement
Add Comment
Please, Sign In to add comment