Ein für Shopware 6 vorbereitet Systemmanagment.
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.

150 lines
3.4 KiB

  1. #!/bin/bash
  2. set -e
  3. project_manager_dir="$(readlink -f "$(dirname "$(readlink -f ${BASH_SOURCE[0]})")/..")"
  4. source "$project_manager_dir/bin/includes/includes"
  5. if [ -f "$project_manager_dir/etc/config" ]
  6. then
  7. source "$project_manager_dir/etc/config"
  8. fi
  9. if [ -f "$project_manager_dir/etc/projects" ]
  10. then
  11. source "$project_manager_dir/etc/projects"
  12. fi
  13. function use {
  14. echo
  15. echoMainTitle "Sumedia Project Manager"
  16. echoSmall "Manager: $project_manager_dir"
  17. echoSmall "Workspaces: $workspaces_dir"
  18. echo
  19. echoSubTitle "Usage:"
  20. echo
  21. echo "project-manager [command] [command-args]"
  22. echo "project-manager [plugin:command] [command-args]"
  23. echo
  24. echo "--help Prints this message"
  25. echo "--help [command] Prints the help message for a command"
  26. echo "--help [plugin:command] Prints the help message for a command"
  27. echo "--list-commands List all commands"
  28. echo "--list-commands [plugin] List all plugin commands"
  29. echo "--list-plugins List all plugins"
  30. echo
  31. }
  32. function list {
  33. local dir=$1
  34. echo >&2
  35. echoMainTitle "List" >&2
  36. echo >&2
  37. echoSubTitle "List $dir" >&2
  38. echo >&2
  39. dir=($(ls -t "$project_manager_dir/$dir"))
  40. for script in "${dir[@]}"
  41. do
  42. echo "- $script" >&2
  43. done
  44. echo >&2
  45. }
  46. help="$(getParameter "--help" false "$*")"
  47. list_commands="$(getParameter "--list-commands" false "$*")"
  48. list_plugins="$(getParameter "--list-plugins" false "$*")"
  49. if [[ "$1" == *"--"* ]]; then key=2; else key=1; fi
  50. param="$(eval "echo \"\$${key}\"")"
  51. if [[ "$param" == *":"* ]]
  52. then
  53. command="$(echo "$param" | cut -f2 -d':')"
  54. plugin="$(echo "$param" | cut -f1 -d':')"
  55. else
  56. command=$param
  57. plugin=""
  58. fi
  59. if [ ! -f "$project_manager_dir/etc/config" ] || [ ! -f "$project_manager_dir/etc/projects" ]
  60. then
  61. command="install-project-manager"
  62. plugin=""
  63. fi
  64. if [ "$1" == "" ] && [ "command" == "" ]
  65. then
  66. use
  67. exit
  68. fi
  69. if [ "$help" == true ] || [ "$list_commands" == true ] || [ "$list_plugins" == true ]
  70. then
  71. if [ "$command" == "" ] && [ "$list_commands" == false ] && [ "$list_plugins" == false ]
  72. then
  73. use
  74. exit
  75. elif [ "$command" != "" ] && [ "$plugin" != "" ] && [ "$help" == true ]
  76. then
  77. file="$project_manager_dir/plugins/$plugin/commands/$command"
  78. if [ ! -f "$file" ]
  79. then
  80. echo
  81. echoError "No such file or directory: $file"
  82. echo
  83. exit
  84. else
  85. source "$file" --help
  86. exit
  87. fi
  88. elif [ "$command" != "" ] && [ "$help" == true ]
  89. then
  90. file="$project_manager_dir/bin/commands/$command"
  91. if [ ! -f "$file" ]
  92. then
  93. echo
  94. echoError "No such file or directory: $file"
  95. echo
  96. exit
  97. else
  98. source "$file" --help
  99. exit
  100. fi
  101. elif [ "$command" != "" ] && [ "$list_commands" == true ]
  102. then
  103. list "plugins/$command/commands"
  104. elif [ "$list_commands" == true ]
  105. then
  106. list "bin/commands"
  107. elif [ "$list_plugins" == true ]
  108. then
  109. list "plugins"
  110. fi
  111. else
  112. if [ "$plugin" != "" ]
  113. then
  114. file="$project_manager_dir/plugins/$plugin/commands/$command"
  115. else
  116. file="$project_manager_dir/bin/commands/$command"
  117. fi
  118. if [ ! -f "$file" ]
  119. then
  120. echo
  121. echoError "No such file or directory: $file"
  122. echo
  123. exit
  124. else
  125. source "$file" "${@:2}"
  126. fi
  127. echo
  128. echoSubTitle "Running postscripts ..."
  129. postScript "$project_manager_dir/bin/postscripts/project-manager"
  130. echo
  131. echoSuccess "Project Manager done"
  132. echo
  133. fi