File size: 1,981 Bytes
ef97c58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env bash
# upload_remaining.sh [PxCy ...] -- upload a known-complete set of captures, SEQUENTIALLY.
#
# Tracking is finished, so there is no watching / polling / retry-until-ready logic here:
# this just walks a fixed list and uploads each one in turn.
#
# Sequential on purpose. The link to HF is ~1 MB/s and shared, so running captures in
# parallel does not add throughput, it just interleaves them and makes a stall in one
# capture look like a stall in all of them.
#
# Each capture is independent: a failure is logged and the loop moves on, so one bad
# capture cannot block the other five. upload_large_folder resumes per capture, so
# re-running this script after any failure costs only what is actually missing.
#
# Run detached (NOT tmux -- a tmux server restart on this shared box has killed an
# upload before):
#     setsid nohup ./scripts/upload_remaining.sh > logs/seq.log 2>&1 < /dev/null &
set -uo pipefail

HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BASE="$(dirname "$HERE")"
LOGDIR="$BASE/logs"; mkdir -p "$LOGDIR"

CAPTURES=("$@")
if [ ${#CAPTURES[@]} -eq 0 ]; then
  CAPTURES=(P2C1 P2C2 P3C2 P4C1 P4C2 P5C2)
fi

STAMP="$(date +%Y%m%d_%H%M%S)"
SUMMARY="$LOGDIR/seq_summary_${STAMP}.txt"
echo "sequential upload of ${#CAPTURES[@]} captures: ${CAPTURES[*]}" | tee "$SUMMARY"
echo "started $(date)" | tee -a "$SUMMARY"

for c in "${CAPTURES[@]}"; do
  log="$LOGDIR/seq_${c}_${STAMP}.log"
  echo "" | tee -a "$SUMMARY"
  echo "########## $c  start $(date +%H:%M:%S)  -> $log" | tee -a "$SUMMARY"
  t0=$(date +%s)
  "$HERE/upload_capture.sh" "$c" > "$log" 2>&1
  rc=$?
  t1=$(date +%s)
  echo "########## $c  exit=$rc  elapsed=$(( (t1-t0)/60 ))m$(( (t1-t0)%60 ))s" | tee -a "$SUMMARY"
  if [ $rc -ne 0 ]; then
    echo "    LAST 15 LINES OF $log:" | tee -a "$SUMMARY"
    tail -15 "$log" | sed 's/^/    /' | tee -a "$SUMMARY"
  fi
done

echo "" | tee -a "$SUMMARY"
echo "finished $(date)" | tee -a "$SUMMARY"
echo "ALL DONE" | tee -a "$SUMMARY"