remoteUpdate.sh
2.17 KB
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
#!/bin/bash
# tgt : mercury, venus, mars, jupiter, saturn, neptune, pluto
# tgt : rosetta, juno
# phase : orb, cruise
# sw : OMNI, ACE_RealTime
export DECODER=/home/budnik/depotDECODER
if [[ $# -eq 0 ]]
then
echo "[ERROR] : No TARGET defined"
exit
fi
# Set Generic Environment Variables
. ${DECODER}/env.sh
tgt=$1
if [[ $# -eq 1 ]]
then
echo "[WARNING] No SW input defined : OMNI is used as SW input"
sw="OMNI"
else
sw=$2
fi
# define TARGET_VI
tgt_vi=$tgt\_orb_all
if [[ $# -eq 3 ]]
then
tgt_vi=$tgt\_$3\_all
echo "[WARNING] Check TARGET_VI : "$tgt_vi
fi
currDir=`pwd`
if [[ $tgt != "rosetta" ]]
then
tgtMaj=$(echo $tgt | tr [:lower:] [:upper:])
# Set SW special environment variables
. swenv.sh $tgtMaj $sw
else
. swenv.sh Rosetta $sw
# use comet Chury as target
tgt="p67"
fi
# Get SW StopTime and Tao StopTime from DDBASE
TaoStop=$(php $currDir/getTaoStop.php)
SwStop=$(php $currDir/getSwStop.php $sw)
if [[ $TaoStop == 'ERROR' ]] || [[ $SwStop == 'ERROR' ]]
then
echo 'ERROR in Tao StopTime or Sw StopTime'
exit
fi
# prepare & run process @ remote; read its PID into $pid variable
read -r pid < <(ssh $REMOTEHOST "$SW2ROOT/runRequest $tgt_vi $sw_vi $TaoStop $SwStop")
echo $pid
#check if process with PID=$pid is running
output=INIT
startTime=$(date +"%s")
while [ ! -z "$output" ]
do
# check each 10 min
sleep 60
output=$(echo $(ssh -f $REMOTEHOST "ps $pid") | grep $pid)
echo $output
stopTime=$(date +"%s")
t=$(( $stopTime-$startTime ))
if [ $t -gt 7200 ]
then
echo "[ERROR] Program is terminated because time of computation overcomes 2 hours"
ssh $REMOTEHOST "kill -9 $pid"
exit 2
fi
done
# Update local database (DDBASE)
echo "UPDATE DATABASE"
$currDir/updateLocalDataBase $tgt
cd $currDir