diff options
Diffstat (limited to 'net-irc/quassel/files/quasselcore.init')
-rw-r--r-- | net-irc/quassel/files/quasselcore.init | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/net-irc/quassel/files/quasselcore.init b/net-irc/quassel/files/quasselcore.init new file mode 100644 index 000000000000..8dacba7c7356 --- /dev/null +++ b/net-irc/quassel/files/quasselcore.init @@ -0,0 +1,60 @@ +#!/sbin/runscript +# Copyright 1999-2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-irc/quassel/files/quasselcore.init,v 1.5 2010/07/01 10:34:03 scarabeus Exp $ + +depend() { + need net + use postgres +} + +LOGFILE="/var/log/quassel.log" +CORE="$(which quasselcore)" +PID="/var/run/quassel.pid" +CONFIGDIR="/var/lib/quassel/" +QUASSEL_USER="quassel" + +checkconfig() { + # check config folder + if [ ! -d "${CONFIGDIR}" ]; then + mkdir ${CONFIGDIR} || return 1 + fi + # permissions always changed just to avoid runtime issues + chown -r ${QUASSEL_USER}:${QUASSEL_USER} ${CONFIGDIR} || return 1 + + # check log file + if [ ! -e "${LOGFILE}" ]; then + touch ${LOGFILE} || return 1 + fi + # permissions always changed just to avoid runtime issues + chown ${QUASSEL_USER}:${QUASSEL_USER} ${LOGFILE} || return 1 +} + +start() { + checkconfig || return 1 + + ebegin "Starting Quassel Core" + + if [ -n "${RC_UNAME}" ]; then + # running on baselayout-2/openrc + start-stop-daemon --start --user ${QUASSEL_USER} --background --make-pidfile \ + --pidfile ${PID} \ + --exec ${CORE} -- --logfile=${LOGFILE} --loglevel=${LOGLEVEL:-"Info"} \ + --listen=${LISTEN:-"0.0.0.0"} --port=${PORT:-"4242"} \ + --configdir=${CONFIGDIR:-"/var/lib/quassel/"} + else + # running on baselayout-1 + start-stop-daemon --start --chuid ${QUASSEL_USER} --background --make-pidfile \ + --pidfile ${PID} --env HOME="/var/lib/quassel/" \ + --exec ${CORE} -- --logfile=${LOGFILE} --loglevel=${LOGLEVEL:-"Info"} \ + --listen=${LISTEN:-"0.0.0.0"} --port=${PORT:-"4242"} \ + --configdir=${CONFIGDIR:-"/var/lib/quassel/"} + fi + eend $? +} + +stop() { + ebegin "Stopping Quassel Core" + start-stop-daemon --stop --pidfile ${PID} --exec ${CORE} + eend $? +} |