Instantly share code, notes, and snippets.

Embed
What would you like to do?
Directory Server Pacemaker Resource. Use this to start and stop directory server for HA environments. Very basic stuff. Use at your own risk.
#!/bin/sh
#
# Resource script for dirsrv_start
#
# Author: Aaditya M Nair
#
# Description: Really, this just starts all dirsrv instances.
#
#
# Note: This script takes heavy influence from Alan Robertson's MailTo
# License: GNU General Public License (GPL)
# Copyright: (C) 2005 International Business Machines
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
#######################################################################
ARGS="$0 $*"
#us=`uname -n`
usage() {
echo "Usage: $0 {start|stop|status|monitor}"
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="dirsrv_start">
<version>1.0</version>
<longdesc lang="en">
This is a resource agent for dirsrv_start. It starts all ldap instances.
</longdesc>
<shortdesc lang="en">Start all dirsrv instances.</shortdesc>
<actions>
<action name="start" timeout="10" />
<action name="stop" timeout="10" />
<action name="status" depth="0" timeout="10" interval="10" />
<action name="monitor" depth="0" timeout="10" interval="10" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
case $1 in
meta-data) meta_data
exit $OCF_SUCCESS
;;
start) systemctl start dirsrv.target
;;
status|monitor) systemctl is-active dirsrv.target
exit $?
;;
stop) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED
;;
esac
exit $?
#!/bin/sh
#
# Resource script for dirsrv_stop
#
# Author: Aaditya M Nair
#
# Description: Really, this just stops all dirsrv instances.
#
#
# Note: This script takes heavy influence from Alan Robertson's MailTo
# License: GNU General Public License (GPL)
# Copyright: (C) 2005 International Business Machines
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
#######################################################################
ARGS="$0 $*"
#us=`uname -n`
usage() {
echo "Usage: $0 {start|stop|status|monitor}"
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="dirsrv_stop">
<version>1.0</version>
<longdesc lang="en">
This is a resource agent for dirsrv_stop. It stops all ldap instances.
</longdesc>
<shortdesc lang="en">Start all dirsrv instances.</shortdesc>
<actions>
<action name="start" timeout="10" />
<action name="stop" timeout="10" />
<action name="status" depth="0" timeout="10" interval="10" />
<action name="monitor" depth="0" timeout="10" interval="10" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
case $1 in
meta-data) meta_data
exit $OCF_SUCCESS
;;
start) systemctl stop dirsrv.target
;;
status|monitor) exit 0
;;
stop) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED
;;
esac
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment