make_and_install 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #!/bin/bash
  2. if [ "$1" == "" ]; then
  3. echo "Usage:"
  4. echo "$0 [clean|compile|install|nccompile|ncinstall] \"standard|standard-dep|mysql|radius|presence|stable|experimental\" [ignore|stop] [installpath]"
  5. echo " "
  6. echo " The first parameter specifies what to do: 'clean' up source tree, 'compile', or compile and 'install'.."
  7. echo " The 'nccompile' and 'ncinstall' do the same as compile and install respectively, but withou"
  8. echo " cleaning the source tree first (this will make make_and_install_output.txt easier to scan for"
  9. echo " errors and takes less time after you have compiled once)."
  10. echo " "
  11. echo " The second parameter controls which modules to include. It may list several group names"
  12. echo " separated by space (see INSTALL). If you don't know what to include, use \"standard\" (default) "
  13. echo " or \"standard mysql\" (if you want mysql storage support)."
  14. echo " "
  15. echo " ignore|stop(default) specifies whether to stop after found errors or ignore and just install."
  16. echo " If you have errors in a module with dependencies, it will allow you to install the remaining"
  17. echo " modules. This switch is only relevant for install and ncinstall."
  18. echo " "
  19. echo " If installpath is not supplied, ser will be installed created in /usr/local and sub-directories."
  20. echo " "
  21. echo " Groups and installpath will be stored and reused the next time you use make_and_install unless"
  22. echo " you specify explicitly groups and installpath on the command line."
  23. echo " "
  24. echo " Examples:"
  25. echo " $0 compile"
  26. echo " will compile the standard modules without external dependencies."
  27. echo " If the make_and_install_config_* files exist, groups and installpath specified there will be used."
  28. echo " "
  29. echo " $0 install \"standard mysql\" stop /tmp/ser"
  30. echo " will compile and install all mysql and standard modules without external dependencies to /tmp/ser"
  31. echo " and stop and not install if there are errors."
  32. echo " make_and_install_config_* files will be created to save the groups and installpath."
  33. echo " "
  34. echo " $0 ncinstall \"standard standard-dep\" ignore"
  35. echo " will compile without cleaning first (i.e. skip already made files and modules). All"
  36. echo " modules without (standard) and with (standard-dep) dependencies will be included, but"
  37. echo " if a module won't compile due to lack of installed dependencies, SER will still be installed"
  38. echo " to default directory (/usr/local)."
  39. echo " make_and_install_config_* files will be created to save the groups and installpath."
  40. echo " "
  41. echo " $0 clean"
  42. echo " will default clean ALL modules (not only standard). Specify groups to clean only those."
  43. echo " If the make_and_install_config_groups file exists, groups specified there will be used."
  44. exit
  45. fi
  46. action="$1"
  47. groups="$2"
  48. whenerrors="$3"
  49. installpath="$4"
  50. # source the saved config
  51. if [ "$groups" == "" ]; then
  52. echo "Attempting to load groups and install path from files..."
  53. echo " To reset, either specify groups to include and installation path on command line or"
  54. echo " do: rm make_and_install_config_*"
  55. echo " "
  56. if [ -f ./make_and_install_config_groups ]; then
  57. groups="`cat ./make_and_install_config_groups`"
  58. echo " Loaded groups..."
  59. fi
  60. if [ -f ./make_and_install_config_installpath ]; then
  61. installpath="`cat ./make_and_install_config_installpath`"
  62. echo " Loaded installpath..."
  63. fi
  64. fi
  65. if [ "$whenerrors" == "" ]; then
  66. whenerrors="stop"
  67. fi
  68. if [ "$installpath" == "" ]; then
  69. installpath="/usr/local"
  70. fi
  71. if [ "$groups" == "" ]; then
  72. if [ "$action" == "clean" ]; then
  73. groups="standard standard-dep stable experimental"
  74. else
  75. groups="standard"
  76. fi
  77. fi
  78. clean="yes"
  79. if [ "$action" == "clean" ]; then
  80. echo "The source tree will be cleaned."
  81. elif [ "$action" == "compile" ]; then
  82. echo "SER core and groups $groups will be compiled."
  83. elif [ "$action" == "nccompile" ]; then
  84. echo "SER core and groups $groups will be compiled without cleaning source tree."
  85. clean="no"
  86. action="compile"
  87. elif [ "$action" == "install" ]; then
  88. echo "SER core and groups $groups will be compiled and installed to $installpath."
  89. elif [ "$action" == "ncinstall" ]; then
  90. echo "SER core and groups $groups will be compiled and installed to $installpath without cleaning source tree."
  91. clean="no"
  92. action="install"
  93. else
  94. echo "No such action, please specify clean, compile, or install."
  95. exit
  96. fi
  97. echo " "
  98. if [ "$action" == "clean" ]; then
  99. echo "----------------------"
  100. echo "Cleaning up the SER source tree for $groups... "
  101. echo "----------------------"
  102. make group_include="$groups" prefix=$installpath proper > /dev/null 2>&1
  103. rm -f make_and_install_output.txt
  104. rm -f make_and_install_config_*
  105. exit
  106. fi
  107. # save config
  108. rm -f ./make_and_install_config*
  109. echo "$groups" > ./make_and_install_config_groups
  110. echo "$installpath" > ./make_and_install_config_installpath
  111. echo " YOU WILL FIND THE OUTPUT IN make_and_install_output.txt IN THE CURRENT DIRECTORY"
  112. echo "----------------------"
  113. if [ "$clean" == "yes" ]; then
  114. echo "Cleaning up the source tree... "
  115. echo "----------------------"
  116. make group_include="$groups" prefix=$installpath proper > /dev/null 2>&1
  117. echo "----------------------"
  118. fi
  119. echo "Making ser and all modules in the groups \"$groups\". This may take some time..."
  120. echo "----------------------"
  121. echo "COMPILING......"
  122. rm -f ./make_and_install_output.txt
  123. make group_include="$groups" prefix=$installpath all > ./make_and_install_output.txt 2>&1
  124. echo "----------------------"
  125. count=`egrep "error |Error |error:" ./make_and_install_output.txt | wc -l | awk '{print $1}'`
  126. if [ $count -ne 0 ]; then
  127. echo "FOUND ERRORS!"
  128. echo " You may want to run the same $0 command again but use 'nccompile'."
  129. echo " The output file will then be simpler to read."
  130. echo " See make_and_install_output.txt for full output, search for 'error'."
  131. if [ "$whenerrors" == "ignore" ]; then
  132. echo " "
  133. echo "Error ignore switch was specified, moving on despite errors..."
  134. else
  135. exit
  136. fi
  137. fi
  138. if [ "$action" == "compile" ]; then
  139. echo "'compile' was used; skipping installation."
  140. exit
  141. fi
  142. echo "----------------------"
  143. echo "Installing SER and all modules to $installpath"
  144. echo "----------------------"
  145. make group_include="$groups" prefix=$installpath install >> ./make_and_install_output.txt 2>&1