Index: trunk/tools/eam/rebalance/launch.insert.sh
===================================================================
--- trunk/tools/eam/rebalance/launch.insert.sh	(revision 42485)
+++ trunk/tools/eam/rebalance/launch.insert.sh	(revision 42534)
@@ -1,33 +1,35 @@
 #!/bin/csh 
 
-set srclist = (ipp100 ipp101 ipp102 ipp104 ipp105 ipp108 ipp112 ipp114 ipp115 ipp117 ipp123 ipp124 ipp125 ipp126 ipp134 ipp136 ipp137 ipp139)
-set tgtlist = (ipp153 ipp153 ipp154 ipp154 ipp155 ipp155 ipp156 ipp156 ipp157 ipp157 ipp153 ipp154 ipp155 ipp156 ipp157 ipp154 ipp155 ipp157)
+set program = `basename $0`
 
-set mydir = /data/ipphome1.0/home/eugene/rebalance.20220922
+set run = v0
+set version = 20230802
 
-# manually set these values:
-set run = v0
-set version = 20220922
+# set to 'insert' first, then run with 'insert.check'
+# set mode = insert
 set mode = insert.check
 
-if ($#argv < 1) then
-  echo "USAGE: launch.insert.sh launch"
-  echo "USAGE: launch.insert.sh (src) (tgt)"
+set srchost = (ipp100 ipp108 ipp112 ipp114)
+set srcvol  = (     0      0      1      0)
+set tgthost = (ipp161 ipp161 ipp162 ipp162)
+set tgtvol  = (     0      1      0      1)
+
+set mydir = /data/ipphome1.0/home/eugene/rebalance.20230802
+
+if ($#argv == 0) then
+  echo "USAGE: $program launch"
+  echo "USAGE: $program run (Nentry)"
+  echo "   eg: $program run 1"
   exit 2
 endif
 
-if ($#argv == 1) then
-  if ("$1" != "launch") then
-    echo "USAGE: launch.insert.sh launch"
-    echo "USAGE: launch.insert.sh (src) (tgt)"
-    exit 2
-  endif
+if ("$1" == "launch") then
+
+  # NOTE: the insert jobs run on the target machines, not source machines
 
   set i = 1
-  while ($i <= $#srclist)
-    set src = $srclist[$i]
-    set tgt = $tgtlist[$i]
-    echo ssh -f $tgt "cd $mydir && ./launch.insert.sh $src $tgt"
-         ssh -f $tgt "cd $mydir && ./launch.insert.sh $src $tgt"
+  while ($i <= $#tgthost)
+    echo ssh -f $tgthost[$i] "cd $mydir && ./$program run $i"
+         ssh -f $tgthost[$i] "cd $mydir && ./$program run $i"
     @ i++
   end
@@ -35,20 +37,29 @@
 endif
 
-if ($#argv != 2) then
-  echo "USAGE: launch.insert.sh launch"
-  echo "USAGE: launch.insert.sh (src) (tgt)"
-  exit 2
+if ("$1" == "run") then
+  if ($#argv != 2) then
+    echo "USAGE: $program run (Nentry)"
+    echo "   eg: $program run 1"
+    exit 2
+  endif
+
+  set N = $2
+
+  set hn = $srchost[$N]
+  set hv = $srcvol[$N]
+  set tn = $tgthost[$N]
+  set tv = $tgtvol[$N]
+
+  set myhost = `hostname`
+  if ($tn != $myhost) then
+    echo "ERROR: need to run $mode on the source host ($tn vs $myhost)"
+    exit 3
+  endif
+
+  echo "running on $myhost for source $hn.$hv to target $tn.$tv in mode $mode, version $version"
+  mkdir -p $hn.$hv
+  echo "./rebalance.mana $mode $hn $hv $tn $tv $version > & $hn.$hv/log.$mode.$version.$run &"
+        ./rebalance.mana $mode $hn $hv $tn $tv $version > & $hn.$hv/log.$mode.$version.$run &
+  exit 0
 endif
 
-set src = $1
-set tgt = $2
-
-set v = 0 ; set h = $src; set t = $tgt; ./rebalance.mana $mode $h $v $t $v $version > & $h.$v/log.$mode.$version.$run &
-set v = 1 ; set h = $src; set t = $tgt; ./rebalance.mana $mode $h $v $t $v $version > & $h.$v/log.$mode.$version.$run &
-
-# e.g.: ssh -f ipp127 "cd `pwd` && ./launch.rsync.sh"
-
-#     echo ssh $f ps ux
-#          ssh $f ps ux
-#      ssh $f killall mana
-#      ssh $f killall find
