Megatest

Changes On Branch efe2d432753ef140
Login

Changes In Branch v1.60-nbfake-stderr Through [efe2d43275] Excluding Merge-Ins

This is equivalent to a diff from 2513a8d303 to efe2d43275

2014-10-29
15:46
Fix local variable name in nbfake Closed-Leaf check-in: 794eaa8cad user: tyardeni tags: v1.60-nbfake-stderr
15:40
Use local rather than env variables to determine log and host check-in: efe2d43275 user: tyardeni tags: v1.60-nbfake-stderr
15:17
Remove debug code from nbfake check-in: bb277556b4 user: tyardeni tags: v1.60-nbfake-stderr
13:57
Merged Tal's nbfake fix to v1.60 check-in: 02d61b3703 user: mrwellan tags: v1.60
11:47
Update nbfake to write output to stderr, and append to logfile. Update nbfake variables, but fall back to old TARGETHOST vars check-in: 712f18e24b user: tyardeni tags: v1.60-nbfake-stderr
2014-10-28
23:08
Don't do threaded registration check-in: 2513a8d303 user: matt tags: v1.60
00:18
change default for server-query-threshold to -1, forcing always a server to start Added test for vars with . check-in: cf47596912 user: matt tags: v1.60

Modified utils/nbfake from [e5bec056c7] to [2b1cbc2712].

1

2




























3
4

5











6
7










8






9
10
11
12





13
14
15


16
17
18

19

20

21
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

+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

-
+

+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+

+
+
+
+
+
+
-
-
-
-
+
+
+
+
+

-
-
+
+
-
-
-
+

+
-
+

#!/bin/bash
###############################################################################

#
# nbfake - capture command output in a logfile
#
# nbfake behavior can be changed by setting the following env vars:
#   NBFAKE_HOST       SSH to $NBFAKE_HOST and run command
#   NBFAKE_LOG        Logfile for nbfake output
#
###############################################################################

if [[ -z "$@" ]]; then
  cat <<__EOF

nbfake usage:

nbfake <command to run>

nbfake behavior can be changed by setting the following env vars:
   NBFAKE_HOST       SSH to \$NBFAKE_HOST and run command
   NBFAKE_LOG        Logfile for nbfake output

__EOF
  exit
fi

#==============================================================================
# Setup
#==============================================================================

# Can't always trust $PWD
CURRWD=`pwd`
CURRWD=$(pwd)

# Make sure nbfake host and logfile are set. Fall back to old-style variable names

if [[ -z "$NBFAKE_HOST" && -n "$TARGETHOST" ]]; then 
  MY_NBFAKE_HOST=$TARGETHOST     
else
  MY_NBFAKE_HOST=$NBFAKE_HOST
  unset NBFAKE_HOST
fi


if [[ -z "$NBFAKE_LOG" && -n "$TARGETHOST_LOGF" ]]; then 
if [[ $TARGETHOST_LOGF == "" ]]; then
    TARGETHOST_LOGF=NBFAKE-`date +%GWW%V.%u_%T`
  MY_NBFAKE_LOG=$TARGETHOST_LOGF
else
  MY_NBFAKE_LOG=$NBFAKE_LOG
  unset NBFAKE_LOG
fi

# Set default nbfake log

if [[ -z "$MY_NBFAKE_LOG" ]]; then
  MY_NBFAKE_LOG=NBFAKE-$(date +%GWW%V.%u_%T)
fi

#==============================================================================
# Run and log
#==============================================================================

cat <<__EOF >&2
echo "#======================================================================"
echo "# NBFAKE Logging command to $TARGETHOST_LOGF"
echo "#     \"$*\""
echo "#======================================================================"
#======================================================================
# NBFAKE logging command to: $NBFAKE_LOG
#     $*
#======================================================================
__EOF

if [[ $TARGETHOST == ""  ]]; then
  unset TARGETHOST
if [[ -z "$MY_NBFAKE_HOST" ]]; then
  # Run locally
  TARGETHOST_LOGF_TEMP=$TARGETHOST_LOGF
  unset TARGETHOST_LOGF
  sh -c "cd $CURRWD;export DISPLAY=$DISPLAY; export PATH=$PATH; nohup $* >> $TARGETHOST_LOGF_TEMP 2>&1 &"
  sh -c "cd $CURRWD;export DISPLAY=$DISPLAY; export PATH=$PATH; nohup $* >> $MY_NBFAKE_LOG 2>&1 &"
else
  # run remotely
  ssh -n -f $TARGETHOST "sh -c \"cd $CURRWD;export DISPLAY=$DISPLAY; export PATH=$PATH; nohup $* >> $TARGETHOST_LOGF 2>&1 &\""
  ssh -n -f $MY_NBFAKE_HOST "sh -c \"cd $CURRWD;export DISPLAY=$DISPLAY; export PATH=$PATH; nohup $* >> $MY_NBFAKE_LOG 2>&1 &\""
fi