post_install.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #!/bin/bash
  2. ################################################################################
  3. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. ################################################################################
  17. SRC_DIR=$(dirname $0)
  18. TARGET_DIR=/usr/bin
  19. # Files in bin/ need to create/remove symbolic links
  20. ####################################################
  21. files_to_link=(
  22. 'dfuplus'
  23. 'ecl'
  24. 'eclcc'
  25. 'ecl-packagemap'
  26. 'eclplus'
  27. 'ecl-queries'
  28. 'ecl-roxie'
  29. 'soapplus'
  30. 'wuget'
  31. 'ecl-bundle'
  32. )
  33. # Check if this is post uninstall
  34. #################################
  35. IS_UNINSTALL=0
  36. [ "$1" = "-u" ] && IS_UNINSTALL=1
  37. # Get absolute path of clienttools bin directory
  38. ################################################
  39. CUR_DIR=$(pwd)
  40. [ "$SRC_DIR" != "." ] && cd $SRC_DIR
  41. SRC_DIR=$(pwd)
  42. CT_HOME=$(echo $SRC_DIR | sed -n "s/^\(.*clienttools\)\(.*\)/\1/p")
  43. CT_BIN=${CT_HOME}/bin
  44. PY2_BIN=${CT_HOME}/versioned/python2
  45. ECL_TEST_DIR=${CT_HOME}/testing/regress
  46. cd $CUR_DIR
  47. # Handle symbolic links
  48. # Only proceed if HPCC Platform is not installed
  49. ################################################
  50. [ -e /opt/HPCCSystems/etc/init.d/hpcc-init ] && exit 0
  51. if [ $IS_UNINSTALL -eq 0 ]
  52. then
  53. # Add symbolic link
  54. for file in ${files_to_link[@]}
  55. do
  56. [ -e ${CT_BIN}/${file} ] && \
  57. ln -sf ${CT_BIN}/${file} ${TARGET_DIR}/${file}
  58. done
  59. [ -e ${ECL_TEST_DIR}/ecl-test ] && \
  60. ln -sf ${ECL_TEST_DIR}/ecl-test ${TARGET_DIR}/ecl-test
  61. [ -e ${PY2_BIN}/libpy2embed.so ] && \
  62. ln -sf ${PY2_BIN}/libpy2embed.so ${PY2_BIN}/libpyembed.so
  63. else
  64. # Remove symbolic link
  65. for file in ${files_to_link[@]}
  66. do
  67. [ ! -e ${TARGET_DIR}/${file} ] && continue
  68. ls -l ${TARGET_DIR}/${file} | egrep -q "${CT_BIN}/${file}$"
  69. [ $? -eq 0 ] && rm -rf ${TARGET_DIR}/${file}
  70. done
  71. if [ -e ${TARGET_DIR}/ecl-test ]
  72. then
  73. ls -l ${TARGET_DIR}/ecl-test | egrep -q "${ECL_TEST_DIR}/ecl-test"
  74. [ $? -eq 0 ] && rm -rf ${TARGET_DIR}/ecl-test
  75. fi
  76. if [ -e ${PY2_BIN}/libpyembed.so ]
  77. then
  78. ls -l ${PY2_BIN}/libpyembed.so | egrep -q "${PY2_BIN}/libpy2embed.so"
  79. [ $? -eq 0 ] && rm -rf ${PY2_BIN}/libpyembed.so
  80. fi
  81. fi
  82. exit 0