#!/bin/sh

# first find which PHP binary to use
if test "x$PHP_PEAR_PHP_BIN" != "x"; then
  PHP="$PHP_PEAR_PHP_BIN"
else
  if test "/usr/bin/env /www/roundcube/releases/roundcubemail-1.1.3/vendor/bin/composer-php" = '@'php_bin'@'; then
    PHP=php
  else
    PHP="/usr/bin/env /www/roundcube/releases/roundcubemail-1.1.3/vendor/bin/composer-php"
  fi
fi

# then look for the right pear include dir
if test "x$PHP_PEAR_INSTALL_DIR" != "x"; then
  INCDIR=$PHP_PEAR_INSTALL_DIR
  INCARG="-d include_path=$PHP_PEAR_INSTALL_DIR"
else
  if test "/www/roundcube/releases/roundcubemail-1.1.3/vendor/pear-pear.php.net/PEAR" = '@'php_dir'@'; then
    INCDIR=`dirname $0`
    INCARG=""
  else
    INCDIR="/www/roundcube/releases/roundcubemail-1.1.3/vendor/pear-pear.php.net/PEAR"
    INCARG="-d include_path=/www/roundcube/releases/roundcubemail-1.1.3/vendor/pear-pear.php.net/PEAR"
  fi
fi

exec $PHP -C -n -q $INCARG -d date.timezone=UTC -d output_buffering=1 -d variables_order=EGPCS -d safe_mode=0 -d register_argc_argv="On" $INCDIR/peclcmd.php "$@"
