This script fixes update of the server name in mom config

--
   Olivier LAHAYE
   CEA DRT/LIST/DCSI/DIR
Index: packages/torque/scripts/update_mom_config
===================================================================
--- packages/torque/scripts/update_mom_config	(révision 9483)
+++ packages/torque/scripts/update_mom_config	(copie de travail)
@@ -5,35 +5,46 @@
 
 # Author:	Jeremy Enos je...@ncsa.uiuc.edu
 #		Bernard Li <b...@bcgsc.ca>
+#		Olivier Lahaye <olivier.lah...@cea.fr>
 
 # Updates mom config file with real TORQUE server hostname and pushes it out.
 # 
 
+# Try to find the correct mom config file.
+mom_config_files="/etc/torque/mom/config /var/lib/torque/mom_priv/config /var/spool/pbs/mom_priv/config"
 . /etc/profile
-mom_config=/var/spool/pbs/mom_priv/config
-sed_tmp=/tmp/mom_config_tmp
 
-if [ -f $mom_config ] ; then
-  cat $mom_config |sed s/pbs_oscar/$HOSTNAME/g > $sed_tmp
-  /bin/cp -f $sed_tmp $mom_config
-  /bin/rm -f $sed_tmp
-  echo "TORQUE mom config file updated with clienthost: $HOSTNAME"
-  echo "Pushing config file to clients..."
-  if [ -x `which cpush` ] ; then
-    cpush $mom_config $mom_config
-  else
-    echo "Error:  Can't find cpush utility."
-    exit 1
+for mom_config in $mom_config_files
+do
+  if [ -f $mom_config ] ; then
+    # update the $pbsserver full line instead of replacing pbs_oscar
+    # this permits the use of distro torque package.
+    # if there is no $pbsserver line in the file, it doesn't fail and
+    # the $PBS_SERVER_HOME/server_name hostname is used instead.
+    sed -i -e "s/\$pbsserver.*$/\$pbsserver $HOSTNAME/g" $mom_config
+    echo "TORQUE mom config file $mom_config"
+    echo "updated with clienthost: $HOSTNAME"
+    echo "Pushing config file to clients..."
+    if [ -x `which cpush` ] ; then
+      cpush $mom_config $mom_config
+    else
+      echo "Error:  Can't find cpush utility."
+      exit 1
+    fi
+    echo "Sending SIGHUP to all moms..."
+    if [ -x `which cexec` ] ; then
+      cexec killall -1 pbs_mom
+    else
+      echo "Error:  Can't find cexec utility."
+      exit 1
+    fi
+    exit 0 # Config done, we can exit now
   fi
-  echo "Sending SIGHUP to all moms..."
-  if [ -x `which cexec` ] ; then
-    cexec killall -1 pbs_mom
-  else
-    echo "Error:  Can't find cexec utility."
-    exit 1
-  fi
-else
-  echo "Error:  Not updating TORQUE mom config file."
-  echo "$mom_config not found."
-  exit 1
-fi
+done
+
+# Still here: we did not find any config file to update.
+echo "Error:  Not updating TORQUE mom config file."
+echo "None of the following config file found:"
+echo "$mom_config_files"
+exit 1
+ 
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Oscar-devel mailing list
Oscar-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oscar-devel

Reply via email to