config.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. # get array of plugin names
  3. # set IFS to newline so spaces aren't treated as delimiters in array
  4. temp_ifs="$IFS"
  5. IFS=$'\n'
  6. script_path="$BASH_SOURCE"
  7. script_path="$(dirname "$script_path")"
  8. ALL_PLUGINS=(`cd "${script_path}/../plugins" && find -L . -maxdepth 1 -type d`)
  9. PLUGIN_NUM=${#ALL_PLUGINS[@]}
  10. for ((i=0; i < ${PLUGIN_NUM}; i++))
  11. do
  12. plugin_name="${ALL_PLUGINS[$i]}"
  13. ALL_PLUGINS[$i]="${plugin_name#./}"
  14. done
  15. export ALL_PLUGINS
  16. echo "ALL_PLUGINS = (${ALL_PLUGINS[@]})"
  17. # restore IFS
  18. IFS="$temp_ifs"
  19. unset temp_ifs
  20. # define the plugin root directory & publish target directory
  21. export TARGET_DIR_NAME="publish"
  22. if [ ! ${PLUGIN_ROOT} ]; then
  23. pushd ../
  24. export PLUGIN_ROOT="$(pwd)"
  25. popd
  26. fi
  27. export TARGET_ROOT="${PLUGIN_ROOT}/${TARGET_DIR_NAME}"
  28. echo "PLUGIN_ROOT = ${PLUGIN_ROOT}"
  29. echo "TARGET_ROOT = ${TARGET_ROOT}"
  30. # get a string include all plugins name(separate with ':')
  31. export PLUGINS_CAN_SELECT=""
  32. for ((i=0; i < ${PLUGIN_NUM}; i++))
  33. do
  34. plugin_name="${ALL_PLUGINS[$i]}"
  35. PLUGINS_CAN_SELECT="${PLUGINS_CAN_SELECT}${PLUGINS_CAN_SELECT:+:}${plugin_name}"
  36. done
  37. echo "PLUGINS_CAN_SELECT = ${PLUGINS_CAN_SELECT}"