Hi,

Since centos-6, torque uses /etc/torque instead of /var/spool/pbs to store its 
configuration files. This script is updated to it is able to handle multiple 
config paths (old pbs or oscar specific or new torque location).
It also check the full $pbsserver line instead of replaceing pbs_oscar name. 
This allows the use of distro torque package.

Patch attached.

--
   Olivier LAHAYE
   CEA DRT/LIST/DCSI/DIR
Index: update_mom_config
===================================================================
--- update_mom_config	(révision 9483)
+++ 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
+ 
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Oscar-devel mailing list
Oscar-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oscar-devel

Reply via email to