#!/bin/sh

# We don't want more than one instance running.

COMTAIL="$@"

URLPREFIX="`echo "$COMTAIL" | grep --extended-regexp "http://|ftp://|https://|file://|-mail|-edit|-addressbook|-calendar|-remote"`"
if [ "$URLPREFIX" = "" ];then
 [ "$COMTAIL" = "" ] || COMTAIL="file://${COMTAIL}"
fi
 
ps | grep "firefox\-bin" > /dev/null 2>&1
if [ $? -eq 0 ];then #=0 if found.
 exec /usr/lib/firefox/firefox-bin -a firefox -remote "openURL($COMTAIL,new-tab)"
else
 exec /usr/lib/firefox/firefox-bin $COMTAIL
fi
   
