diff options
| author | Robin H. Johnson <robbat2@gentoo.org> | 2015-08-08 13:49:04 -0700 |
|---|---|---|
| committer | Robin H. Johnson <robbat2@gentoo.org> | 2015-08-08 17:38:18 -0700 |
| commit | 56bd759df1d0c750a065b8c845e93d5dfa6b549d (patch) | |
| tree | 3f91093cdb475e565ae857f1c5a7fd339e2d781e /dev-db/drizzle/files/drizzle.init.d.2 | |
| download | gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.gz gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.bz2 gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.zip | |
proj/gentoo: Initial commit
This commit represents a new era for Gentoo:
Storing the gentoo-x86 tree in Git, as converted from CVS.
This commit is the start of the NEW history.
Any historical data is intended to be grafted onto this point.
Creation process:
1. Take final CVS checkout snapshot
2. Remove ALL ChangeLog* files
3. Transform all Manifests to thin
4. Remove empty Manifests
5. Convert all stale $Header$/$Id$ CVS keywords to non-expanded Git $Id$
5.1. Do not touch files with -kb/-ko keyword flags.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
X-Thanks: Alec Warner <antarus@gentoo.org> - did the GSoC 2006 migration tests
X-Thanks: Robin H. Johnson <robbat2@gentoo.org> - infra guy, herding this project
X-Thanks: Nguyen Thai Ngoc Duy <pclouds@gentoo.org> - Former Gentoo developer, wrote Git features for the migration
X-Thanks: Brian Harring <ferringb@gentoo.org> - wrote much python to improve cvs2svn
X-Thanks: Rich Freeman <rich0@gentoo.org> - validation scripts
X-Thanks: Patrick Lauer <patrick@gentoo.org> - Gentoo dev, running new 2014 work in migration
X-Thanks: Michał Górny <mgorny@gentoo.org> - scripts, QA, nagging
X-Thanks: All of other Gentoo developers - many ideas and lots of paint on the bikeshed
Diffstat (limited to 'dev-db/drizzle/files/drizzle.init.d.2')
| -rw-r--r-- | dev-db/drizzle/files/drizzle.init.d.2 | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/dev-db/drizzle/files/drizzle.init.d.2 b/dev-db/drizzle/files/drizzle.init.d.2 new file mode 100644 index 000000000000..4b44ec0d51e9 --- /dev/null +++ b/dev-db/drizzle/files/drizzle.init.d.2 @@ -0,0 +1,127 @@ +#!/sbin/runscript +# Copyright 1999-2012 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 +# $Id$ + +######################### +### Construct vars ###### +######################### + + +SUFFIX=".${SVCNAME#*.}" +[ "${SUFFIX}" == ".drizzled" ] && SUFFIX='' + +DIR_PID="/run/drizzle" +DIR_LOG="/var/log/drizzle" + +BASE_CNF="/etc/drizzle/drizzled" +BASE_PID="${DIR_PID}/drizzled" +BASE_LOG="${DIR_LOG}/drizzled" +BASE_DIR="/var/lib/drizzle/drizzled" + +CNFFILE="${BASE_CNF}${SUFFIX}.cnf" +LOGFILE="${BASE_LOG}${SUFFIX}.log" +DATADIR="${BASE_DIR}${SUFFIX}" +DRIZZLE="/usr/bin/drizzle" +DRIZZLE_USER="drizzle" + +pidfile="${BASE_PID}${SUFFIX}.pid" +command="/usr/sbin/drizzled" +command_args="--daemon --datadir=${DATADIR} --pid-file=${pidfile} --user=${DRIZZLE_USER} --syslog.errmsg-enable ${DRIZZLE_EXTRA}" + +start_stop_daemon_args="--user ${DRIZZLE_USER} --wait 5000" + +######################### +### Helper functions #### +######################### + + +# +# 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() { + # TODO: --print-defaults no longer a valid option. Needs to be rewritten. + #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 "${CNFFILE}" ]; then + eerror "The configuration file $CNFFILE was not found!" + fi +} + +depend() { + use localmount + use logger + use gearmand + use 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. +} + +start_pre() { + checkpath -d -o ${DRIZZLE_USER}:nogroup ${DIR_PID} ${DIR_LOG} + checkpath -f -o ${DRIZZLE_USER}:nogroup ${LOGFILE} +} + +start_post() { + 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 +} + +stop_post() { + drizzle_status check_dead warn +} + +status() { + if drizzle_status check_alive nowarn; then + mark_service_started drizzled + einfo "status: started" + else + mark_service_stopped drizzled + einfo "status: stopped" + fi +} |
