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.

prepareWorkspace.sh 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/usr/bin/env bash
  2. #
  3. # Licensed to the Apache Software Foundation (ASF) under one
  4. # or more contributor license agreements. See the NOTICE file
  5. # distributed with this work for additional information
  6. # regarding copyright ownership. The ASF licenses this file
  7. # to you under the Apache License, Version 2.0 (the
  8. # "License"); you may not use this file except in compliance
  9. # with the License. You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing,
  14. # software distributed under the License is distributed on an
  15. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. # KIND, either express or implied. See the License for the
  17. # specific language governing permissions and limitations
  18. # under the License.
  19. #
  20. # Author: Martin Stockhammer <martin_s@apache.org>
  21. # Date: 2017-05-24
  22. #
  23. # Removes directories that are not used anymore.
  24. ##
  25. ATTIC_DIRS="archiva-modules/archiva-base/archiva-indexer\
  26. archiva-modules/archiva-base/archiva-proxy-common\
  27. archiva-modules/archiva-base/archiva-maven2-common\
  28. archiva-modules/archiva-base/archiva-maven2-indexer\
  29. archiva-modules/archiva-base/archiva-maven2-metadata\
  30. archiva-modules/archiva-base/archiva-maven2-model\
  31. archiva-modules/archiva-base/archiva-proxy-maven\
  32. archiva-modules/archiva-scheduler/archiva-scheduler-indexing-maven2\
  33. archiva-modules/metadata/metadata-model-maven2\
  34. archiva-modules/plugins/maven2-repository\
  35. archiva-modules/archiva-base/archiva-converter\
  36. "
  37. REMOVE_DIRS=".indexer"
  38. TMP_DIRECTORY=".tmp"
  39. while [ ! -z "$1" ]; do
  40. case "$1" in
  41. -d)
  42. shift
  43. REPO_DIR=$1
  44. shift
  45. ;;
  46. *)
  47. shift
  48. ;;
  49. esac
  50. done
  51. if [ -e "${TMP_DIRECTORY}" ]; then
  52. rm -rf "${TMP_DIRECTORY}"
  53. fi
  54. mkdir -p "${TMP_DIRECTORY}"
  55. if [ ! -z "${REPO_DIR}" ]; then
  56. if [ -d "${REPO_DIR}" ]; then
  57. rm -rf "${REPO_DIR}"
  58. else
  59. echo "WARNING: Directory not found ${REPO_DIR}"
  60. fi
  61. fi
  62. for i in ${ATTIC_DIRS}; do
  63. if [ "X${i}" != "X" -a -d ${i} ]; then
  64. echo "Deleting directory ${i}"
  65. rm -rf ${i}
  66. fi
  67. done
  68. for i in ${REMOVE_DIRS}; do
  69. find . -type d -name "${i}" -print0 | xargs -0 rm -rvf
  70. done
  71. TMP_DIRS="/tmp/archiva /var/tmp/archiva"
  72. for MY_TMP in $TMP_DIRS; do
  73. if [ -e ${MY_TMP} ]; then
  74. echo "Trying to delete ${MY_TMP}"
  75. rm -rf ${MY_TMP} >/dev/null 2>&1
  76. fi
  77. if [ -e ${MY_TMP} ]; then
  78. echo "Trying to move ${MY_TMP} away"
  79. mv ${MY_TMP} ${MY_TMP}.$$
  80. fi
  81. if [ -e ${MY_TMP} ]; then
  82. echo "Warning there exists a temporary directory, that cannot be cleaned ${MY_TMP}"
  83. ls -latr ${MY_TMP}
  84. ls -latr $(dirname ${MY_TMP})
  85. fi
  86. done
  87. exit 0