You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 line
2.2KB

  1. #!/usr/bin/env sh
  2. ################################################################################
  3. #
  4. # Cake is a shell script for invoking CakePHP shell commands
  5. #
  6. # CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  7. # Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  8. #
  9. # Licensed under The MIT License
  10. # For full copyright and license information, please see the LICENSE.txt
  11. # Redistributions of files must retain the above copyright notice.
  12. #
  13. # @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  14. # @link https://cakephp.org CakePHP(tm) Project
  15. # @since 1.2.0
  16. # @license https://opensource.org/licenses/mit-license.php MIT License
  17. #
  18. ################################################################################
  19. # Canonicalize by following every symlink of the given name recursively
  20. canonicalize() {
  21. NAME="$1"
  22. if [ -f "$NAME" ]
  23. then
  24. DIR=$(dirname -- "$NAME")
  25. NAME=$(cd -P "$DIR" > /dev/null && pwd -P)/$(basename -- "$NAME")
  26. fi
  27. while [ -h "$NAME" ]; do
  28. DIR=$(dirname -- "$NAME")
  29. SYM=$(readlink "$NAME")
  30. NAME=$(cd "$DIR" > /dev/null && cd "$(dirname -- "$SYM")" > /dev/null && pwd)/$(basename -- "$SYM")
  31. done
  32. echo "$NAME"
  33. }
  34. # Find a CLI version of PHP
  35. findCliPhp() {
  36. for TESTEXEC in php php-cli /usr/local/bin/php
  37. do
  38. SAPI=$(echo "<?= PHP_SAPI ?>" | $TESTEXEC 2>/dev/null)
  39. if [ "$SAPI" = "cli" ]
  40. then
  41. echo $TESTEXEC
  42. return
  43. fi
  44. done
  45. echo "Failed to find a CLI version of PHP; falling back to system standard php executable" >&2
  46. echo "php";
  47. }
  48. # If current path is a symlink, resolve to real path
  49. realname="$0"
  50. if [ -L "$realname" ]
  51. then
  52. realname=$(readlink -f "$0")
  53. fi
  54. CONSOLE=$(dirname -- "$(canonicalize "$realname")")
  55. APP=$(dirname "$CONSOLE")
  56. # If your CLI PHP is somewhere that this doesn't find, you can define a PHP environment
  57. # variable with the correct path in it.
  58. if [ -z "$PHP" ]
  59. then
  60. PHP=$(findCliPhp)
  61. fi
  62. if [ "$(basename "$realname")" != 'cake' ]
  63. then
  64. exec "$PHP" "$CONSOLE"/cake.php "$(basename "$realname")" "$@"
  65. else
  66. exec "$PHP" "$CONSOLE"/cake.php "$@"
  67. fi
  68. exit

Powered by TurnKey Linux.