jexefy-all.sh 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. # /////////////////////////////////////////////////////////////////////////////
  2. # REFCODES.ORG
  3. # =============================================================================
  4. # This code is copyright (c) by Siegfried Steiner, Munich, Germany and licensed
  5. # under the following (see "http://en.wikipedia.org/wiki/Multi-licensing")
  6. # licenses:
  7. # =============================================================================
  8. # GNU General Public License, v3.0 ("http://www.gnu.org/licenses/gpl-3.0.html")
  9. # =============================================================================
  10. # Apache License, v2.0 ("http://www.apache.org/licenses/LICENSE-2.0")
  11. # =============================================================================
  12. # Please contact the copyright holding author(s) of the software artifacts in
  13. # question for licensing issues not being covered by the above listed licenses,
  14. # also regarding commercial licensing models or regarding the compatibility
  15. # with other open source licenses.
  16. # /////////////////////////////////////////////////////////////////////////////
  17. #!/bin/bash
  18. # ------------------------------------------------------------------------------
  19. # INIT:
  20. # ------------------------------------------------------------------------------
  21. CURRENT_PATH="$(pwd)"
  22. SCRIPT_PATH="$(dirname $0)"
  23. cd "${SCRIPT_PATH}"
  24. SCRIPT_PATH="$(pwd)"
  25. cd "${CURRENT_PATH}"
  26. SCRIPT_DIR="${SCRIPT_PATH##*/}"
  27. SCRIPT_NAME="$(basename $0 .sh)"
  28. PARENT_PATH="$(realpath $(dirname $0)/..)"
  29. PARENT_DIR="${PARENT_PATH##*/}"
  30. MODULE_NAME="$(echo -e "${SCRIPT_DIR}" | cut -d- -f3- )"
  31. if [ -z "${MODULE_NAME}" ]; then
  32. MODULE_NAME="$(echo -e "${SCRIPT_DIR}" | cut -d- -f2- )"
  33. if [ -z "${MODULE_NAME}" ]; then
  34. MODULE_NAME="${SCRIPT_DIR}"
  35. fi
  36. fi
  37. if [ -z ${COLUMNS} ] ; then
  38. export COLUMNS=$(tput cols)
  39. fi
  40. # ------------------------------------------------------------------------------
  41. # ANSI ESCAPE CODES:
  42. # ------------------------------------------------------------------------------
  43. ESC_BOLD="\E[1m"
  44. ESC_FAINT="\E[2m"
  45. ESC_FG_RED="\E[31m"
  46. ESC_FG_GREEN="\E[32m"
  47. ESC_FG_YELLOW="\E[33m"
  48. ESC_FG_BLUE="\E[34m"
  49. ESC_FG_MAGENTA="\E[35m"
  50. ESC_FG_CYAN="\E[36m"
  51. ESC_FG_WHITE="\E[37m"
  52. ESC_RESET="\E[0m"
  53. # ------------------------------------------------------------------------------
  54. # PRINTLN:
  55. # ------------------------------------------------------------------------------
  56. function printLn {
  57. char="-"
  58. if [[ $# == 1 ]] ; then
  59. char="$1"
  60. fi
  61. echo -en "${ESC_FAINT}"
  62. for (( i=0; i< ${COLUMNS}; i++ )) ; do
  63. echo -en "${char}"
  64. done
  65. echo -e "${ESC_RESET}"
  66. }
  67. # ------------------------------------------------------------------------------
  68. # QUIT:
  69. # ------------------------------------------------------------------------------
  70. function quit {
  71. input=""
  72. while ([ "$input" != "q" ] && [ "$input" != "y" ]); do
  73. echo -ne "> Continue? Enter [${ESC_BOLD}q${ESC_RESET}] to quit, [${ESC_BOLD}y${ESC_RESET}] to continue: ";
  74. read input;
  75. done
  76. # printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
  77. if [ "$input" == "q" ] ; then
  78. printLn
  79. echo -e "> ${ESC_BOLD}Aborting due to user input.${ESC_RESET}"
  80. cd "${CURRENT_PATH}"
  81. exit 1
  82. fi
  83. }
  84. # ------------------------------------------------------------------------------
  85. # BANNER:
  86. # ------------------------------------------------------------------------------
  87. function printBanner {
  88. figlet -w 180 "/${MODULE_NAME}:>>>${SCRIPT_NAME}..." 2> /dev/null
  89. if [ $? -ne 0 ]; then
  90. banner "${SCRIPT_NAME}..." 2> /dev/null
  91. if [ $? -ne 0 ]; then
  92. echo -e "> ${SCRIPT_NAME}:" | tr a-z A-Z
  93. fi
  94. fi
  95. }
  96. printBanner
  97. # ------------------------------------------------------------------------------
  98. # HELP:
  99. # ------------------------------------------------------------------------------
  100. function printHelp {
  101. printLn
  102. echo -e "Usage: ${ESC_BOLD}${SCRIPT_NAME}${ESC_RESET}.sh [-h]"
  103. printLn
  104. echo -e "jEXEfies all projects possible found in the parent folder of this script, e.g. fat executables are created where applicable."
  105. printLn
  106. echo -e "${ESC_BOLD}-h${ESC_RESET}: Print this help"
  107. printLn
  108. }
  109. if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
  110. printHelp
  111. exit 0
  112. fi
  113. # ------------------------------------------------------------------------------
  114. # MAIN:
  115. # ------------------------------------------------------------------------------
  116. cd "${SCRIPT_PATH}/.."
  117. dirs=$(find . -maxdepth 2 -type d | grep -v -e "target" -e "src" -F -e "/.")
  118. for dir in $dirs ; do
  119. if [ -d "${dir}" ] && [ "$dir" != 'RemoteSystemsTempFiles/' ] && [ "$dir" != '.' ] ; then
  120. cd "$dir"
  121. if [ -f "./jexefy.sh" ] && [ -d "./target" ] ; then
  122. ./jexefy.sh
  123. fi
  124. cd "${SCRIPT_PATH}/.."
  125. fi
  126. done
  127. cd "${CURRENT_PATH}"