[Swift-commit] r5167 - trunk/bin

davidk at ci.uchicago.edu davidk at ci.uchicago.edu
Sat Sep 24 16:32:35 CDT 2011


Author: davidk
Date: 2011-09-24 16:32:35 -0500 (Sat, 24 Sep 2011)
New Revision: 5167

Modified:
   trunk/bin/gensites
   trunk/bin/start-coaster-service
   trunk/bin/stop-coaster-service
Log:
Updated coaster scripts and gensites into trunk


Modified: trunk/bin/gensites
===================================================================
--- trunk/bin/gensites	2011-09-24 21:29:54 UTC (rev 5166)
+++ trunk/bin/gensites	2011-09-24 21:32:35 UTC (rev 5167)
@@ -45,7 +45,7 @@
 
    Examples:
 
-   Create a site configuration file for sites.xml using default properties.file in current directory
+   Create a site configuration file for sites.xml using swift.properties in current directory
    	$ gensites pads > sites.xml
 
    Use a specific properties file for a site
@@ -88,7 +88,7 @@
 fi
 
 # List all templates
-if [ ! -z $LIST_TEMPLATES ]; then
+if [ ! -z "$LIST_TEMPLATES" ]; then
    # Templates in etc/sites
    for file in `ls -1 $SWIFT_HOME/* 2>/dev/null`
    do
@@ -127,92 +127,89 @@
 fi
 
 # List a specific template
-if [ ! -z $LIST_SPECIFIC_TEMPLATE ]; then
+if [ ! -z "$LIST_SPECIFIC_TEMPLATE" ]; then
    cat $TEMPLATE_PATH
    exit 0
 fi
 
 # Ensure a properties file exists
 if [ ! -f "$PROPERTIES_FILE" ]; then
-   PROPERTIES_FILE="swift.properties"
+   PROPERTIES_FILE="./swift.properties"
    if [ ! -f "$PROPERTIES_FILE" ]; then
       PROPERTIES_FILE="$HOME/.swift/swift.properties"
-      if [ ! -f "$PROPERTIES_FILE" ]; then
-         crash "Unable to find a valid properties file! Please specify a valid file with the -p option"
-      fi
    fi
 fi
 
 # Setup for creating a TC file
-if [ -f "tc.data" ] && [ -n "`grep -e app $PROPERTIES_FILE`" ]; then
-   mv tc.data tc.data.old
-   HOSTS=`grep -i "pool handle" $TEMPLATE|grep -v "^[[:space:]]*#"|cut -d'"' -f2`
+if [ -n "`grep -e app $PROPERTIES_FILE`" ]; then
+   if [ -f "tc.data" ]; then
+      mv tc.data tc.data.old
+   fi
+   HOSTS=`grep -i "pool handle" $TEMPLATE_PATH|grep -v "^[[:space:]]*#"|cut -d'"' -f2`
 fi
 
 # Parse values into variables for later sed processing
-#WORK=`pwd`"/work"
-while read line
-do
-   case "$line" in
-      "#site $TEMPLATE work="*|'#site work='*) 
-         WORK=`get_value $line`
+if [ -f "$PROPERTIES_FILE" ]; then
+   while read line
+   do
+      case "$line" in
+         "#site $TEMPLATE work="*|'#site work='*) 
+            WORK=`get_value $line`
+            ;;
+         "#site $TEMPLATE globus_hostname="*|'#site globus_hostname=') 
+            GLOBUS_HOSTNAME=`get_value $line`
+            ;;
+         "#site $TEMPLATE nodes="*|'#site nodes='*)
+            NODES=`get_value $line`
+            ;;
+         "#site $TEMPLATE project="*|'#site project='*)
+            PROJECT=`get_value $line`
+            ;;
+         "#site $TEMPLATE queue="*|'#site queue='*)
+            QUEUE=`get_value $line`
+            ;;
+         "#site $TEMPLATE n_gran="*|'#site n_gran='*)
+            N_GRAN=`get_value $line`
+            ;;
+         "#site $TEMPLATE n_max="*|'#site n_max='*)
+            MAXTIME=`get_value $line`
+            ;;
+         "#site $TEMPLATE slots="*|'#site slots='*)
+            SLOTS=`get_value $line`
+            ;;
+         "#site $TEMPLATE execution_url="*|'#site execution_url='*)
+            EXECUTION_URL=`get_value $line`
+           ;;
+         "#site $TEMPLATE internalhostname="*|'#site internalhostname='*)
+            INTERNALHOSTNAME=`get_value $line`
+            ;;
+         '#app'*)
+            if [ `echo $line | wc -w` == 2 ]; then
+               for HOST in $HOSTS
+               do
+                  NAME=`echo $line |cut -d'=' -f1|awk '{print $2}'`
+                  COMMAND=`echo $line |cut -d'=' -f2`
+                  COMMAND=`eval echo $COMMAND`
+                  echo $HOST $NAME `readlink -f $COMMAND` null null null >> tc.data
+              done
+           fi
+
+           if [ `echo $line |wc -w` == 3 ]; then
+              for HOST in $HOSTS
+              do
+                 if [ $HOST == `echo $line|awk '{print $2}'` ]; then
+                    NAME=`echo $line|awk '{print $3}'|cut -d'=' -f1`
+                    COMMAND=`echo $line|awk '{print $3}'|cut -d'=' -f2`
+                    COMMAND=`eval echo $COMMAND`
+                    eval echo $HOST $NAME `readlink -f $COMMAND` null null null >> tc.data
+                 fi
+               done
+            fi
          ;;
-      "#site $TEMPLATE globus_hostname="*|'#site globus_hostname=') 
-         GLOBUS_HOSTNAME=`get_value $line`
-         ;;
-      "#site $TEMPLATE nodes="*|'#site nodes='*)
-         NODES=`get_value $line`
-         ;;
-      "#site $TEMPLATE project="*|'#site project='*)
-         PROJECT=`get_value $line`
-         ;;
-      "#site $TEMPLATE queue="*|'#site queue='*)
-         QUEUE=`get_value $line`
-         ;;
-      "#site $TEMPLATE n_gran="*|'#site n_gran='*)
-         N_GRAN=`get_value $line`
-         ;;
-      "#site $TEMPLATE n_max="*|'#site n_max='*)
-         MAXTIME=`get_value $line`
-         ;;
-      "#site $TEMPLATE slots="*|'#site slots='*)
-         SLOTS=`get_value $line`
-         ;;
-      "#site $TEMPLATE execution_url="*|'#site execution_url='*)
-        EXECUTION_URL=`get_value $line`
-        ;;
-      "#site $TEMPLATE internalhostname="*|'#site internalhostname='*)
-         INTERNALHOSTNAME=`get_value $line`
-         ;;
-       '#app'*)
-         if [ `echo $line | wc -w` == 2 ]; then
-            for HOST in $HOSTS
-            do
-               NAME=`echo $line |cut -d'=' -f1|awk '{print $2}'`
-               COMMAND=`echo $line |cut -d'=' -f2`
-               COMMAND=`eval echo $COMMAND`
-               echo $HOST $NAME `readlink -f $COMMAND` null null null >> tc.data
-           done
-        fi
-         
-	if [ `echo $line |wc -w` == 3 ]; then
-           for HOST in $HOSTS
-           do
-              if [ $HOST == `echo $line|awk '{print $2}'` ]; then
-                 NAME=`echo $line|awk '{print $3}'|cut -d'=' -f1`
-                 COMMAND=`echo $line|awk '{print $3}'|cut -d'=' -f2`
-                 COMMAND=`eval echo $COMMAND`
-                 eval echo $HOST $NAME `readlink -f $COMMAND` null null null >> tc.data
-             fi
-          done
-        fi
-        ;;
-   esac
-done < $PROPERTIES_FILE
+      esac
+   done < $PROPERTIES_FILE
+fi
 
-# Test for mandatory variables
-[[ ${WORK}   == "" ]] && crash "Not specified: WORK"
-
 # Verify that the variables by the template are defined
 for TOKEN in NODES HOST WORK PROJECT QUEUE N_GRAN N_MAX SLOTS INTERNALHOSTNAME MAXTIME EXECUTION_URL
 do

Modified: trunk/bin/start-coaster-service
===================================================================
--- trunk/bin/start-coaster-service	2011-09-24 21:29:54 UTC (rev 5166)
+++ trunk/bin/start-coaster-service	2011-09-24 21:32:35 UTC (rev 5167)
@@ -119,18 +119,18 @@
 RUN_DIR=`pwd`
 
 # Import settings
-if [ -f "$HOME/.swift/coaster-service.conf" ]; then
+if [ -f "$RUN_DIR/coaster-service.conf" ]; then
+   CONFIG_FILE="$RUN_DIR/coaster-service.conf"
+elif [ -f "$HOME/.swift/coaster-service.conf" ]; then
    CONFIG_FILE="$HOME/.swift/coaster-service.conf"
 elif [ -f "$(dirname $(readlink -f $0))/../etc/coaster-service.conf" ]; then
    CONFIG_FILE="$(dirname $(readlink -f $0))/../etc/coaster-service.conf"
-fi
-
-if [ -n "$CONFIG_FILE" ]; then
-   source "$CONFIG_FILE"
 else
    crash "Cannot find coaster-service.conf!"
 fi
 
+source $CONFIG_FILE
+
 # Determine information needed about this machine
 if [ -z "$IPADDR" ]; then
    if [ -x "/sbin/ifconfig" ]; then

Modified: trunk/bin/stop-coaster-service
===================================================================
--- trunk/bin/stop-coaster-service	2011-09-24 21:29:54 UTC (rev 5166)
+++ trunk/bin/stop-coaster-service	2011-09-24 21:32:35 UTC (rev 5167)
@@ -12,24 +12,19 @@
 PID_FILE="$HOME/.swift/.coaster-service-pids"
 SWIFTVM_INSTANCES="$HOME/.swift/.swiftvm_instances"
 
-if [ -f "$HOME/.swift/coaster-service.conf" ]; then
+# Import settings
+if [ -f "./coaster-service.conf" ]; then
+   CONFIG_FILE="./coaster-service.conf"
+elif [ -f "$HOME/.swift/coaster-service.conf" ]; then
    CONFIG_FILE="$HOME/.swift/coaster-service.conf"
 elif [ -f "$(dirname $(readlink -f $0))/../etc/coaster-service.conf" ]; then
    CONFIG_FILE="$(dirname $(readlink -f $0))/../etc/coaster-service.conf"
-fi
-
-if [ -z "$CONFIG_FILE" ]; then
-   crash "Unable to find coaster-service.conf!"
-fi
-
-
-# Read config file to determine worker mode
-if [ -f "$CONFIG_FILE" ]; then
-   source "$CONFIG_FILE"
 else
    crash "Cannot find coaster-service.conf!"
 fi
 
+source "$CONFIG_FILE"
+
 echo Ending coaster processes..
 if [ -f "$PID_FILE" ]; then
    for pid in `cat $PID_FILE`




More information about the Swift-commit mailing list