#!/bin/sh # # Resource script for Zimbra # # Description: Manages Zimbra as an OCF resource in # an high-availability setup. # # Author: Adrian Gibanel # : Original Author # License: GNU General Public License (GPL) # Note: Aimed at an active/passive cluster originally # Inspired from postfix OCF script # Inspired from Ubuntu LSB script. # Not sure it will work # for other distros without modifying # # # usage: $0 {start|stop|reload|status # |monitor|validate-all|meta-data} # # The "start" arg starts Zimbra # # The "stop" arg stops it. # # OCF parameters: # OCF_RESKEY_binary # OCF_RESKEY_config_dir # OCF_RESKEY_parameters # ###################### # Initialization: : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs : ${OCF_RESKEY_binary="zmcontrol"} : ${OCF_RESKEY_zimbra_dir="/opt/zimbra"} : ${OCF_RESKEY_zimbra_user="zimbra"} : ${OCF_RESKEY_zimbra_group="zimbra"} USAGE="Usage: $0 {start|stop|reload\ |status|monitor|validate-all|meta-data}"; ############################### usage() { echo $USAGE >&2 } meta_data() { cat < 0.1 This script manages Zimbra as an OCF resource in a high-availability setup. Manages a highly available Zimbra mail server instance Short name to the Zimbra control script. For example, "zmcontrol". Short name to the Zimbra control script Full path to Zimbra directory. For example, "/opt/zimbra". Full path to Zimbra directory Zimbra username. For example, "zimbra". Zimbra username Zimbra group. For example, "zimbra". Zimbra group END } command() { if [ -f ${zimbra_dir}/redolog/redo.log ]; then chown -f ${zimbra_user}:${zimbra_group} \ ${zimbra_dir}/redolog/redo.log fi su - ${zimbra_user} -c "${binary} $1 > /tmp/prox_conf_$OCF_RESOURCE_INSTANCE #echo OCF_RESKEY_binary=$OCF_RESKEY_zimbra_dir \ #>> /tmp/prox_conf_$OCF_RESKEY_zimbra_dir #echo OCF_RESKEY_binary=$OCF_RESKEY_zimbra_user \ #>> /tmp/prox_conf_$OCF_RESKEY_zimbra_user #echo OCF_RESKEY_binary=$OCF_RESKEY_zimbra_group \ #>> /tmp/prox_conf_$OCF_RESKEY_zimbra_group #echo OCF_RESKEY_binary=$OCF_RESKEY_parameters \ #>> /tmp/prox_conf_$OCF_RESKEY_parameters # build Zimbra options string # *outside* to access from each method OPTIONS='' OPTION_CONFIG_DIR='' # check if the Zimbra config_dir exist if [ "x$config_dir" != "x" ]; then # check for postconf binary #check_binary "${zimbra_dir}/bin/${binary}" # remove all trailing slashes zimbra_dir=`echo $zimbra_dir | sed 's/\/*$//'` fi case $1 in meta-data) meta_data exit $OCF_SUCCESS ;; usage|help) usage exit $OCF_SUCCESS ;; esac zimbra_validate_all ret=$? #echo "debug[$1:$ret]" LSB_STATUS_STOPPED=3 if [ $ret -ne $OCF_SUCCESS ]; then case $1 in stop) exit $OCF_SUCCESS ;; monitor) exit $OCF_NOT_RUNNING;; status) exit $LSB_STATUS_STOPPED;; *) exit $ret;; esac fi case $1 in monitor) zimbra_monitor exit $? ;; start) zimbra_start exit $? ;; stop) zimbra_stop exit $? ;; reload) zimbra_reload exit $? ;; status) if zimbra_status; then ocf_log info "Zimbra is running." exit $OCF_SUCCESS else ocf_log info "Zimbra is stopped." exit $OCF_NOT_RUNNING fi ;; validate-all) exit $OCF_SUCCESS ;; *) usage exit $OCF_ERR_UNIMPLEMENTED ;; esac