-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_Lens.sh
executable file
·101 lines (90 loc) · 2.01 KB
/
run_Lens.sh
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash
cleanup() {
# Remove the Lens distribution
if [ -f "Lens.tgz" ]; then
rm -v "Lens.tgz"
fi
# Remove the Tcl add-ons distribution
if [ -f "tcl_procs.tgz" ]; then
rm -v "tcl_procs.tgz"
fi
# Check the home directory for any transfered files.
if [ -f ALLURLS ]; then
while read url; do
fname=$(basename "$url")
if [ -f "$fname" ]; then
rm -v "$fname"
fi
done < ALLURLS
fi
# Package the weights for transfer and clean up
# First, check if any weight files exist.
nwt=$(ls -1 *.wt 2>/dev/null | wc -l)
if [ $nwt -gt 0 ]; then
tar czf wt.tgz *.wt && rm *.wt
fi
nin=$(ls -1 *.in 2>/dev/null | wc -l)
if [ $nin -gt 0 ]; then
rm *.in
fi
ntcl=$(ls -1 *.tcl 2>/dev/null | wc -l)
if [ $ntcl -gt 0 ]; then
rm *.tcl
fi
if [ -d "Lens" ]; then
rm -rf Lens/
fi
if [ -d "ex" ]; then
rm -rf ex/
fi
}
abort() {
echo >&2 '
*************
** ABORTED **
*************
'
echo >&2 "Files at time of error/interrupt"
echo >&2 "--------------------------------"
ls >&2 -l
cleanup
echo "An error occured. Exiting ..." >&2
exit 1
}
success() {
echo '
*************
** SUCCESS **
*************
'
cleanup
exit 0
}
# If an exit or interrupt occurs while the script is executing, run the abort
# function.
trap abort EXIT SIGTERM
set -e
## Set variables
root=$( pwd )
trainscript="trainscript_phase01.tcl"
export LENSDIR=$root/Lens
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$LENSDIR/Bin
## Install Lens
if [ ! -f Lens.tgz ]; then
wget -q "http://proxy.chtc.wisc.edu/SQUID/crcox/Lens/Lens.tgz"
fi
tar xzf "Lens.tgz"
if [ ! -f tcl_procs.tgz ]; then
wget -q "http://proxy.chtc.wisc.edu/SQUID/crcox/Lens/tcl_procs.tgz"
fi
tar xzf "tcl_procs.tgz"
chmod u+x $LENSDIR/Bin/lens-2.63
>&2 echo "INSTALLED Lens at ${root}/Lens/Bin"
# Run Lens
>&2 echo "STARTING LENS"
$LENSDIR/Bin/lens-2.63 -batch "$trainscript"
>&2 echo "LENS ENDED"
# Directory state after running lens and cleaning up
ls -ltr
# Exit successfully. Hooray!
trap success EXIT SIGTERM