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.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. REMOVE_DIRS=".indexer"
  27. TMP_DIRECTORY=".tmp"
  28. while [ ! -z "$1" ]; do
  29. case "$1" in
  30. -d)
  31. shift
  32. REPO_DIR=$1
  33. shift
  34. ;;
  35. *)
  36. shift
  37. ;;
  38. esac
  39. done
  40. if [ -e "${TMP_DIRECTORY}" ]; then
  41. rm -rf "${TMP_DIRECTORY}"
  42. fi
  43. mkdir -p "${TMP_DIRECTORY}"
  44. if [ ! -z "${REPO_DIR}" ]; then
  45. if [ -d "${REPO_DIR}" ]; then
  46. rm -rf "${REPO_DIR}"
  47. else
  48. echo "WARNING: Directory not found ${REPO_DIR}"
  49. fi
  50. fi
  51. for i in ${ATTIC_DIRS}; do
  52. if [ "X${i}" != "X" -a -d ${i} ]; then
  53. echo "Deleting directory ${i}"
  54. rm -rf ${i}
  55. fi
  56. done
  57. for i in ${REMOVE_DIRS}; do
  58. find . -type d -name "${i}" -print0 | xargs -0 rm -rvf
  59. done
  60. TMP_DIRS="/tmp/archiva /var/tmp/archiva"
  61. for MY_TMP in $TMP_DIRS; do
  62. if [ -e ${MY_TMP} ]; then
  63. echo "Trying to delete ${MY_TMP}"
  64. rm -rf ${MY_TMP} >/dev/null 2>&1
  65. fi
  66. if [ -e ${MY_TMP} ]; then
  67. echo "Trying to move ${MY_TMP} away"
  68. mv ${MY_TMP} ${MY_TMP}.$$
  69. fi
  70. if [ -e ${MY_TMP} ]; then
  71. echo "Warning there exists a temporary directory, that cannot be cleaned ${MY_TMP}"
  72. ls -latr ${MY_TMP}
  73. ls -latr $(dirname ${MY_TMP})
  74. fi
  75. done
  76. exit 0