* [gentoo-commits] gentoo-x86 commit in dev-db/drizzle/files: drizzle.init.d drizzle.conf.d
@ 2010-03-18 13:04 Diego Petteno (flameeyes)
0 siblings, 0 replies; only message in thread
From: Diego Petteno (flameeyes) @ 2010-03-18 13:04 UTC (permalink / raw
To: gentoo-commits
flameeyes 10/03/18 13:04:25
Added: drizzle.init.d drizzle.conf.d
Log:
Version bump from Pavel, this time with an init script that can start drizzled.
(Portage version: 2.2_rc67/cvs/Linux x86_64)
Revision Changes Path
1.1 dev-db/drizzle/files/drizzle.init.d
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-db/drizzle/files/drizzle.init.d?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-db/drizzle/files/drizzle.init.d?rev=1.1&content-type=text/plain
Index: drizzle.init.d
===================================================================
#!/sbin/runscript
# Copyright 2010 Pavel Stratil, senbonzakura.eu
# Some functions were taken from debian init script. Licensed under GPL-2
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-db/drizzle/files/drizzle.init.d,v 1.1 2010/03/18 13:04:24 flameeyes Exp $
#########################
### Construct vars ######
#########################
SUFIX=".${SVCNAME#*.}"
[ "${SUFIX}" == ".drizzle" ] && SUFIX=''
BASE_CONFD="/etc/conf.d/drizzle"
BASE_CNF="/etc/drizzle/drizzled"
BASE_PID="/var/run/drizzle/drizzled"
BASE_LOG="/var/log/drizzle/drizzled"
BASE_DIR="/var/lib/drizzle/drizzled"
PIDFILE="${BASE_PID}${SUFIX}.pid"
CNFFILE="${BASE_CNF}${SUFIX}.cnf"
LOGFILE="${BASE_LOG}${SUFIX}.log"
DATADIR="${BASE_DIR}${SUFIX}"
CONFSRC="${BASE_CONFD}${SUFIX}"
DRIZZLE="/usr/bin/drizzle"
DRIZZLE_USER="drizzle"
DRIZZLE_DAEMON="/usr/sbin/drizzled"
DRIZZLE_EXTRA=""
#########################
### Helper functions ####
#########################
#
# drizzle_get_param() fetches a particular option from drizzle's invocation.
# Usage: void drizzle_get_param option
# Example: /etc/init.d/drizzle drizzle_get_param pid-file
#
drizzle_get_param() {
${DRIZZLE_DAEMON} --print-defaults \
| tr " " "\n" \
| grep -- "--$1" \
| tail -n 1 \
| cut -d= -f2
}
#
# drizzle_status() checks if there is a server running and if it is accessible.
# "check_alive" insists on a pingable server, "check_dead" also fails
# if there is a lost drizzled in the process list
# Usage: boolean drizzle_status [check_alive|check_dead] [warn|nowarn]
#
drizzle_status() {
ping_output=`$DRIZZLE --ping 2>&1`; ping_alive=$(( ! $? ))
ps_alive=0
if [ -f "$PIDFILE" ] && ps `cat $PIDFILE` >/dev/null 2>&1; then ps_alive=1; fi
if [ "$1" = "check_alive" -a $ping_alive = 1 ] ||
[ "$1" = "check_dead" -a $ping_alive = 0 -a $ps_alive = 0 ]; then
return 0 # EXIT_SUCCESS
else
if [ "$2" = "warn" ]; then
echo -e "$ps_alive processes alive and '$DRIZZLE --ping' resulted in\n$ping_output\n"
fi
return 1 # EXIT_FAILURE
fi
}
#########################
### Main ################
#########################
checkconfig() {
CNFDATADIR=`drizzle_get_param datadir`
if [ -z "${CNFDATADIR}" ] ; then
ewarn "Datadir not set in ${CNFFILE}."
ewarn "Trying to use ${DATADIR}"
else
DATADIR="${CNFDATADIR}"
fi
if [[ ! -d "${DATADIR}" ]] ; then
eerror "Drizzle datadir is empty or invalid."
eerror "Please check your configuration ${CNFFILE} and DRIZZLE_EXTRA"
return 1
fi
if [ -f "${CONFSRC}" ]; then
source "${CONFSRC}"
else
eerror "The configuration file $CONFSRC was not found!"
fi
if [ ! -f "${CNFFILE}" ]; then
eerror "The configuration file $CNFFILE was not found!"
fi
}
depend() {
use localmount
need gearmand
need memcached
# TODO use drizzle_get_param() to decide if gearmand and memcached
# are needed. Then the useflag based sed-ing of this script
# can be removed from the ebuild.
}
stop() {
ebegin "Stopping ${SVCNAME}"
start-stop-daemon --pidfile ${PIDFILE} --stop \
--exec ${DRIZZLE_DAEMON}
eend $?
drizzle_status check_dead warn
}
start() {
checkconfig
ebegin "Starting ${SVCNAME}"
start-stop-daemon --background --pidfile ${PIDFILE} --stderr ${LOGFILE} \
--user ${DRIZZLE_USER} --start --exec ${DRIZZLE_DAEMON} -- \
--datadir=${DATADIR} --pid-file=${PIDFILE} --user=${DRIZZLE_USER} \
${DRIZZLE_EXTRA}
eend $?
# TODO in order to have replication always working we should add the
# --server-id=# option. AFAIK only integers are allowed, though
# ${HOSTNAME}${SVCNAME}${SUFIX} whould be much easier to handle.
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14; do
sleep 1
if drizzle_status check_alive nowarn ; then break ; fi
done
if drizzle_status check_alive warn ; then
einfo "${SVCNAME} is alive!"
else
eerror "${SVCNAME} died!"
fi
}
restart() {
stop
sleep 1
start
}
status() {
if drizzle_status check_alive nowarn; then
einfo "status: started"
else
einfo "status: stopped"
fi
}
1.1 dev-db/drizzle/files/drizzle.conf.d
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-db/drizzle/files/drizzle.conf.d?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-db/drizzle/files/drizzle.conf.d?rev=1.1&content-type=text/plain
Index: drizzle.conf.d
===================================================================
DRIZZLE_EXTRA=""
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-03-18 13:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-18 13:04 [gentoo-commits] gentoo-x86 commit in dev-db/drizzle/files: drizzle.init.d drizzle.conf.d Diego Petteno (flameeyes)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox