Merge branch 'acb-develop'
Add basic message page explaining why service has been turned off.
diff --git a/xos/synchronizers/vcpe/files/etc/service/message/run b/xos/synchronizers/vcpe/files/etc/service/message/run
new file mode 100755
index 0000000..59c2759
--- /dev/null
+++ b/xos/synchronizers/vcpe/files/etc/service/message/run
@@ -0,0 +1,16 @@
+#!/usr/bin/python
+
+import BaseHTTPServer
+class HTTPHandlerOne(BaseHTTPServer.BaseHTTPRequestHandler):
+  def do_GET(self):
+      with open('./message.html', 'r') as msgfile:
+          message = msgfile.read()
+      self.wfile.write(message)
+
+def run(server_class=BaseHTTPServer.HTTPServer,
+        handler_class=BaseHTTPServer.BaseHTTPRequestHandler):
+    server_address = ('192.168.0.1', 8000)
+    httpd = server_class(server_address, handler_class)
+    httpd.serve_forever()
+
+run(handler_class=HTTPHandlerOne)
diff --git a/xos/synchronizers/vcpe/steps/sync_vcpetenant_vtn.yaml b/xos/synchronizers/vcpe/steps/sync_vcpetenant_vtn.yaml
index eed6b42..3fb7fa7 100644
--- a/xos/synchronizers/vcpe/steps/sync_vcpetenant_vtn.yaml
+++ b/xos/synchronizers/vcpe/steps/sync_vcpetenant_vtn.yaml
@@ -239,17 +239,35 @@
     notify:
     - reset bwlimits
 
+  - name: copy simple webserver
+    copy: src=/opt/xos/synchronizers/vcpe/files/etc/service/ dest=/var/container_volumes/{{ container_name }}/etc/service/ owner=root group=root
+    when: status != "enabled"
+
+  - name: generate the message page
+    template: src=/opt/xos/synchronizers/vcpe/templates/message.html.j2 dest=/var/container_volumes/{{ container_name }}/etc/service/message/message.html owner=root group=root mode=0644
+    when: status != "enabled"
+    notify: restart vcpe
+
+  - name: remove simple webserver
+    file: path=/var/container_volumes/{{ container_name }}/etc/service/message state=absent
+    when: status == "enabled"
+    notify: restart vcpe
+
   - name: Make sure vCPE service is running
     service: name={{ container_name }} state=started
 
   handlers:
+  # Use docker cp instead of single-file volume
+  # The reason is that changes to external file volume don't show up inside the container
+  # Probably Ansible deletes and then recreates the external file, and container has old version
+  # Do this handler first, e.g., before restarting the container
+  - name: copy in /etc/rc.local
+    shell: docker cp /var/container_volumes/{{ container_name }}/etc/rc.local {{ container_name }}:/etc/
+
   # Dnsmasq is automatically restarted in the container
   - name: restart dnsmasq
     shell: docker exec {{ container_name }} killall dnsmasq
 
-  - name: restart vcpe
-    shell: service {{ container_name }} stop; sleep 1; service {{ container_name }} start
-
   - name: stop vcpe
     service: name={{ container_name }} state=stopped
 
@@ -262,14 +280,11 @@
   - name: reload ufw
     shell: docker exec {{ container_name }} bash -c "/sbin/iptables -t nat -F PREROUTING; /usr/sbin/ufw reload"
 
-  # Use docker cp instead of single-file volume
-  # The reason is that changes to external file volume don't show up inside the container
-  # Probably Ansible deletes and then recreates the external file, and container has old version
-  - name: copy in /etc/rc.local
-    shell: docker cp /var/container_volumes/{{ container_name }}/etc/rc.local {{ container_name }}:/etc/
-
   - name: rerun /etc/rc.local
     shell: docker exec {{ container_name }} bash -c "/etc/rc.local"
 
   - name: reset bwlimits
     shell: docker exec {{ container_name }} bash -c "/usr/local/sbin/bwlimit.sh restart"
+
+  - name: restart vcpe
+    shell: service {{ container_name }} stop; sleep 1; service {{ container_name }} start
diff --git a/xos/synchronizers/vcpe/templates/before.rules.j2 b/xos/synchronizers/vcpe/templates/before.rules.j2
index e6f7d4a..b60aaef 100644
--- a/xos/synchronizers/vcpe/templates/before.rules.j2
+++ b/xos/synchronizers/vcpe/templates/before.rules.j2
@@ -26,6 +26,10 @@
 {% endfor %}
 {% endif %}
 
+{% if status != "enabled" %}
+-A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 8000
+{% endif %}
+
 # don't delete the 'COMMIT' line or these nat table rules won't be processed
 COMMIT
 
diff --git a/xos/synchronizers/vcpe/templates/message.html.j2 b/xos/synchronizers/vcpe/templates/message.html.j2
new file mode 100644
index 0000000..a04e822
--- /dev/null
+++ b/xos/synchronizers/vcpe/templates/message.html.j2
@@ -0,0 +1,8 @@
+{% if status == "delinquent" %}
+Your account is delinquent.  Please visit the customer portal to pay your bill.
+{% elif status == "copyrightviolation" %}
+Someone in your home has been illegally downloading copyrighted material.
+Please visit the customer portal and perform the Copyright Training course.
+{% else %}
+Your service has been suspended.  Please visit the customer portal to resume.
+{% endif %}
diff --git a/xos/synchronizers/vcpe/templates/start-vcpe-vtn.sh.j2 b/xos/synchronizers/vcpe/templates/start-vcpe-vtn.sh.j2
index e118b3c..62c504e 100644
--- a/xos/synchronizers/vcpe/templates/start-vcpe-vtn.sh.j2
+++ b/xos/synchronizers/vcpe/templates/start-vcpe-vtn.sh.j2
@@ -20,6 +20,7 @@
     -v /var/container_volumes/$VCPE/etc/dnsmasq.d:/etc/dnsmasq.d:ro \
     -v /var/container_volumes/$VCPE/usr/local/sbin:/usr/local/sbin:ro \
     -v /var/container_volumes/$VCPE/etc/ufw:/etc/ufw \
+    -v /var/container_volumes/$VCPE/etc/service/message:/etc/service/message \
     andybavier/docker-vcpe
 else
     docker start $VCPE