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.

134 lines
2.8 KiB

  1. #!/bin/bash
  2. ### DO NOT EDIT THIS FILE
  3. source "$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." &> /dev/null && pwd)/etc/config"
  4. source "$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." &> /dev/null && pwd)/etc/projects"
  5. function usage {
  6. echo
  7. echoMainTitle "Removes a project"
  8. echo
  9. echoSubTitle "Usage:"
  10. echo
  11. echo "remove-project [shortname]"
  12. echo
  13. echo "This will remove the project and move the project files to ./.trash"
  14. echo
  15. echo "--help Prints this message"
  16. echo
  17. }
  18. help="$(getParameter "--help" false "$*")"
  19. if [ "$help" == true ] || [ "$1" == "" ]
  20. then
  21. usage
  22. exit
  23. fi
  24. shortname="$(getArgument "$1" "$(usage)" true)"
  25. customer="$(getCustomerFromShortname "$shortname")"
  26. project="$(getProjectFromShortname "$shortname")"
  27. index=false
  28. for i in "${!shortnames[@]}"
  29. do
  30. if [ "${shortnames[$i]}" == "$shortname" ]
  31. then
  32. index="$i"
  33. fi
  34. done
  35. if [ "$index" == false ]
  36. then
  37. echo
  38. echoError "Could not find project: $shortname"
  39. echo
  40. exit
  41. fi
  42. echo
  43. echoMainTitle "Remove project"
  44. echo
  45. echoSubTitle "Please verify data"
  46. echo
  47. echo "Project Path: $workspaces_dir/$customer/$project"
  48. echo "Project Data Path: $project_manager_dir/data/$customer/$project"
  49. echo
  50. confirm
  51. echo
  52. echo "Moving files to trash"
  53. customer_dir_list=($(ls -t "$project_manager_dir/data/$customer"))
  54. has_more_dirs=$(if [ "${#customer_dir_list[@]}" -gt 1 ]; then echo true; else echo false; fi)
  55. rand=$(cat /proc/sys/kernel/random/uuid)
  56. trash_path="$project_manager_dir/.trash/$rand"
  57. mkdir "$trash_path"
  58. mkdir "$trash_path/data"
  59. mkdir "$trash_path/workspace"
  60. mkdir "$trash_path/data/$customer"
  61. mkdir "$trash_path/workspace/$customer"
  62. mv "$project_manager_dir/data/$customer/$project" "$trash_path/data/$customer/$project"
  63. mv "$workspaces_dir/$customer/$project" "$trash_path/workspace/$customer/$project"
  64. if [ "$has_more_dirs" != true ]
  65. then
  66. rmdir "$project_manager_dir/data/$customer"
  67. rmdir "$workspaces_dir/$customer"
  68. fi
  69. nr=0
  70. projects_string='';
  71. for i in "${!projects[@]}"
  72. do
  73. if [ "$i" != "$index" ]
  74. then
  75. ((nr=nr+1))
  76. projects_string+="$(echo -e "\n\t'${projects[$i]}' # $nr")"
  77. fi
  78. done
  79. nr=0
  80. shortnames_string='';
  81. for i in "${!shortnames[@]}"
  82. do
  83. if [ "$i" != "$index" ]
  84. then
  85. ((nr=nr+1))
  86. shortnames_string+="$(echo -e "\n\t'${shortnames[$i]}' # $nr")"
  87. fi
  88. done
  89. nr=0
  90. customers_string='';
  91. for i in "${!customers[@]}"
  92. do
  93. if [ "$i" != "$index" ]
  94. then
  95. ((nr=nr+1))
  96. customers_string+="$(echo -e "\n\t'${customers[$i]}' # $nr")"
  97. fi
  98. done
  99. cat <<- EOF > "$project_manager_dir/etc/projects"
  100. #!/bin/bash
  101. projects=($projects_string
  102. )
  103. shortnames=($shortnames_string
  104. )
  105. customers=($customers_string
  106. )
  107. EOF
  108. echo
  109. echoSubTitle "Running postscripts ..."
  110. postScript "$path/bin/postscripts/commands/remove-project"
  111. postScript "$workspaces_dir/$customer/$project/bin/postscripts/commands/remove-project"
  112. echo
  113. echoSuccess "Project has been remove, (moved to ./.trash)"
  114. echo