script for starting xos inside docker, add postgres wait
diff --git a/Dockerfile b/Dockerfile
index 7ca3b75..7d84cd7 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -131,4 +131,4 @@
 
 # Define default command.
 #CMD ["/bin/bash"]
-CMD service postgresql start; service supervisor start; cd /opt/xos; PUBLIC_HOSTNAME=`./xos-config.py get server_hostname $HOSTNAME`; python manage.py runserver $PUBLIC_HOSTNAME:8000 --insecure
+CMD /opt/xos/scripts/docker_start_xos
diff --git a/xos/scripts/docker_start_xos b/xos/scripts/docker_start_xos
new file mode 100755
index 0000000..e5d6558
--- /dev/null
+++ b/xos/scripts/docker_start_xos
@@ -0,0 +1,15 @@
+function wait_postgres {
+    sudo -u postgres psql -c '\q'
+    while [[ "$?" != "0" ]]; do
+        echo Waiting for postgres to start
+        sleep 1
+        sudo -u postgres psql -c '\q'
+    done
+}
+
+service postgresql start
+wait_postgres
+service supervisor start
+cd /opt/xos
+PUBLIC_HOSTNAME=`./xos-config.py get server_hostname $HOSTNAME`
+python manage.py runserver $PUBLIC_HOSTNAME:8000 --insecure