Merge "SPM packaging metadata"
diff --git a/horizon/files/entrypoint.sh b/horizon/files/entrypoint.sh
new file mode 100644
index 0000000..be7a8ff
--- /dev/null
+++ b/horizon/files/entrypoint.sh
@@ -0,0 +1,24 @@
+{%- from "horizon/map.jinja" import server with context -%}
+#!/bin/bash -e
+
+cat /srv/salt/pillar/horizon-server.sls | envsubst > /tmp/horizon-server.sls
+mv /tmp/horizon-server.sls /srv/salt/pillar/horizon-server.sls
+
+salt-call --local --retcode-passthrough state.highstate
+
+{% for service in server.services %}
+service {{ service }} stop || true
+{% endfor %}
+
+export APACHE_RUN_USER=horizon
+export APACHE_RUN_GROUP=horizon
+export APACHE_PID_FILE=/var/run/apache2/apache2.pid
+export APACHE_RUN_DIR=/var/run/apache2
+export APACHE_LOCK_DIR=/var/lock/apache2
+export APACHE_LOG_DIR=/var/log/apache2
+
+su horizon --shell=/bin/sh -c 'apachectl -DFOREGROUND'
+
+{#-
+vim: syntax=jinja
+-#}
\ No newline at end of file
diff --git a/horizon/meta/salt.yml b/horizon/meta/salt.yml
new file mode 100644
index 0000000..1c0e954
--- /dev/null
+++ b/horizon/meta/salt.yml
@@ -0,0 +1,6 @@
+orchestrate:
+  server:
+    priority: 730
+    require:
+    - salt: keystone.server
+
diff --git a/horizon/server/service.sls b/horizon/server/service.sls
index d549c57..344a095 100644
--- a/horizon/server/service.sls
+++ b/horizon/server/service.sls
@@ -83,4 +83,15 @@
     - require:
       - file: horizon_log_dir
 
+{%- if grains.get('virtual_subtype', None) == "Docker" %}
+
+horizon_entrypoint:
+  file.managed:
+  - name: /entrypoint.sh
+  - template: jinja
+  - source: salt://horizon/files/entrypoint.sh
+  - mode: 755
+
+{%- endif %}
+
 {%- endif %}
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 6710a50..8c07e58 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -18,7 +18,7 @@
 SALT_CONFIG_DIR=${SALT_CONFIG_DIR:-${BUILDDIR}/salt}
 SALT_CACHE_DIR=${SALT_CACHE_DIR:-${SALT_CONFIG_DIR}/cache}
 
-SALT_OPTS="${SALT_OPTS} --retcode-passthrough --local -c ${SALT_CONFIG_DIR}"
+SALT_OPTS="${SALT_OPTS} --retcode-passthrough --local -c ${SALT_CONFIG_DIR} --log-file=/dev/null"
 
 if [ "x${SALT_VERSION}" != "x" ]; then
     PIP_SALT_VERSION="==${SALT_VERSION}"