36ac449
#!/bin/sh
36ac449
#
36ac449
# Startup script for the fedora.us Thunderbird RPM
36ac449
# (based on the Mozilla RPM launch script)
36ac449
#
36ac449
ff6676c
MOZ_LIB_DIR="/usr/lib"
ff6676c
if [ -x "/usr/lib64/thunderbird-TBIRD_VERSION/thunderbird-bin" ]
ff6676c
then
ff6676c
  MOZ_LIB_DIR="/usr/lib64"
ff6676c
fi
ff6676c
ff6676c
MOZILLA_FIVE_HOME="$MOZ_LIB_DIR/thunderbird-TBIRD_VERSION"
ff6676c
MRE_HOME="$MOZ_LIB_DIR/thunderbird-TBIRD_VERSION"
36ac449
export MOZILLA_FIVE_HOME MRE_HOME
36ac449
fec1589
MOZ_PROGRAM=$MRE_HOME/thunderbird-bin
36ac449
#MOZ_CLIENT_PROGRAM="$MRE_HOME/mozilla-xremote-client -a thunderbird"
fec1589
MOZ_CLIENT_PROGRAM="$MRE_HOME/thunderbird-bin -remote" 
36ac449
0d16653
##
e727439
## Set MOZ_ENABLE_PANGO is no longer used because Pango is enabled by default
e727439
## you may use MOZ_DISABLE_PANGO=1 to force disabling of pango
0d16653
##
e727439
#MOZ_DISABLE_PANGO=1
ff6676c
#export MOZ_DISABLE_PANGO
0d16653
20f8dae
36ac449
function check_running() {
36ac449
    $MOZ_CLIENT_PROGRAM 'ping()' 2>/dev/null >/dev/null
36ac449
    RETURN_VAL=$?
36ac449
    if [ "$RETURN_VAL" -eq "2" ]; then
36ac449
      echo 0
36ac449
      return 0
36ac449
    else
36ac449
      echo 1
36ac449
      return 1
36ac449
    fi
36ac449
}
36ac449
36ac449
function rm_shit() {
36ac449
    find $HOME/.thunderbird -name XUL.mfasl 2>/dev/null | xargs rm -f
36ac449
}
36ac449
36ac449
# currently unused
36ac449
MOZARGS=""
36ac449
36ac449
ALREADY_RUNNING=`check_running`
36ac449
36ac449
# If no command-line arguments given...
36ac449
if [ -z "$1" ]; then
36ac449
    if [ "${ALREADY_RUNNING}" -eq "1" ]; then
36ac449
        exec $MOZ_CLIENT_PROGRAM "xfeDoCommand(openInbox)" >/dev/null 2>&1
36ac449
    else
36ac449
        rm_shit
36ac449
        exec $MOZ_PROGRAM $MOZARGS >/dev/null 2>&1
36ac449
    fi
36ac449
fi
36ac449
36ac449
for arg in $@ ; do
36ac449
    case "$1" in
36ac449
    -remote)
36ac449
        shift
36ac449
        exec $MOZ_PROGRAM -remote "$@"
36ac449
        ;;
36ac449
36ac449
    -mail)
36ac449
        shift
36ac449
        if [ "${ALREADY_RUNNING}" -eq "1" ]; then
36ac449
            # remove 'mailto:' prefix
36ac449
            ARGS="`echo $@ | sed 's/^mailto://'`"
36ac449
            exec $MOZ_CLIENT_PROGRAM "mailto($ARGS)"
36ac449
        else
36ac449
            rm_shit
36ac449
            exec $MOZ_PROGRAM $MOZARGS -mail "$@"
36ac449
        fi
36ac449
        ;;
36ac449
36ac449
    -compose)
36ac449
        shift
36ac449
        if [ "${ALREADY_RUNNING}" -eq "1" ]; then
36ac449
            # remove 'mailto:' prefix
36ac449
            ARGS="`echo $@ | sed 's/^mailto://'`"
36ac449
            exec $MOZ_CLIENT_PROGRAM "mailto($ARGS)"
36ac449
        else
36ac449
            rm_shit
36ac449
            exec $MOZ_PROGRAM $MOZARGS -compose "$@"
36ac449
        fi
36ac449
        ;;
36ac449
36ac449
    *)
36ac449
        # for now, pass it on and hope for the best
36ac449
        exec $MOZ_PROGRAM $MOZARGS "$@"
36ac449
        ;;
36ac449
    esac
36ac449
    shift
36ac449
done
36ac449