Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init Script RHEL update #4

Open
volga629 opened this issue Dec 18, 2013 · 1 comment
Open

Init Script RHEL update #4

volga629 opened this issue Dec 18, 2013 · 1 comment
Assignees
Milestone

Comments

@volga629
Copy link

Hello Everyone,
I updated init script for RHEL based systems. As far I understand daemon garbd is not supports -HUP, this options will be nice to have to purpose like log rotate. Please review the change.

Configuration file /etc/sysconfig/garb

#Copyright (C) 2012 Coedership Oy
# This config file is to be sourced by garb service script.

# A space-separated list of node addresses (address[:port]) in the cluster
GALERA_NODES=""

# Galera cluster name, should be the same as on the rest of the nodes. Example: "-g groupname"
GALERA_GROUP="-g mygroupname"

# Galera node name. Example: "-n mynode"
GALERA_NODE_NAME="-n my-node"

# Optional Galera internal options string (e.g. SSL settings)
# see http://www.codership.com/wiki/doku.php?id=galera_parameters. Example: -o "myoption; myoption2=1"
GALERA_OPTIONS="-o evs.suspect_timeout=PT30S; socket.ssl=yes; socket.ssl_compression=yes; socket.ssl_ca=; socket.ssl_cert=; socket.ssl_key="
# Log file for garbd. Optional, by default logs to syslog. Example: -l "path to my log"
LOG_FILE="-l /var/log/galera/galera.log"

Init script

#!/bin/bash
#
# Copyright (C) 2012-2013 Codership Oy <[email protected]>
#
# init.d script for garbd
#
# chkconfig: - 99 01
# config: /etc/sysconfig/garb | /etc/default/garb
#
#### BEGIN INIT INFO
# Provides:          garbd
# Required-Start:    $network
# Should-Start:
# Required-Stop:     $network
# Should-Stop:
# Default-Start:     3 4 5
# Default-Stop:      0 1 2 6
# Short-Description: Galera Arbitrator Daemon
# Description:       Galera Arbitrator Daemon
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Config file
. /etc/sysconfig/garb

# Check that networking is enabled.
[ ${NETWORKING} = "no" ] && exit 1

RETVAL=0
pidfile="/var/run/garbd.pid"
garbd=${GARBD-/usr/bin/garbd}
prog="garbd"

start_prog() {
        # Check that node addresses are configured
    if [ -z "${GALERA_NODES}" ]; then
        echo "List of GALERA_NODES is not configured"
        exit 1
    fi
    if [ -z "${GALERA_GROUP}" ]; then
        echo "GALERA_GROUP name is not configured"
        exit 1
    fi

    GALERA_PORT=${GALERA_PORT:-4567}

    # Find a working node
    for ADDRESS in ${GALERA_NODES} 0; do
        HOST=$(echo $ADDRESS | cut -d \: -f 1 )
        PORT=$(echo $ADDRESS | cut -d \: -f 2 )
        PORT=${PORT:-$GALERA_PORT}
        nc -z $HOST $PORT >/dev/null && break
    done
    if [ ${ADDRESS} == "0" ]; then
        echo "None of the nodes in $GALERA_NODES is accessible"
        exit 1
    fi

    OPTIONS="-d -a gcomm://${ADDRESS}"
        GALERA_OPTION="\"$GALERA_OPTIONS\""
    [ -n "${GALERA_GROUP#'-g'*}" ]
    [ -n "${GALERA_NODE_NAME#'-n'*}" ]
    [ -n "${LOG_FILE#'-l'*}" ]

        echo -n $"Starting $prog: "
        daemon --pidfile=${pidfile} ${garbd} $OPTIONS ${GALERA_GROUP} ${GALERA_NODE_NAME} ${GALERA_OPTION} ${LOG_FILE}
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog && echo "`pidof $prog`" > ${pidfile}
        echo "Galera Arbitrator running PID: "`cat ${pidfile}`

}

stop_prog() {
        echo -n $"Shutting down $prog: "
        killproc $prog
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
}

# This is in question.
reload_prog() {
        echo -n $"Reloading $prog: "
        killproc -p ${pidfile} $prog -HUP
        RETVAL=$?
        echo
}


# See how we were called.
case "$1" in
  start)
    start_prog
    ;;
  stop)
    stop_prog
    ;;
  status)
    status $prog > /dev/null
        RETVAL=$?
        [ $RETVAL -eq 0 ] && echo "Galera Arbitrator running PID: "`cat ${pidfile}`
    ;;
  restart)
        stop_prog
        start_prog
    ;;
  reload)
        stop_prog
        start_prog
       ;;
  condrestart)
    if status $prog > /dev/null; then
        stop_prog
        start_prog
    fi
    ;;
  *)
    echo $"Usage: $0 {start|stop|status|restart|reload}"
    exit 2
esac

exit $RETVAL
@ayurchen
Copy link
Member

Depends on issue #6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant