Last active
August 29, 2015 14:08
-
-
Save vincepii/2771b79dddd18adb1e51 to your computer and use it in GitHub Desktop.
Corosync SMF manifest and script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0'?> | |
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'> | |
<service_bundle type='manifest' name='HACluster_Corosync'> | |
<service name='application/hacluster/corosync' type='service' version='1'> | |
<create_default_instance enabled='false'/> | |
<single_instance/> | |
<dependency | |
name='multi-user-server' | |
grouping='optional_all' | |
type='service' | |
restart_on='none'> | |
<service_fmri value='svc:/milestone/multi-user-server' /> | |
</dependency> | |
<dependency name='network' grouping='require_all' restart_on='error' type='service'> | |
<service_fmri value='svc:/milestone/network:default'/> | |
</dependency> | |
<dependency name='filesystem-local' grouping='require_all' restart_on='none' type='service'> | |
<service_fmri value='svc:/system/filesystem/local:default'/> | |
</dependency> | |
<dependency name='autofs' grouping='optional_all' restart_on='error' type='service'> | |
<service_fmri value='svc:/system/filesystem/autofs:default'/> | |
</dependency> | |
<method_context> | |
<method_credential user="root" /> | |
</method_context> | |
<exec_method name='start' type='method' exec='/opt/etc/smf/corosyncd start' timeout_seconds='60'/> | |
<exec_method name='stop' type='method' exec='/opt/etc/smf/corosyncd stop' timeout_seconds='30'/> | |
<property_group name='startd' type='framework'> | |
<propval name='ignore_error' type='astring' value='core,signal'/> | |
</property_group> | |
<stability value='Evolving'/> | |
<template> | |
<common_name> | |
<loctext xml:lang='C'>HACluster Corosync</loctext> | |
</common_name> | |
<documentation> | |
<doc_link name='HACluster' uri='http://www.clusterlabs.org'/> | |
<manpage title='corosync' section='1M' manpath='/opt/ha/share/man/man8' /> | |
</documentation> | |
</template> | |
</service> | |
</service_bundle> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
. /lib/svc/share/smf_include.sh | |
## Tracing with debug version | |
# PCMK_trace_files=1 | |
# PCMK_trace_functions=1 | |
# PCMK_trace_formats=1 | |
# PCMK_trace_tags=1 | |
export PCMK_ipc_type=socket | |
PREFIX=/opt/ | |
CLUSTER_USER=hacluster | |
COROSYNC=corosync | |
PACEMAKERD=pacemakerd | |
PACEMAKER_PROCESSES=pacemaker | |
APPPATH=${PREFIX}/sbin/ | |
SLEEPINTERVALL=10 | |
SLEEPCOUNT=5 | |
SLEPT=0 | |
killapp() { | |
pid=`pgrep -f $1` | |
if [ "x$pid" != "x" ]; then | |
kill -9 $pid | |
fi | |
return 0 | |
} | |
start() { | |
stop | |
su ${CLUSTER_USER} -c ${APPPATH}${COROSYNC} | |
sleep $sleep0 | |
su ${CLUSTER_USER} -c ${APPPATH}${PACEMAKERD} & | |
return 0 | |
} | |
stop() { | |
# first try, graceful shutdown | |
pid=`pgrep -U ${CLUSTER_USER} -f ${PACEMAKERD}` | |
if [ "x$pid" != "x" ]; then | |
${APPPATH}${PACEMAKERD} --shutdown & | |
sleep $SLEEPINTERVALL | |
fi | |
# second try, kill the rest | |
killapp ${APPPATH}${COROSYNC} | |
sleep 1 | |
killapp ${PACEMAKER_PROCESSES} | |
return 0 | |
} | |
let sleep0=$SLEEPINTERVALL/2 | |
case "$1" in | |
'start') | |
start | |
;; | |
'restart') | |
stop | |
start | |
;; | |
'stop') | |
stop | |
;; | |
*) | |
echo "Usage: -bash { start | stop | restart}" | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment