-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathamu_run_step
executable file
·44 lines (39 loc) · 903 Bytes
/
amu_run_step
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
b=$1
e=$2
[ $e ] || e=$b
dateformat='+%Y/%m/%d %H:%M:%S'
timef=`mktemp`
cleanup() {
[ -f $timef ] && rm $timef ;
}
bail () {
cleanup
exit 1
}
trap bail INT
source $AMU_HOME/*.bash
for i in `seq $b $e` ; do
cd $i
if [[ $? -ne 0 ]] ; then
echo `date "$dateformat"`" Bailing." 2> /dev/stderr
exit 1
fi
printf "%s %s Step: % 4d " "`date \"$dateformat\"`" "$(amu_get_project_name /)" "$i"
T="$(date +%s%N)"
make -s 2> /dev/null
r=$?
T="$(($(date +%s%N)-T))"
S="$((T/1000000000))"
M="$((T/1000000))"
T=$S
t=$(printf "%02d:%02d:%02d:%02d.%03d" "$((T/86400))" "$((T/3600%24))" "$((T/60%60))" "$((T%60))" "$((M/100000))" )
cd ..
if [[ $r -eq 2 ]] ; then
echo " failed. Bailing. Elapsed: $t" 2> /dev/stderr
exit 1
elif [[ $r -eq 0 ]] ; then
echo " success. Elapsed: $t"
fi
done
cleanup