From 0d3f08ddabd6498d2c8e435112222fee766ea8bd Mon Sep 17 00:00:00 2001
From: david_williams <david_williams>
Date: Thu, 19 Aug 2010 04:49:50 +0000
Subject: [PATCH] improve xvfb scripts

---
 releng.control/cc.sh           | 25 ++--------------------
 releng.control/killcc.sh       | 24 +--------------------
 releng.control/xvfb-restart.sh |  5 +++++
 releng.control/xvfb-start.sh   | 39 ++++++++++++++++++++++++++++++++++
 releng.control/xvfb-stop.sh    | 26 +++++++++++++++++++++++
 5 files changed, 73 insertions(+), 46 deletions(-)
 create mode 100644 releng.control/xvfb-restart.sh
 create mode 100644 releng.control/xvfb-start.sh
 create mode 100644 releng.control/xvfb-stop.sh

diff --git a/releng.control/cc.sh b/releng.control/cc.sh
index 5a2b9911e..cdc0e2696 100644
--- a/releng.control/cc.sh
+++ b/releng.control/cc.sh
@@ -1,6 +1,7 @@
 #!/usr/bin/env bash
 
 ulimit -n 2048
+echo "ulimit: " `ulimit -n`
 
 # remember to leave no slashes on filename in source command,
 # (the commonVariations.shsource file, that is)
@@ -11,29 +12,7 @@ then
    source ${RELENG_CONTROL}/commonComputedVariables.shsource
 fi
 
-if [ -z $DISPLAYNUMBER ]
-then
-DISPLAYNUMBER=1001
-fi
-
-if [ -z $XVFBFONTPATH ] 
-then 
-  XVFBFONTPATH=/usr/share/fonts/misc/
-fi
-
-
-# limit data space (ld) to 10m bytes. 
-# limit stack space (ls) to 1m bytes.
-# limit number of open files (lf) to 20
-# set connection time out to 60 seconds
-XVFBSCREEN=${BUILD_HOME}/tmp
-mkdir -p  ${XVFBSCREEN}
-/usr/bin/Xvfb :$DISPLAYNUMBER -screen 0 1600x1200x16 -fbdir "${XVFBSCREEN}" -fp "${XVFBFONTPATH}" -ld 10240 -ls 1024 -lf 20 -to 60 -reset  &
-echo $! > ccxvfb.pid
-
-
-
-echo "ulimit: " `ulimit -n`
+${RELENG_CONTROL}/xvfb-start.sh
 
 jmxport="7000"
 webport="7777"
diff --git a/releng.control/killcc.sh b/releng.control/killcc.sh
index c8a249df3..62ba13070 100644
--- a/releng.control/killcc.sh
+++ b/releng.control/killcc.sh
@@ -23,26 +23,4 @@ else
 fi
 echo;
 
-PIDFILE=ccxvfb.pid
-
-if [ -f ${PIDFILE} ] ; then
-  echo "    Killing Xvfb process from PID file"
-  PID=`cat ${PIDFILE}`
-  kill -3 $PID
-  # if permission denied, for example, then be sure not to remove PID file
-  if [ $? ]
-  then
-          if kill -9 $PID ; then
-            echo "    Xvfb process stopped"
-            rm -f ${PIDFILE}
-          else
-            echo "    Xvfb process could not be stopped"
-          fi
-  else
-    echo "    Could not kill the process."
-  fi
-else
-        echo "    PID file (${PIDFILE}) does not exist."
-        echo "        Either Xvfb not running, or PID file has been deleted"
-fi
-echo;
+./xvfb-stop.sh
diff --git a/releng.control/xvfb-restart.sh b/releng.control/xvfb-restart.sh
new file mode 100644
index 000000000..db83a6c72
--- /dev/null
+++ b/releng.control/xvfb-restart.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+./xvfb-stop.sh
+
+./xvfb-start.sh
diff --git a/releng.control/xvfb-start.sh b/releng.control/xvfb-start.sh
new file mode 100644
index 000000000..4d739be2f
--- /dev/null
+++ b/releng.control/xvfb-start.sh
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+
+# remember to leave no slashes on filename in source command,
+# (the commonVariations.shsource file, that is)
+# so that users path is used to find it (first)
+if [ -z $BUILD_INITIALIZED ]
+then
+   source commonVariations.shsource
+   source ${RELENG_CONTROL}/commonComputedVariables.shsource
+fi
+
+if [ -z $DISPLAYNUMBER ]
+then
+DISPLAYNUMBER=1001
+fi
+
+if [ -z $XVFBFONTPATH ] 
+then 
+  XVFBFONTPATH=/usr/share/fonts/misc/
+fi
+
+
+# limit data space (ld) to 10m bytes. 
+# limit stack space (ls) to 1m bytes.
+# limit number of open files (lf) to 20
+# set connection time out to 60 seconds
+XVFBSCREEN=${BUILD_HOME}/tmp
+mkdir -p  ${XVFBSCREEN}
+
+Xvfb :$DISPLAYNUMBER -screen 0 1600x1200x16 -fbdir "${XVFBSCREEN}" -fp "${XVFBFONTPATH}" -ld 10240 -ls 1024 -lf 20 -to 60 -reset -bs &
+XVFBPID=$!
+echo $XVFBPID > ccxvfb.pid
+
+echo "DISPLAYNUMBER: " $DISPLAYNUMBER;
+echo "XVFBFONTPATH: " $XVFBFONTPATH;
+echo "XVFBSCREEN: " $XVFBSCREEN;
+echo "XVFBPID: " $XVFBPID;
+
+
diff --git a/releng.control/xvfb-stop.sh b/releng.control/xvfb-stop.sh
new file mode 100644
index 000000000..8399a2fd2
--- /dev/null
+++ b/releng.control/xvfb-stop.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+
+
+PIDFILE=ccxvfb.pid
+
+if [ -f ${PIDFILE} ] ; then
+  echo "    Killing Xvfb process from PID file"
+  PID=`cat ${PIDFILE}`
+  kill -3 $PID
+  # if permission denied, for example, then be sure not to remove PID file
+  if [ $? ]
+  then
+          if kill -9 $PID ; then
+            echo "    Xvfb process stopped"
+            rm -f ${PIDFILE}
+          else
+            echo "    Xvfb process could not be stopped"
+          fi
+  else
+    echo "    Could not kill the process."
+  fi
+else
+        echo "    PID file (${PIDFILE}) does not exist."
+        echo "        Either Xvfb not running, or PID file has been deleted"
+fi
+echo;
\ No newline at end of file
-- 
GitLab