summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2013-06-26 14:33:53 +0200
committerOndřej Surý <ondrej@sury.org>2013-06-26 14:33:53 +0200
commit509ad7fe247fea6f5a60f231b3496fb4d8bc778b (patch)
treeeb65b29f085e51cc02cb57494875e4790084363f
parentf620fbe1c9cff790452f601f3e10067bd691e7d2 (diff)
downloadknot-509ad7fe247fea6f5a60f231b3496fb4d8bc778b.tar.gz
Move PIDFILE to /run/knot/knot.pid and run under knot:knot by default
-rw-r--r--debian/knot.init.d14
-rw-r--r--debian/knot.postinst16
-rw-r--r--debian/knot.postrm22
-rw-r--r--debian/patches/0001-move_pidfile_to_var_run.patch10
4 files changed, 56 insertions, 6 deletions
diff --git a/debian/knot.init.d b/debian/knot.init.d
index b9d291f..c148445 100644
--- a/debian/knot.init.d
+++ b/debian/knot.init.d
@@ -17,7 +17,8 @@ DESC="Knot DNS server" # Introduce a short description here
NAME=knotd # Introduce the short server's name here
DAEMON=/usr/sbin/$NAME # Introduce the server's location here
DAEMON_ARGS="-d" # Arguments to run the daemon with
-PIDFILE=/var/run/$NAME.pid
+RUNDIR=/run/knot
+PIDFILE=${RUNDIR}/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
# Exit if the package is not installed
@@ -33,6 +34,17 @@ SCRIPTNAME=/etc/init.d/$NAME
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
+# Don't run if we are running upstart
+if init_is_upstart; then
+ exit 1
+fi
+
+check_rundir()
+{
+ [ -d "${RUNDIR}" ] && mkdir "${RUNDIR}"
+ [ -n "${KNOT_USER}" -a -n "${KNOT_GROUP}" ] && chown ${KNOT_USER}:${KNOT_GROUP} "${RUNDIR}"
+}
+
#
# Function that starts the daemon/service
#
diff --git a/debian/knot.postinst b/debian/knot.postinst
new file mode 100644
index 0000000..a9de4cd
--- /dev/null
+++ b/debian/knot.postinst
@@ -0,0 +1,16 @@
+#!/bin/sh
+set -e
+
+if [ "$1" = "configure" ]; then
+ if ! getent passwd knot > /dev/null; then
+ adduser --quiet --system --group --no-create-home knot
+ fi
+
+ dpkg-statoverride --list /var/lib/knot > /dev/null || dpkg-statoverride --update --add knot knot 0755 /var/lib/knot
+ dpkg-statoverride --list /etc/knot/knot.conf > /dev/null || dpkg-statoverride --update --add knot knot 0640 /etc/knot/knot.conf
+ dpkg-statoverride --list /etc/knot > /dev/null || dpkg-statoverride --update --add knot knot 0750 /etc/knot
+fi
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/knot.postrm b/debian/knot.postrm
new file mode 100644
index 0000000..ed21405
--- /dev/null
+++ b/debian/knot.postrm
@@ -0,0 +1,22 @@
+#!/bin/sh
+set -e
+
+unset_perms() {
+
+}
+
+if test "$1" = "purge"; then
+ spool=/var/lib/knot
+ rm -f $spool/*.db $spool/*.db.crc
+ rmdir $spool 2>/dev/null || true
+
+ dpkg-statoverride --remove /var/lib/knot >/dev/null 2>/dev/null || true
+ dpkg-statoverride --remove /etc/knot/knot.conf >/dev/null 2>/dev/null || true
+ dpkg-statoverride --remove /etc/knot >/dev/null 2>/dev/null || true
+
+ deluser --quiet knot > /dev/null || true
+fi
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/patches/0001-move_pidfile_to_var_run.patch b/debian/patches/0001-move_pidfile_to_var_run.patch
index 2cc2961..2dc60c9 100644
--- a/debian/patches/0001-move_pidfile_to_var_run.patch
+++ b/debian/patches/0001-move_pidfile_to_var_run.patch
@@ -1,16 +1,16 @@
---- a/src/knot/common.h
-+++ b/src/knot/common.h
+--- knot.orig/src/knot/common.h
++++ knot/src/knot/common.h
@@ -42,7 +42,7 @@ typedef unsigned int uint; /*!< \brief U
#define PROJECT_EXEC SBINDIR "/" "knotd" /*!< \brief Project executable. */
#define ZONEPARSER_EXEC LIBEXECDIR "/" "knot-zcompile" /*!< \brief Zoneparser executable. */
-#define PID_FILE "knot.pid" /*!< \brief Server PID file name. */
-+#define PID_FILE "/var/run/knotd.pid" /*!< \brief Server PID file name. */
++#define PID_FILE "/run/knot/knotd.pid" /*!< \brief Server PID file name. */
/*
* Server.
---- a/src/knot/conf/conf.c
-+++ b/src/knot/conf/conf.c
+--- knot.orig/src/knot/conf/conf.c
++++ knot/src/knot/conf/conf.c
@@ -154,7 +154,7 @@ static int conf_process(conf_t *conf)
// Create PID file