Changeset 1487 for palm/trunk/SCRIPTS
- Timestamp:
- Oct 25, 2014 2:36:28 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SCRIPTS/mbuild
r1469 r1487 1 #!/bin/ ksh1 #!/bin/bash 2 2 3 3 # mbuild - script for compiling the PALM code and its utility programs … … 22 22 # Current revisions: 23 23 # ------------------ 24 # 24 # bash compatibility adjustments: output formatting with printf instead 25 # of "typeset -L/-R", print replaced by echo 25 26 # 26 27 # Former revisions: … … 117 118 typeset -i ih ihost=0 118 119 119 typeset -R30 calltime120 typeset -L20 column1121 typeset -L50 column2122 typeset -L70 column3123 typeset -L40version="MBUILD 2.1 Rev$Rev$"120 calltime="" 121 column1="" 122 column2="" 123 column3="" 124 version="MBUILD 2.1 Rev$Rev$" 124 125 125 126 # ERROR HANDLING … … 174 175 # DETERMINE THE LOCAL HOST 175 176 local_host_real_name=$(hostname) 176 # local_address=$(nslookup `hostname` 2>&1 | grep "Address:" | tail -1 | awk '{print$2}')177 local_address=$(nslookup `hostname` 2>&1 | grep "Address:" | tail -1 | awk '{echo $2}') 177 178 178 179 … … 357 358 printf "\n" 358 359 printf "#------------------------------------------------------------------------# \n" 359 printf "| $version$calltime | \n"360 printf "| %-40s%30s | \n" "$version" "$calltime" 360 361 printf "| | \n" 361 column1="called on:"; column2=$local_host_real_name 362 printf "| $column1$column2 | \n" 363 column1="local username:"; column2=$local_username 364 printf "| $column1$column2 | \n" 365 column1="local IP-address:"; column2=$local_address 366 printf "| $column1$column2 | \n" 367 column1="config file:"; column2=$config_file 368 printf "| $column1$column2 | \n" 369 column1="makefile:"; column2=$makefile 370 printf "| $column1$column2 | \n" 371 column1="local source path:"; column2=$local_source_path 372 printf "| $column1$column2 | \n" 362 printf "| %-20s%-50s | \n" "called on:" "$local_host_real_name" 363 printf "| %-20s%-50s | \n" "local username:" "$local_username" 364 printf "| %-20s%-50s | \n" "local IP-address:" "$local_address" 365 column2=$(echo $config_file | cut -c1-50 ) 366 printf "| %-20s%-50s | \n" "config file:" "$column2" 367 line=$(echo "$config_file" | cut -c51-) 368 while [[ "$line" != "" ]] 369 do 370 column1="" 371 column2=$(echo $line | cut -c1-50 ) 372 printf "| %-20s%-50s | \n" "$column1" "$column2" 373 line=$(echo "$line" | cut -c51-) 374 done 375 column2=$(echo $makefile | cut -c1-50 ) 376 printf "| %-20s%-50s | \n" "makefile:" "$column2" 377 line=$(echo "$makefile" | cut -c51-) 378 while [[ "$line" != "" ]] 379 do 380 column1="" 381 column2=$(echo $line | cut -c1-50 ) 382 printf "| %-20s%-50s | \n" "$column1" "$column2" 383 line=$(echo "$line" | cut -c51-) 384 done 385 column2=$(echo $local_source_path | cut -c1-50 ) 386 printf "| %-20s%-50s | \n" "local source path:" "$column2" 387 line=$(echo "$local_source_path" | cut -c51-) 388 while [[ "$line" != "" ]] 389 do 390 column1="" 391 column2=$(echo $line | cut -c1-50 ) 392 printf "| %-20s%-50s | \n" "$column1" "$column2" 393 line=$(echo "$line" | cut -c51-) 394 done 373 395 printf "#------------------------------------------------------------------------# \n" 374 375 # printf "| | \n"376 396 377 397 … … 943 963 if [[ $remote_host = $local_host ]] 944 964 then 945 column 1="remote_host:"; column2="$remote_host (= local host!)"965 column2="$remote_host (= local host!)" 946 966 else 947 column 1="remote_host:"; column2=$remote_host948 fi 949 printf "| $column1$column2 | \n"967 column2=$remote_host 968 fi 969 printf "| %-20s%-50s | \n" "remote_host:" "$column2" 950 970 printf "| | \n" 951 column1="conditions:"; column2="$condition1 $condition2" 952 printf "| $column1$column2 | \n" 953 column1="make depository:"; column2=$remote_md 954 printf "| $column1$column2 | \n" 971 printf "| %-20s%-50s | \n" "conditions:" "$condition1 $condition2" 972 column2=$(echo "$remote_md" | cut -c1-50 ) 973 printf "| %-20s%-50s | \n" "make depository:" "$column2" 955 974 line=$(echo "$remote_md" | cut -c51-) 956 975 while [[ "$line" != "" ]] 957 976 do 958 977 column1="" 959 column2=$ line960 printf "| $column1$column2 | \n"978 column2=$(echo "$line" | cut -c1-50 ) 979 printf "| %-20s%-50s | \n" "$column1" "$column2" 961 980 line=$(echo "$line" | cut -c51-) 962 981 done 963 982 if [[ $compile_utility_programs = true ]] 964 983 then 965 column 1="utility directory:"; column2=$remote_ud984 column2=$(echo "$remote_ud" | cut -c1-50 ) 966 985 printf "| $column1$column2 | \n" 967 fi 968 column1="username:"; column2=$remote_username 969 printf "| $column1$column2 | \n" 970 column1="address:"; column2=$remote_address 971 printf "| $column1$column2 | \n" 972 column1="compiler:"; column2=$compiler_name 973 printf "| $column1$column2 | \n" 986 printf "| %-20s%-50s | \n" "utility directory:" "$column2" 987 line=$(echo "$remote_ud" | cut -c51-) 988 while [[ "$line" != "" ]] 989 do 990 column1="" 991 column2=$(echo "$line" | cut -c1-50 ) 992 printf "| %-20s%-50s | \n" "$column1" "$column2" 993 line=$(echo "$line" | cut -c51-) 994 done 995 fi 996 printf "| %-20s%-50s | \n" "username:" "$remote_username" 997 printf "| %-20s%-50s | \n" "address:" "$remote_address" 998 printf "| %-20s%-50s | \n" "compiler:" "$compiler_name" 974 999 if [[ $compile_utility_programs = true ]] 975 1000 then 976 column1="serial compiler:"; column2=$compiler_name_ser 977 printf "| $column1$column2 | \n" 1001 printf "| %-20s%-50s | \n" "serial compiler:" "$compiler_name_ser" 978 1002 fi 979 1003 if [[ "$make_options" != "" ]] 980 1004 then 981 column1="make options:"; column2=$make_options 982 printf "| $column1$column2 | \n" 983 fi 984 column1="cpp options:"; column2=$cpp_options 985 printf "| $column1$column2 | \n" 1005 printf "| %-20s%-50s | \n" "make options:" "$make_options" 1006 fi 1007 column2=$(echo $cpp_options | cut -c1-50 ) 1008 printf "| %-20s%-50s | \n" "cpp options:" "$column2" 986 1009 line=$(echo "$cpp_options" | cut -c51-) 987 1010 while [[ "$line" != "" ]] 988 1011 do 989 1012 column1="" 990 column2=$ line991 printf "| $column1$column2 | \n"1013 column2=$(echo $line | cut -c1-50 ) 1014 printf "| %-20s%-50s | \n" "$column1" "$column2" 992 1015 line=$(echo "$line" | cut -c51-) 993 1016 done 994 column 1="compiler options:"; column2=$compiler_options995 printf "| $column1$column2 | \n"1017 column2=$(echo $compiler_options | cut -c1-50 ) 1018 printf "| %-20s%-50s | \n" "compiler options:" "$column2" 996 1019 line=$(echo "$compiler_options" | cut -c51-) 997 1020 while [[ "$line" != "" ]] 998 1021 do 999 1022 column1="" 1000 column2=$ line1001 printf "| $column1$column2 | \n"1023 column2=$(echo $line | cut -c1-50 ) 1024 printf "| %-20s%-50s | \n" "$column1" "$column2" 1002 1025 line=$(echo "$line" | cut -c51-) 1003 1026 done 1004 column 1="loader options:"; column2=$loader_options1005 printf "| $column1$column2 | \n"1027 column2=$(echo $loader_options | cut -c1-50 ) 1028 printf "| %-20s%-50s | \n" "loader options:" "$column2" 1006 1029 line=$(echo "$loader_options" | cut -c51-) 1007 1030 while [[ "$line" != "" ]] 1008 1031 do 1009 1032 column1="" 1010 column2=$ line1011 printf "| $column1$column2 | \n"1033 column2=$(echo $line | cut -c1-50 ) 1034 printf "| %-20s%-50s | \n" "$column1" "$column2" 1012 1035 line=$(echo "$line" | cut -c51-) 1013 1036 done 1014 1037 if [[ $modules != "" ]] 1015 1038 then 1016 column 1="modules to be load:"; column2=$modules1017 printf "| $column1$column2 | \n"1039 column2=$(echo $modules | cut -c1-50 ) 1040 printf "| %-20s%-50s | \n" "modules to be load:" "$column2" 1018 1041 line=$(echo "$modules" | cut -c51-) 1019 1042 while [[ "$line" != "" ]] 1020 1043 do 1021 1044 column1="" 1022 column2=$ line1023 printf "| $column1$column2 | \n"1045 column2=$(echo $line | cut -c1-50 ) 1046 printf "| %-20s%-50s | \n" "$column1" "$column2" 1024 1047 line=$(echo "$line" | cut -c51-) 1025 1048 done … … 1065 1088 else 1066 1089 # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS 1067 print"[[ ! -d ${remote_md} ]] && (echo \" *** ${remote_md} will be created\"; mkdir -p ${remote_md})" | ssh ${remote_username}@${remote_address} 2>&11090 echo "[[ ! -d ${remote_md} ]] && (echo \" *** ${remote_md} will be created\"; mkdir -p ${remote_md})" | ssh ${remote_username}@${remote_address} 2>&1 1068 1091 fi 1069 1092 … … 1079 1102 else 1080 1103 # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS 1081 print"cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]] && tar -xf ${mainprog}_current_version.tar" | ssh ${remote_username}@${remote_address} 2>&11104 echo "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]] && tar -xf ${mainprog}_current_version.tar" | ssh ${remote_username}@${remote_address} 2>&1 1082 1105 fi 1083 1106 … … 1090 1113 else 1091 1114 # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS 1092 print"cd ${remote_md}; tar -xf ${mainprog}_sources.tar" | ssh ${remote_username}@${remote_address} 2>&11115 echo "cd ${remote_md}; tar -xf ${mainprog}_sources.tar" | ssh ${remote_username}@${remote_address} 2>&1 1093 1116 fi 1094 1117 … … 1130 1153 then 1131 1154 1132 print"$init_cmds $module_calls export OBJECT_MODE=64; cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll1155 echo "$init_cmds $module_calls export OBJECT_MODE=64; cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll 1133 1156 1134 1157 elif [[ $remote_host = lctit ]] … … 1138 1161 while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]] 1139 1162 do 1140 print"cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll1163 echo "cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll 1141 1164 done 1142 1165 … … 1148 1171 else 1149 1172 1150 print"$init_cmds $module_calls cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll1173 echo "$init_cmds $module_calls cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll 1151 1174 1152 1175 fi … … 1184 1207 else 1185 1208 # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS 1186 print"cd ${remote_md}; chmod u+w *; tar -cf ${mainprog}_current_version.tar ${mainprog} *.f90 *.o *.mod" | ssh ${remote_username}@${remote_address} 2>&11209 echo "cd ${remote_md}; chmod u+w *; tar -cf ${mainprog}_current_version.tar ${mainprog} *.f90 *.o *.mod" | ssh ${remote_username}@${remote_address} 2>&1 1187 1210 fi 1188 1211 … … 1204 1227 else 1205 1228 # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS 1206 print"[[ ! -d ${remote_ud} ]] && (echo \" *** ${remote_ud} will be created\"; mkdir -p ${remote_ud}); [[ ! -d ${remote_ud}/../SCRIPTS ]] && (echo \" *** ${remote_ud}/../SCRIPTS will be created\"; mkdir -p ${remote_ud}/../SCRIPTS)" | ssh ${remote_username}@${remote_address} 2>&11229 echo "[[ ! -d ${remote_ud} ]] && (echo \" *** ${remote_ud} will be created\"; mkdir -p ${remote_ud}); [[ ! -d ${remote_ud}/../SCRIPTS ]] && (echo \" *** ${remote_ud}/../SCRIPTS will be created\"; mkdir -p ${remote_ud}/../SCRIPTS)" | ssh ${remote_username}@${remote_address} 2>&1 1207 1230 fi 1208 1231 … … 1254 1277 then 1255 1278 1256 print"$init_cmds $module_calls export OBJECT_MODE=64; cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_address}1279 echo "$init_cmds $module_calls export OBJECT_MODE=64; cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_address} 1257 1280 1258 1281 elif [[ $remote_host = lctit ]] … … 1262 1285 while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]] 1263 1286 do 1264 print"$init_cmds $module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll1287 echo "$init_cmds $module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll 1265 1288 done 1266 1289 … … 1272 1295 else 1273 1296 1274 print"$init_cmds $module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll1297 echo "$init_cmds $module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll 1275 1298 1276 1299 fi
Note: See TracChangeset
for help on using the changeset viewer.