summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2010-12-17 23:09:20 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2010-12-17 23:09:20 +0100
commit654aa459549e99f38cc98f9ec32ea732ae77be7b (patch)
tree4f6e109e1748f67528d198fd88d937a7b349815a
parent47f8491a1c7655d2a852529f7348f8418922e13e (diff)
downloadstartscripts-654aa459549e99f38cc98f9ec32ea732ae77be7b.tar.gz
startscripts-654aa459549e99f38cc98f9ec32ea732ae77be7b.tar.xz
startscripts-654aa459549e99f38cc98f9ec32ea732ae77be7b.zip
znc: separate scripts for every znc instance
-rw-r--r--znc/conf.d/znc11
-rwxr-xr-xznc/init.d/znc111
2 files changed, 62 insertions, 60 deletions
diff --git a/znc/conf.d/znc b/znc/conf.d/znc
index bc321a5..fc238a4 100644
--- a/znc/conf.d/znc
+++ b/znc/conf.d/znc
@@ -9,5 +9,14 @@
# start the daemon as other user
#ZNC_USER="nobody"
-# datadir for znc (you can supply multiple dirs seperated with spaces)
+# datadir for znc
#ZNC_DATADIR=""
+
+# you can override some generic settings form above with special values:
+#
+# * first you have to create a symlink from the generic init.d script
+# to your special name like: init.d/znc.something
+# * then you can override the variable with appending _something to
+# the name
+#ZNC_DATADIR_something=""
+
diff --git a/znc/init.d/znc b/znc/init.d/znc
index eaca712..3ce3e1a 100755
--- a/znc/init.d/znc
+++ b/znc/init.d/znc
@@ -7,91 +7,84 @@ opts="checkconfig reload"
ZNC_USER=${ZNC_USER:-"nobody"}
ZNC_DAEMON=${ZNC_DAEMON:-"/usr/bin/znc"}
+ZNC_EXTRA_ARGS=""
depend() {
need net
use oidentd
+ provide znc
}
checkconfig() {
- if [ -z "${ZNC_DATADIR}" ]; then
- eerror "Please set at least one datadir for ZNC!"
- return 1
+ local instance=${RC_SVCNAME#*.}
+ local instanceVar=$(shell_var "${instance}")
+
+ if [ -n "$instanceVar" ]; then
+ eval local_datadir=\$ZNC_DATADIR_${instanceVar}
+
+ if [ -n "${local_datadir}" ]; then
+ ZNC_DATADIR=${local_datadir}
+ fi
+
+ eval local_user=\$ZNC_USER_${instanceVar}
+
+ if [ -n "${local_user}" ]; then
+ ZNC_USER=${local_USER}
+ fi
+
+ eval local_daemon=\$ZNC_DAEMON_${instanceVar}
+
+ if [ -n "${local_daemon}" ]; then
+ ZNC_DAEMON=${local_daemon}
+ fi
fi
- mkdir -p /var/run/znc/
- if [ ! -d /var/run/znc ]; then
- eerror "Unable to create /var/run/znc!"
+ if [ ! -d "${ZNC_DATADIR}" ]; then
+ eerror "Please set a valid datadir for ZNC!"
return 1
fi
return 0
}
+_get_pid_file() {
+ echo "${1}/.pid"
+}
+
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} --wait 500 \
- -- -d ${dir} -f
-
- eend $?
- fi
- done
+ ebegin "Starting ZNC: ${ZNC_DATADIR}"
+
+ pidfile=$(_get_pid_file "${ZNC_DATADIR}")
+ start-stop-daemon --start --quiet --chuid ${ZNC_USER} --exec ${ZNC_DAEMON} \
+ --pidfile ${pidfile} --make-pidfile --background \
+ --chdir ${ZNC_DATADIR} --wait 500 -- -d ${ZNC_DATADIR} -f
- eoutdent
+ eend $?
}
stop() {
checkconfig || return 1
- ebegin "Stopping ZNC"
- eindent
-
- for pidfile in /var/run/znc/* ; do
- if [ -r ${pidfile} ]; then
- pid=$(< ${pidfile})
-
- if [ -L /proc/${pid}/cwd ]; then
- ebegin $(readlink /proc/${pid}/cwd)
+ ebegin "Stopping ZNC: ${ZNC_DATADIR}"
- start-stop-daemon --stop --user ${ZNC_USER} \
- --exec ${ZNC_DAEMON} \
- --pidfile ${pidfile}
+ pidfile=$(_get_pid_file "${ZNC_DATADIR}")
+ start-stop-daemon --stop --user ${ZNC_USER} --exec ${ZNC_DAEMON} \
+ --pidfile ${pidfile}
- eend $?
- fi
- fi
- done
-
- eoutdent
+ eend $?
}
reload() {
- ebegin "Reloading ZNC"
- eindent
-
- for pidfile in /var/run/znc/* ; do
- if [ -r ${pidfile} ]; then
- pid=$(< ${pidfile})
-
- if [ -L /proc/${pid}/cwd ]; then
- ebegin $(readlink /proc/${pid}/cwd)
- kill -HUP ${pid}
- eend $?
- fi
- fi
- done
+ checkconfig || return 1
+ ebegin "Reloading ZNC: ${ZNC_DATADIR}"
+
+ pidfile=$(_get_pid_file "${ZNC_DATADIR}")
+ if [ -r ${pidfile} ]; then
+ pid=$(< ${pidfile})
+ kill -HUP ${pid}
+ else
+ eerror "Could not find the ZNC process! (pidfile not present)"
+ fi
- eoutdent
+ eend $?
}