/bin/zotonic

https://code.google.com/p/zotonic/ · #! · 50 lines · 46 code · 4 blank · 0 comment · 0 complexity · c8801ac03fef3cc73b7ff386eb573fc1 MD5 · raw file

  1. #!/usr/bin/env bash
  2. #
  3. # Copyright 2011 Lloyd R. Prentice
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. # usage zotonic [command] [arguments...]
  18. #
  19. if type python &> /dev/null
  20. then
  21. export ZOTONIC=${ZOTONIC:=`python -c "import os,sys;print os.path.realpath(\"$0/../..\")"`}
  22. else
  23. export ZOTONIC=${ZOTONIC:=$(cd `dirname $0`/..;pwd)}
  24. fi
  25. export ZOTONIC_SCRIPTS="$ZOTONIC/src/scripts"
  26. if [ ! $1 ]
  27. then
  28. echo Usage: `basename $0` [command] 1>&2
  29. echo 1>&2
  30. echo Where [command] is one of: 1>&2
  31. CMDS="`ls $ZOTONIC_SCRIPTS | grep zotonic- | grep -v _ | sed 's/zotonic-//g'`"
  32. echo $CMDS 1>&2
  33. echo 1>&2
  34. echo see doc/ZotonicCommands.txt for more info 1>&2
  35. echo 1>&2
  36. exit 127
  37. elif [ ! -f "$ZOTONIC_SCRIPTS/zotonic-$1" ]; then
  38. echo Command not found: $1 1>&2
  39. exit 127
  40. else
  41. . $ZOTONIC_SCRIPTS/helpers/zotonic_setup
  42. $ZOTONIC_SCRIPTS/zotonic-$1 ${@:2}
  43. EXIT="$?"
  44. . $ZOTONIC_SCRIPTS/helpers/zotonic_teardown
  45. exit $EXIT
  46. fi