summarylogtreecommitdiffstats
path: root/kwakd.install
diff options
context:
space:
mode:
Diffstat (limited to 'kwakd.install')
-rw-r--r--kwakd.install31
1 files changed, 31 insertions, 0 deletions
diff --git a/kwakd.install b/kwakd.install
new file mode 100644
index 000000000000..dc67f9300e15
--- /dev/null
+++ b/kwakd.install
@@ -0,0 +1,31 @@
+#!/bin/sh
+# kwakd.install file.
+# Copyright 2012 Tom Vincent <http://tlvince.com/contact/>
+
+add_user() {
+ getent group kwakd &>/dev/null || groupadd -r kwakd >/dev/null
+ getent passwd kwakd &>/dev/null || \
+ useradd -r -g kwakd -d / -s /bin/false -c kwakd kwakd >/dev/null
+}
+
+# Allow kwakd to bind to port 80 without root permissions
+# See: http://stackoverflow.com/a/10552029
+grant_bind() {
+ setcap cap_net_bind_service=ep /usr/bin/kwakd
+}
+
+post_install() {
+ add_user
+ grant_bind
+}
+
+post_upgrade() {
+ add_user
+ grant_bind
+}
+
+post_remove() {
+ getent passwd kwakd &>/dev/null && userdel kwakd >/dev/null
+ getent group kwakd &>/dev/null && groupdel kwakd >/dev/null
+ true
+}