debian: About time, really.
[distorted-keys] / debian / distorted-keys.postinst
diff --git a/debian/distorted-keys.postinst b/debian/distorted-keys.postinst
new file mode 100755 (executable)
index 0000000..99a1809
--- /dev/null
@@ -0,0 +1,21 @@
+#! /bin/sh
+
+set -e
+
+user=keys
+home=/var/lib/distorted-keys
+
+## Make sure the user exists.
+if ! grep -q ^$user: /etc/passwd; then
+  adduser --quiet --system --group \
+    --disabled-password --shell /bin/false \
+    --no-create-home --home $home \
+    $user
+fi
+
+## Make the home directory if we need to.
+if [ ! -d $home ]; then
+  mkdir -p $home
+  chown $user:$user $home
+  chmod 2755 $home
+fi