Add comments for all. Automate cleanNightly.sh - no need for $1
diff --git a/cleanNightly.sh b/cleanNightly.sh
index 6e730fe..20a8eb0 100755
--- a/cleanNightly.sh
+++ b/cleanNightly.sh
@@ -1,9 +1,10 @@
 # !/bin/sh
 #set -x
 
+# Cleanup old builds from publish area, and repos
+
 version=$1
 BaseDownloadNFSDir="/home/data/httpd/download.eclipse.org/rt/eclipselink"
-DownloadDir=${BaseDownloadNFSDir}/nightly/${version}
 buildir=/shared/rt/eclipselink
 
 
@@ -27,7 +28,71 @@
     done
     if [ ! "$valid" = "true" ] ; then
        echo "Version not present in nightly. '${runVersion}' isn't a valid or active version..."
-       exit
+       error=true
+    fi
+}
+
+unset cleanNightlyDir
+cleanNightlyDir() {
+    DownloadDir=${BaseDownloadNFSDir}/nightly/${workingVersion}
+    #      leave only the last 10 build dirs for the version on the download server
+    if [ -d ${DownloadDir} ] ; then
+        index=0
+        removed=0
+        cd ${DownloadDir}
+        for contentdir in `ls -dr [0-9]*` ; do
+            index=`expr $index + 1`
+            if [ $index -gt $num_builds ] ; then
+                echo "Removing ${contentdir}..."
+                rm -r $contentdir
+                removed=`expr $removed + 1`
+            fi
+        done
+        echo "Removed $removed directories from ${BaseDownloadNFSDir}/nightly/${workingVersion}."
+    else
+        error=true
+    fi
+}
+
+unset cleanP2NightlySite
+cleanP2NightlySite() {
+    #   leave only the last "num_p2_builds" builds for the version in the nightly P2 repos
+    index=0
+    removed=0
+    cd ${BaseDownloadNFSDir}/nightly-updates
+    for contentdir in `ls -dr ${workingVersion}*` ; do
+        index=`expr $index + 1`
+        if [ $index -gt $num_p2_builds ] ; then
+            echo "Removing ${contentdir}..."
+            rm -r $contentdir
+            removed=`expr $removed + 1`
+        fi
+    done
+    echo "Removed $removed direcories from ${BaseDownloadNFSDir}/nightly-updates."
+}
+
+unset cleanMavenNightlySite
+cleanMavenNightlySite() {
+    if [ "true" = "true" ] ; then
+        echo "TODO: Need to verify the "correct" way to clean the maven repo of old SNAPSHOTs"
+        echo "      In the meantime nothing in the maven repo is cleaned!!"
+    else
+        #      leave only last 5 days worth of files in the maven repository
+        cd ${BaseDownloadNFSDir}/maven.repo/org/eclipse/persistence
+        for mvncomp in `ls -d *eclipse*` ; do
+            index=0
+            removed=0
+            cd ${BaseDownloadNFSDir}/maven.repo/org/eclipse/persistence/${mvncomp}/${workingVersion}-SNAPSHOT
+            for mvnfile in `ls -r ${mvncomp}*.*` ; do
+                index=`expr $index + 1`
+                if [ $index -gt $num_maven_files ] ; then
+                   echo "Removing ${mvnfile}..."
+                   rm $mvnfile
+                   removed=`expr $removed + 1`
+                fi
+            done
+            echo "Removed $removed files from ${BaseDownloadNFSDir}/maven.repo/org/eclipse/persistence/${mvncomp}/${workingVersion}-SNAPSHOT."
+        done
     fi
 }
 
@@ -35,82 +100,46 @@
 #
 # MAIN
 #
-if [ \( -z "$version" \) -o \( "$version" = "" \) ] ; then
-    usage
-    exit
-else
+if [ ! \( \( -z "$version" \) -o \( "$version" = "" \) \) ] ; then
    validateVersion ${version}
-   echo "Purging old builds of '${version}'..."
+   if [ "$error" = "true" ] ; then
+       echo "$version not found!"
+       exit 1
+   fi
+else
+   cd ${BaseDownloadNFSDir}/nightly
+   version=`ls -dr [0-9]*`
 fi
 
-cd ${buildir}
 if [ "input" = "release" ]
 then
-    # When releasing clear all nightly builds
-    num_builds=0
-    num_p2_builds=0
-    num_maven_builds=0
+   # When releasing clear all nightly builds
+   num_builds=0
+   num_p2_builds=0
+   num_maven_builds=0
 else
-    num_builds=10
-    num_p2_builds=5
-    # Maven: 5 builds * 9 files/build = 45
-    num_maven_files=45
+   num_builds=10
+   num_p2_builds=5
+   # Maven: 5 builds * 9 files/build = 45
+   num_maven_files=45
 fi
 
-### Download Site ###
-#      leave only the last 10 build dirs for the version on the download server
-if [ -d ${DownloadDir} ] ; then
-    index=0
-    removed=0
-    cd ${DownloadDir}
-    for contentdir in `ls -dr [0-9]*` ; do
-        index=`expr $index + 1`
-        if [ $index -gt $num_builds ] ; then
-            echo "Removing ${contentdir}..."
-            rm -r $contentdir
-            removed=`expr $removed + 1`
-        fi
-    done
-    echo "Removed $removed directories from ${BaseDownloadNFSDir}/nightly/${version}."
-else
-    echo "No '${BaseDownloadNFSDir}/nightly/${version}' dir found!
-    echo "    Assuming invalid version number, and aborting clean.
-    exit
-fi
+for workingVersion in ${version} ; do
+   cd ${buildir}
+   echo "Purging old builds of '${workingVersion}'..."
 
-### P2 Site ###
-#      leave only the last "num_p2_builds" builds for the version in the nightly P2 repos
-index=0
-removed=0
-cd ${BaseDownloadNFSDir}/nightly-updates
-for contentdir in `ls -dr ${version}*` ; do
-    index=`expr $index + 1`
-    if [ $index -gt $num_p2_builds ] ; then
-        echo "Removing ${contentdir}..."
-        rm -r $contentdir
-        removed=`expr $removed + 1`
-    fi
-done
-echo "Removed $removed direcories from ${BaseDownloadNFSDir}/nightly-updates."
-
-echo "TODO: Need to verify the "correct" way to clean the maven repo of old SNAPSHOTs"
-echo "Hit the fullstop!"
-exit
-### Maven Site ###
-#      leave only last 5 days worth of files in the maven repository
-cd ${BaseDownloadNFSDir}/maven.repo/org/eclipse/persistence
-for mvncomp in `ls -d *eclipse*` ; do
-    index=0
-    removed=0
-    cd ${BaseDownloadNFSDir}/maven.repo/org/eclipse/persistence/${mvncomp}/${version}-SNAPSHOT
-    for mvnfile in `ls -r ${mvncomp}*.*` ; do
-        index=`expr $index + 1`
-        if [ $index -gt $num_maven_files ] ; then
-           echo "Removing ${mvnfile}..."
-           rm $mvnfile
-           removed=`expr $removed + 1`
-        fi
-    done
-    echo "Removed $removed files from ${BaseDownloadNFSDir}/maven.repo/org/eclipse/persistence/${mvncomp}/${version}-SNAPSHOT."
+   ### Download Site ###
+   cleanNightlyDir
+   if [ "$error" = "true" ] ; then
+      echo "No '${BaseDownloadNFSDir}/nightly/${workingVersion}' dir found!"
+      echo "    Assuming invalid version number, and aborting clean."
+      exit
+   fi
+   
+   ### P2 Site ###
+   cleanP2NightlySite
+   
+   ### Maven Site ###
+   cleanMavenNightlySite   
 done
 cd ${buildir}
diff --git a/cleanTestDb.sh b/cleanTestDb.sh
index 4d6f806..d881255 100755
--- a/cleanTestDb.sh
+++ b/cleanTestDb.sh
@@ -1,5 +1,7 @@
 # !/bin/sh
 
+# This cleans the database used by a specific branch for its cb and nightly builds
+
 BRANCH=$1
 COMMON_BLD_ROOT=/shared/rt/eclipselink
 MYSQL_EXEC=/usr/bin/mysql
diff --git a/dbclean.sh b/dbclean.sh
index 595b14c..1a546b9 100755
--- a/dbclean.sh
+++ b/dbclean.sh
@@ -1,5 +1,7 @@
 # !/bin/sh
 
+#This cleans all the tables used by all cb and nightly builds (super sledge)
+
 SETUP=FALSE
 ARG1=$1