summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2010-12-17 14:16:59 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2010-12-17 14:20:12 +0100
commit6793f3f5743c4a1b46864c92b3559a52eae1f8a9 (patch)
tree920686b2c2b883cf4badd976db81c179b5af4485
downloadstartscripts-6793f3f5743c4a1b46864c92b3559a52eae1f8a9.tar.gz
startscripts-6793f3f5743c4a1b46864c92b3559a52eae1f8a9.tar.xz
startscripts-6793f3f5743c4a1b46864c92b3559a52eae1f8a9.zip
znc: added init.d script and conf.d file
-rw-r--r--znc/conf.d/znc13
-rwxr-xr-xznc/init.d/znc74
2 files changed, 87 insertions, 0 deletions
diff --git a/znc/conf.d/znc b/znc/conf.d/znc
new file mode 100644
index 0000000..bc321a5
--- /dev/null
+++ b/znc/conf.d/znc
@@ -0,0 +1,13 @@
+# conf.d file for ZNC
+# Copyright 1999-2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+# $Header: $
+
+# znc binary to start
+#ZNC_DAEMON="/usr/bin/znc"
+
+# start the daemon as other user
+#ZNC_USER="nobody"
+
+# datadir for znc (you can supply multiple dirs seperated with spaces)
+#ZNC_DATADIR=""
diff --git a/znc/init.d/znc b/znc/init.d/znc
new file mode 100755
index 0000000..14b30cd
--- /dev/null
+++ b/znc/init.d/znc
@@ -0,0 +1,74 @@
+#!/sbin/runscript
+# Copyright 1999-2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+# $Header: $
+
+ZNC_USER=${ZNC_USER:-"nobody"}
+ZNC_DAEMON=${ZNC_DAEMON:-"/usr/bin/znc"}
+
+depend() {
+ need net oidentd
+}
+
+checkconfig() {
+ if [ -z "${ZNC_DATADIR}" ]; then
+ eerror "Please set at least one datadir for ZNC!"
+ return 1
+ fi
+
+ mkdir -p /var/run/znc/
+ if [ ! -d /var/run/znc ]; then
+ eerror "Unable to create /var/run/znc!"
+ return 1
+ fi
+
+ return 0
+}
+
+start() {
+ checkconfig || return 1
+ ebegin "Starting ZNC"
+ eindent
+
+ for dir in "${ZNC_DATADIR}"; do
+ if [ -d "${dir}" ]; then
+ ebegin "${dir}"
+
+ pidfile=$(mktemp --tmpdir=/var/run/znc)
+ start-stop-daemon --start --quiet \
+ --chuid ${ZNC_USER} \
+ --exec ${ZNC_DAEMON} \
+ --pidfile ${pidfile} \
+ --make-pidfile --background \
+ --chdir ${dir} -- -d ${dir} -f
+
+ eend $?
+ fi
+ done
+
+ eoutdent
+ eend $?
+}
+
+stop() {
+ checkconfig || return 1
+ ebegin "Stopping ZNC"
+ eindent
+
+ for pidfile in /var/run/znc/* ; do
+ pid=$(< ${pidfile})
+
+ if [ -L /proc/${pid}/cwd ]; then
+ ebegin $(readlink /proc/${pid}/cwd)
+
+ start-stop-daemon --stop --user ${ZNC_USER} \
+ --exec ${ZNC_DAEMON} \
+ --pidfile ${pidfile}
+
+ eend $?
+ fi
+ done
+
+ eoutdent
+ eend $?
+}