Allow setting policy-rc.d
diff --git a/README.rst b/README.rst
index cd43da2..9d1ae82 100644
--- a/README.rst
+++ b/README.rst
@@ -139,6 +139,20 @@
 
 To disable set autologin to `false`.
 
+Set ``policy-rc.d`` on Debian-based systems. Action can be any available
+command in ``while true`` loop and ``case`` context.
+Following will disallow dpkg to stop/start services for cassandra package automatically:
+
+.. code-block:: yaml
+
+    linux:
+      system:
+        policyrcd:
+          - package: cassandra
+            action: exit 101
+          - package: '*'
+            action: switch
+
 Kernel
 ~~~~~~
 
diff --git a/linux/files/policy-rc.d b/linux/files/policy-rc.d
new file mode 100644
index 0000000..20868fd
--- /dev/null
+++ b/linux/files/policy-rc.d
@@ -0,0 +1,10 @@
+{%- from "linux/map.jinja" import system with context -%}
+#!/bin/sh
+
+while true; do
+case $1 in
+  {%- for policy in system.policyrcd %}
+  {{ policy.package }}) {{ policy.action }};;
+  {%- endfor %}
+esac
+done
diff --git a/linux/system/init.sls b/linux/system/init.sls
index 6c149bb..4864f43 100644
--- a/linux/system/init.sls
+++ b/linux/system/init.sls
@@ -51,3 +51,6 @@
 {%- if system.motd|length > 0 %}
 - linux.system.motd
 {%- endif %}
+{%- if system.get('policyrcd', [])|length > 0 %}
+- linux.system.policyrcd
+{%- endif %}
diff --git a/linux/system/policyrcd.sls b/linux/system/policyrcd.sls
new file mode 100644
index 0000000..fe3c495
--- /dev/null
+++ b/linux/system/policyrcd.sls
@@ -0,0 +1,19 @@
+{%- from "linux/map.jinja" import system with context %}
+{%- if system.enabled %}
+
+policyrcd_file:
+  file.managed:
+    - name: /usr/local/sbin/policy-rc.d
+    - source: salt://linux/files/policy-rc.d
+    - mode: 655
+    - template: jinja
+
+policyrcd_alternatives:
+  alternatives.install:
+    - name: policy-rc.d
+    - link: /usr/sbin/policy-rc.d
+    - path: /usr/local/sbin/policy-rc.d
+    - require:
+      - file: policyrcd_file
+
+{%- endif %}
diff --git a/tests/pillar/system.sls b/tests/pillar/system.sls
index f804a7e..bb27472 100644
--- a/tests/pillar/system.sls
+++ b/tests/pillar/system.sls
@@ -64,3 +64,8 @@
       opencontrail:
         source: "deb http://ppa.launchpad.net/tcpcloud/contrail-2.20/ubuntu trusty main"
         architectures: amd64
+    policyrcd:
+      - package: cassandra
+        action: exit 101
+      - package: '*'
+        action: switch