Fclean_config.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/bash
  2. ######################################################
  3. # Author : Simona Flavoni for NEMO
  4. # Contact : sflod@locean-ipsl.upmc.fr
  5. #
  6. # Some functions called from makenemo
  7. # Fclean_config : config removing
  8. ######################################################
  9. #set -x
  10. set -o posix
  11. #set -u
  12. #set -e
  13. #+
  14. #
  15. # ================
  16. # Fclean_config.sh
  17. # ================
  18. #
  19. # ------------------------
  20. # Remove the configuration
  21. # ------------------------
  22. #
  23. # SYNOPSIS
  24. # ========
  25. #
  26. # ::
  27. #
  28. # $ Fclean_config.sh CONFNAME
  29. #
  30. #
  31. # DESCRIPTION
  32. # ===========
  33. #
  34. #
  35. # Remove the configuration:
  36. #
  37. # - remove CONFIG_NAME/WORK
  38. # - remove CONFIG_NAME/BLD
  39. # - remove CONFIG_NAME from TOOLS/TOOLS/COMPILE/cfg.txt
  40. #
  41. # EXAMPLES
  42. # ========
  43. #
  44. # ::
  45. #
  46. # $ ./Fclean_config.sh ORCA2_LIM
  47. #
  48. #
  49. # TODO
  50. # ====
  51. #
  52. # option debug
  53. #
  54. #
  55. # EVOLUTIONS
  56. # ==========
  57. #
  58. # $Id: Fclean_config.sh 2158 2010-10-20 17:30:03Z sflod $
  59. #
  60. #
  61. #
  62. # * creation
  63. #
  64. #-
  65. NEW_CONF=${x_n}
  66. if [ ${#NEW_CONF} -eq 0 ] ; then
  67. echo " "
  68. echo "No configuration specified, please use makenemo -n CONFIG clean_config "
  69. else
  70. echo "Are you sure that you want to remove this directory $NEW_CONF? [y/n] "
  71. read answer
  72. answer=`echo $answer | sed 's/^[y].*$/y/'`
  73. if [ -z "$answer" -o "x$answer" = "xy" ]; then
  74. # testing if configuration exists
  75. if [ "$(cat ${CONFIG_DIR}/cfg.txt | grep "${NEW_CONF} ")" == "" ] ; then
  76. echo "The configuration ${NEW_CONF} does not exist in file cfg.txt"
  77. echo "No removing configuration"
  78. echo " "
  79. else
  80. rm -rf ${CONFIG_DIR}/${NEW_CONF}
  81. sed -e "/${NEW_CONF} /d" ${CONFIG_DIR}/cfg.txt > ${CONFIG_DIR}/cfg.tmp
  82. mv ${CONFIG_DIR}/cfg.tmp ${CONFIG_DIR}/cfg.txt
  83. echo "${NEW_CONF} configuration REMOVED"
  84. fi
  85. else
  86. echo " "
  87. echo "nothing to remove"
  88. fi
  89. fi
  90. unset -v answer