Merge pull request #130 from cloudbuilders/fix_races

Address races in NBD and images
diff --git a/exercise.sh b/exercise.sh
index ce69a93..9b63888 100755
--- a/exercise.sh
+++ b/exercise.sh
@@ -188,3 +188,4 @@
 
 # make sure that we can describe instances
 euca-describe-instances
+Mon Oct 31 15:18:21 PDT 2011
diff --git a/files/sources.list b/files/sources.list
index a58eca3..77a1bfb 100644
--- a/files/sources.list
+++ b/files/sources.list
@@ -1,9 +1,9 @@
-deb http://us.archive.ubuntu.com/ubuntu/ %DIST% main restricted
-deb http://us.archive.ubuntu.com/ubuntu/ %DIST%-updates main restricted
-deb http://us.archive.ubuntu.com/ubuntu/ %DIST% universe
-deb http://us.archive.ubuntu.com/ubuntu/ %DIST%-updates universe
-deb http://us.archive.ubuntu.com/ubuntu/ %DIST% multiverse
-deb http://us.archive.ubuntu.com/ubuntu/ %DIST%-updates multiverse
+deb http://mirror.rackspace.com/ubuntu/ %DIST% main restricted
+deb http://mirror.rackspace.com/ubuntu/ %DIST%-updates main restricted
+deb http://mirror.rackspace.com/ubuntu/ %DIST% universe
+deb http://mirror.rackspace.com/ubuntu/ %DIST%-updates universe
+deb http://mirror.rackspace.com/ubuntu/ %DIST% multiverse
+deb http://mirror.rackspace.com/ubuntu/ %DIST%-updates multiverse
 deb http://security.ubuntu.com/ubuntu %DIST%-security main restricted
 deb http://security.ubuntu.com/ubuntu %DIST%-security universe
 deb http://security.ubuntu.com/ubuntu %DIST%-security multiverse
diff --git a/stack.sh b/stack.sh
index 7511991..9466512 100755
--- a/stack.sh
+++ b/stack.sh
@@ -22,8 +22,8 @@
 
 # Warn users who aren't on natty, but allow them to override check and attempt
 # installation with ``FORCE=yes ./stack``
-if ! grep -q natty /etc/lsb-release; then
-    echo "WARNING: this script has only been tested on natty"
+if ! egrep -q 'natty|oneiric' /etc/lsb-release; then
+    echo "WARNING: this script has only been tested on natty and oneiric"
     if [[ "$FORCE" != "yes" ]]; then
         echo "If you wish to run this script anyway run with FORCE=yes"
         exit 1
diff --git a/tools/xen/build_domU.sh b/tools/xen/build_domU.sh
index ef5815e..3e4a767 100755
--- a/tools/xen/build_domU.sh
+++ b/tools/xen/build_domU.sh
@@ -263,6 +263,23 @@
 sed -e "s,@ETH3_IP@,$PUB_IP,g" -i $INTERFACES
 sed -e "s,@ETH3_NETMASK@,$PUB_NETMASK,g" -i $INTERFACES
 
+# Gracefully cp only if source file/dir exists
+function cp_it {
+    if [ -e $1 ] || [ -d $1 ]; then
+        cp -pRL $1 $2
+    fi
+}
+
+# Copy over your ssh keys and env if desired
+COPYENV=${COPYENV:-1}
+if [ "$COPYENV" = "1" ]; then
+    cp_it ~/.ssh $STAGING_DIR/opt/stack/.ssh
+    cp_it ~/.ssh/id_rsa.pub $STAGING_DIR/opt/stack/.ssh/authorized_keys
+    cp_it ~/.gitconfig $STAGING_DIR/opt/stack/.gitconfig
+    cp_it ~/.vimrc $STAGING_DIR/opt/stack/.vimrc
+    cp_it ~/.bashrc $STAGING_DIR/opt/stack/.bashrc
+fi
+
 # Configure run.sh
 cat <<EOF >$STAGING_DIR/opt/stack/run.sh
 #!/bin/bash