From 424f552b350130be894a9fe03c3d09e3ac3dd24e Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Fri, 17 Dec 2010 20:41:48 +0100 Subject: eggdrop: inital version --- eggdrop/conf.d/eggdrop | 22 ++++++++++++ eggdrop/init.d/eggdrop | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 eggdrop/conf.d/eggdrop create mode 100755 eggdrop/init.d/eggdrop diff --git a/eggdrop/conf.d/eggdrop b/eggdrop/conf.d/eggdrop new file mode 100644 index 0000000..87801eb --- /dev/null +++ b/eggdrop/conf.d/eggdrop @@ -0,0 +1,22 @@ +# conf.d file for eggdrop irc bot +# Copyright 1999-2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License, v2 or later +# $Header: $ + +# eggdrop binary to start +#EGGDROP_DAEMON="/opt/eggdrop/eggdrop" + +# start the daemon as other user +#EGGDROP_USER="nobody" + +# eatadir for the bot (this is the dir where the config, users, scripts +# and all other files are lying around) +#EGGDROP_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/eggdrop.something +# * then you can override the variable with appending _something to +# the name +#EGGDROP_DATADIR_something="" diff --git a/eggdrop/init.d/eggdrop b/eggdrop/init.d/eggdrop new file mode 100755 index 0000000..3752b0b --- /dev/null +++ b/eggdrop/init.d/eggdrop @@ -0,0 +1,93 @@ +#!/sbin/runscript +# Copyright 1999-2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License, v2 or later +# $Header: $ + +opts="checkconfig" + +EGGDROP_USER=${EGGDROP_USER:-"nobody"} +EGGDROP_DAEMON=${EGGDROP_DAEMON:-"/opt/eggdrop/eggdrop"} +EGGDROP_EXTRA_ARGS="" + +depend() { + need net oidentd + provide eggdrop +} + +checkconfig() { + local instance=${RC_SVCNAME#*.} + local instanceVar=$(shell_var "${instance}") + + if [ -n "$instanceVar" ]; then + eval local_datadir=\$EGGDROP_DATADIR_${instanceVar} + + if [ -n "${local_datadir}" ]; then + EGGDROP_DATADIR=${local_datadir} + fi + + eval local_user=\$EGGDROP_USER_${instanceVar} + + if [ -n "${local_user}" ]; then + EGGDROP_USER=${local_USER} + fi + + eval local_daemon=\$EGGDROP_DAEMON_${instanceVar} + + if [ -n "${local_daemon}" ]; then + EGGDROP_DAEMON=${local_daemon} + fi + fi + + if [ -n "${instance}" ]; then + EGGDROP_EXTRA_ARGS="--startas eggdrop(${instance})" + fi + + if [ ! -d "${EGGDROP_DATADIR}" ]; then + eerror "Please set a valid datadir for the eggdrop!" + return 1 + fi + + return 0 +} + +_get_pid_file() { + local pid=$(grep "^ *set pidfile" "${1}/eggdrop.conf" | cut -d\" -f2) + + if [ -n "$pid" ]; then + echo "${1}/$pid" + else + local botnet_nick=$(grep "^ *set botnet-nick" "${1}/eggdrop.conf" | cut -d\" -f2) + + if [ -n "${botnet_nick}" ]; then + echo "${1}/pid.${botnet_nick}" + else + local nick=$(grep "^ *set nick" "${1}/eggdrop.conf" | cut -d\" -f2) + echo "${1}/pid.${nick}" + fi + fi +} + +start() { + checkconfig || return 1 + ebegin "Starting Eggdrop: ${EGGDROP_DATADIR}" + + pidfile=$(_get_pid_file "${EGGDROP_DATADIR}") + start-stop-daemon --start --quiet --chuid ${EGGDROP_USER} \ + --exec ${EGGDROP_DAEMON} --pidfile ${pidfile} \ + --chdir ${EGGDROP_DATADIR} --wait 500 \ + ${EGGDROP_EXTRA_ARGS} + + eend $? +} + +stop() { + checkconfig || return 1 + ebegin "Stopping Eggdrop: ${EGGDROP_DATADIR}" + + pidfile=$(_get_pid_file "${EGGDROP_DATADIR}") + start-stop-daemon --stop --user ${EGGDROP_USER} \ + --exec ${EGGDROP_DAEMON} \ + --pidfile ${pidfile} + + eend $? +} -- cgit v1.2.3