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