Page MenuHomeClusterLabs Projects

No OneTemporary

diff --git a/heartbeat/ZFS b/heartbeat/ZFS
index 560c1b5c2..e9404d489 100755
--- a/heartbeat/ZFS
+++ b/heartbeat/ZFS
@@ -1,212 +1,213 @@
#!/bin/sh
#
# License: GNU General Public License (GPL)
# Support: zfs@lists.illumos.org
# Written by: Saso Kiselkov
#
# This script manages ZFS pools
# It can import a ZFS pool or export it
#
# usage: $0 {start|stop|status|monitor|validate-all|meta-data}
#
# The "start" arg imports a ZFS pool.
# The "stop" arg exports it.
#
# OCF parameters are as follows
# OCF_RESKEY_pool - the pool to import/export
#
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
# Defaults
OCF_RESKEY_pool_default=""
OCF_RESKEY_importargs_default=""
OCF_RESKEY_importforce_default=true
: ${OCF_RESKEY_pool=${OCF_RESKEY_pool_default}}
: ${OCF_RESKEY_importargs=${OCF_RESKEY_importargs_default}}
: ${OCF_RESKEY_importforce=${OCF_RESKEY_importforce_default}}
USAGE="usage: $0 {start|stop|status|monitor|validate-all|meta-data}";
#######################################################################
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="ZFS" version="1.0">
<version>1.0</version>
<longdesc lang="en">
This script manages ZFS pools
It can import a ZFS pool or export it
</longdesc>
<shortdesc lang="en">Manages ZFS pools</shortdesc>
<parameters>
<parameter name="pool" unique="1" required="1">
<longdesc lang="en">
The name of the ZFS pool to manage, e.g. "tank".
</longdesc>
<shortdesc lang="en">ZFS pool name</shortdesc>
<content type="string" default="${OCF_RESKEY_pool_default}" />
</parameter>
<parameter name="importargs" unique="0" required="0">
<longdesc lang="en">
Arguments to zpool import, e.g. "-d /dev/disk/by-id".
</longdesc>
<shortdesc lang="en">Import arguments</shortdesc>
<content type="string" default="${OCF_RESKEY_importargs_default}" />
</parameter>
<parameter name="importforce" unique="0" required="0">
<longdesc lang="en">
zpool import is given the -f option.
</longdesc>
<shortdesc lang="en">Import is forced</shortdesc>
<content type="boolean" default="${OCF_RESKEY_importforce_default}" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="60s" />
<action name="stop" timeout="60s" />
<action name="monitor" depth="0" timeout="30s" interval="5s" />
<action name="validate-all" timeout="30s" />
<action name="meta-data" timeout="5s" />
</actions>
</resource-agent>
END
exit $OCF_SUCCESS
}
zpool_is_imported () {
# Check if ZFS kstats exists
if [ -d /proc/spl/kstat/zfs/ ] ; then
# Check the existence of kstats for the pool. If the stats exists, the pool was imported.
[ -d /proc/spl/kstat/zfs/"${OCF_RESKEY_pool}" ]
- rc=$?
+ rc=$?
else
# If ZFS kstats do not exists, fallback to the standard check
- rc=$(zpool list -H "$OCF_RESKEY_pool" > /dev/null)
+ zpool list -H "$OCF_RESKEY_pool" > /dev/null
+ rc=$?
fi
return $rc
}
# Forcibly imports a ZFS pool, mounting all of its auto-mounted filesystems
# (as configured in the 'mountpoint' and 'canmount' properties)
# If the pool is already imported, no operation is taken.
zpool_import () {
if ! zpool_is_imported; then
ocf_log debug "${OCF_RESKEY_pool}:starting import"
# The meanings of the options to import are as follows:
# -f : import even if the pool is marked as imported to another
# system - the system may have failed and not exported it
# cleanly.
# -o cachefile=none : the import should be temporary, so do not
# cache it persistently (across machine reboots). We want
# the CRM to explicitly control imports of this pool.
if ocf_is_true "${OCF_RESKEY_importforce}"; then
FORCE=-f
else
FORCE=""
fi
if zpool import $FORCE $OCF_RESKEY_importargs -o cachefile=none "$OCF_RESKEY_pool" ; then
ocf_log debug "${OCF_RESKEY_pool}:import successful"
return $OCF_SUCCESS
else
ocf_log debug "${OCF_RESKEY_pool}:import failed"
return $OCF_ERR_GENERIC
fi
fi
}
# Forcibly exports a ZFS pool, unmounting all of its filesystems in the process
# If the pool is not imported, no operation is taken.
zpool_export () {
if zpool_is_imported; then
ocf_log debug "${OCF_RESKEY_pool}:starting export"
# -f : force the export, even if we have mounted filesystems
# Please note that this may fail with a "busy" error if there are
# other kernel subsystems accessing the pool (e.g. SCSI targets).
# Always make sure the pool export is last in your failover logic.
if zpool export -f "$OCF_RESKEY_pool" ; then
ocf_log debug "${OCF_RESKEY_pool}:export successful"
return $OCF_SUCCESS
else
ocf_log debug "${OCF_RESKEY_pool}:export failed"
return $OCF_ERR_GENERIC
fi
fi
}
# Monitors the health of a ZFS pool resource. Please note that this only
# checks whether the pool is imported and functional, not whether it has
# any degraded devices (use monitoring systems such as Zabbix for that).
zpool_monitor () {
# If the pool is not imported, then we can't monitor its health
if ! zpool_is_imported; then
return $OCF_NOT_RUNNING
fi
# Check the pool status
# Since version 0.7.10 status can be obtained without locks
# https://github.com/zfsonlinux/zfs/pull/7563
if [ -f /proc/spl/kstat/zfs/$OCF_RESKEY_pool/state ] ; then
HEALTH=$(cat /proc/spl/kstat/zfs/$OCF_RESKEY_pool/state)
else
HEALTH=$(zpool list -H -o health "$OCF_RESKEY_pool")
fi
case "$HEALTH" in
ONLINE|DEGRADED) return $OCF_SUCCESS;;
FAULTED) return $OCF_NOT_RUNNING;;
*) return $OCF_ERR_GENERIC;;
esac
}
# Validates whether we can import a given ZFS pool
zpool_validate () {
# Check that the 'zpool' command is known
if ! which zpool > /dev/null; then
return $OCF_ERR_INSTALLED
fi
# If the pool is imported, then it is obviously valid
if zpool_is_imported; then
return $OCF_SUCCESS
fi
# Check that the pool can be imported
if zpool import $OCF_RESKEY_importargs | grep 'pool:' | grep "\\<$OCF_RESKEY_pool\\>" > /dev/null;
then
return $OCF_SUCCESS
else
return $OCF_ERR_CONFIGURED
fi
}
usage () {
echo "$USAGE" >&2
return $1
}
if [ $# -ne 1 ]; then
usage $OCF_ERR_ARGS
fi
case $1 in
meta-data) meta_data;;
start) zpool_import;;
stop) zpool_export;;
status|monitor) zpool_monitor;;
validate-all) zpool_validate;;
usage) usage $OCF_SUCCESS;;
*) usage $OCF_ERR_UNIMPLEMENTED;;
esac
exit $?
diff --git a/heartbeat/iface-bridge b/heartbeat/iface-bridge
index a4e50adb9..3ac79f1b1 100755
--- a/heartbeat/iface-bridge
+++ b/heartbeat/iface-bridge
@@ -1,843 +1,843 @@
#!/bin/sh
#
# OCF Resource Agent compliant iface-bridge script.
#
# Implements network Bridge interface management
#
# Copyright (C) 2013 Red Hat, Inc. All rights reserved.
# Author: Fabio M. Di Nitto <fdinitto@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Further, this software is distributed without any warranty that it is
# free of the rightful claim of any third person regarding infringement
# or the like. Any license provided herein, whether implied or
# otherwise, applies only to this software file. Patent licenses, if
# any, provided herein do not apply to combinations of this program with
# other software, or any other product whatsoever.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
#
#
# TODO:
# * Eventually improve bridge_check to verify all runtime
# parameters. Is it really necessary?
# * consider add support for advanced multicast timers tuning
# sethashel <bridge> <int> set hash elasticity default 4
# sethashmax <bridge> <int> set hash max default 512
# setmclmc <bridge> <int> set multicast last member count default 2, ?
# setmcsqc <bridge> <int> set multicast startup query count default 2, ?
# setmclmi <bridge> <time> set multicast last member interval default HZ
# setmcmi <bridge> <time> set multicast membership interval default 260 * HZ
# setmcqpi <bridge> <time> set multicast querier interval default 255 * HZ
# setmcqi <bridge> <time> set multicast query interval detault 125 * HZ
# setmcqri <bridge> <time> set multicast query response interval default 10 * HZ
# setmcqri <bridge> <time> set multicast startup query interval default 125 * hZ / 4
#
#
# OCF parameters are as below
# OCF_RESKEY_bridge_name
# OCF_RESKEY_bridge_slaves
# OCF_RESKEY_bridge_ageing
# OCF_RESKEY_port_hairpin
# OCF_RESKEY_stp
# OCF_RESKEY_stp_bridgeprio
# OCF_RESKEY_stp_fd
# OCF_RESKEY_stp_maxage
# OCF_RESKEY_stp_hello
# OCF_RESKEY_stp_pathcost
# OCF_RESKEY_stp_portprio
# OCF_RESKEY_multicast_router
# OCF_RESKEY_multicast_snooping
# OCF_RESKEY_multicast_querier
# OCF_RESKEY_multicast_port_router
#
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
# Defaults
OCF_RESKEY_stp_default=false
OCF_RESKEY_stp_fd_default=0
OCF_RESKEY_multicast_router_default=1
OCF_RESKEY_multicast_snooping_default=1
OCF_RESKEY_multicast_querier_default=0
: ${OCF_RESKEY_stp=${OCF_RESKEY_stp_default}}
: ${OCF_RESKEY_stp_fd=${OCF_RESKEY_stp_fd_default}}
: ${OCF_RESKEY_multicast_router=${OCF_RESKEY_multicast_router_default}}
: ${OCF_RESKEY_multicast_snooping=${OCF_RESKEY_multicast_snooping_default}}
: ${OCF_RESKEY_multicast_querier=${OCF_RESKEY_multicast_querier_default}}
# binaries
: ${BRCTL:=brctl}
#######################################################################
bridge_usage() {
cat <<END
usage: $0 {start|stop|status|monitor|validate-all|meta-data}
Expects to have a fully populated OCF RA-compliant environment set.
END
}
bridge_meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="iface-bridge" version="1.0">
<version>1.0</version>
<longdesc lang="en">
This resource manages Bridge network interfaces.
It can add, remove, configure bridges and spanning-tree.
</longdesc>
<shortdesc lang="en">
Manages Bridge network interfaces.
</shortdesc>
<parameters>
<parameter name="bridge_name" unique="1" required="1">
<longdesc lang="en">
Define the name of the bridge (max 15 charaters).
</longdesc>
<shortdesc lang="en">
Name of the bridge
</shortdesc>
<content type="string"/>
</parameter>
<parameter name="bridge_slaves" unique="1">
<longdesc lang="en">
Define the list of interfaces, space separated, to add to the bridge.
The list can be empty.
</longdesc>
<shortdesc lang="en">
Network interface
</shortdesc>
<content type="string"/>
</parameter>
<parameter name="bridge_ageing" unique="0">
<longdesc lang="en">
Set the ethernet (MAC) address ageing time in seconds.
</longdesc>
<shortdesc lang="en">
MAC ageing in seconds.
</shortdesc>
<content type="integer"/>
</parameter>
<parameter name="port_hairpin" unique="0">
<longdesc lang="en">
Set hairpin forwarding mode.
A list of ports that should have hairpin enabled
can be specified using the following
Example: eth0 eth1
</longdesc>
<shortdesc lang="en">
Set hairpin forwarding mode.
</shortdesc>
<content type="string"/>
</parameter>
<parameter name="stp" unique="0">
<longdesc lang="en">
Enable or disable Spanning Tree Protocol on the bridge.
</longdesc>
<shortdesc lang="en">
Spanning Tree Protocol
</shortdesc>
<content type="boolean" default="${OCF_RESKEY_stp_default}"/>
</parameter>
<parameter name="stp_bridgeprio" unique="0">
<longdesc lang="en">
Set the bridge's priority to defined value. The priority value is a
number between 0 and 65535), and has no dimension. Lower priority values are
preferred. The bridge with the lowest priority will be elected as root bridge.
</longdesc>
<shortdesc lang="en">
Set the bridge's priority.
</shortdesc>
<content type="integer"/>
</parameter>
<parameter name="stp_fd" unique="0">
<longdesc lang="en">
Set the bridge forward delay (in seconds).
</longdesc>
<shortdesc lang="en">
Set the bridge forward delay.
</shortdesc>
<content type="integer" default="${OCF_RESKEY_stp_fd_default}"/>
</parameter>
<parameter name="stp_maxage" unique="0">
<longdesc lang="en">
Set the bridge maximum message age (in seconds).
</longdesc>
<shortdesc lang="en">
Set the bridge maximum message age.
</shortdesc>
<content type="integer"/>
</parameter>
<parameter name="stp_hello" unique="0">
<longdesc lang="en">
Set the bridge hello time (in seconds).
</longdesc>
<shortdesc lang="en">
Set the bridge hello time.
</shortdesc>
<content type="integer"/>
</parameter>
<parameter name="stp_pathcost" unique="0">
<longdesc lang="en">
Set the port cost. This is a dimensionless metric.
A list of port/cost can be specified using the following
format: unpromoted cost unpromoted cost.
Example: eth0 100 eth1 1000
</longdesc>
<shortdesc lang="en">
Set the port cost.
</shortdesc>
<content type="string"/>
</parameter>
<parameter name="stp_portprio" unique="0">
<longdesc lang="en">
Set the port priority. This is a number between 0 and 63.
$BRCTL man page reports a value between 0 and 255, but
tests show a limit of 63 on a live system.
This metric is used in the designated port and root port
selection algorithms.
A list of port/priority can be specified using the following
format: unpromoted cost unpromoted cost.
Example: eth0 10 eth1 60
</longdesc>
<shortdesc lang="en">
Set the port priority.
</shortdesc>
<content type="string"/>
</parameter>
<parameter name="multicast_router" unique="0">
<longdesc lang="en">
Enable or disable multicast routing on the bridge.
</longdesc>
<shortdesc lang="en">
Enable or disable multicast routing.
</shortdesc>
<content type="boolean" default="${OCF_RESKEY_multicast_router_default}"/>
</parameter>
<parameter name="multicast_snooping" unique="0">
<longdesc lang="en">
Enable or disable multicast snooping on the bridge.
</longdesc>
<shortdesc lang="en">
Enable or disable multicast snooping.
</shortdesc>
<content type="boolean" default="${OCF_RESKEY_multicast_snooping_default}"/>
</parameter>
<parameter name="multicast_port_router" unique="0">
<longdesc lang="en">
Enable or disable a port from the multicast router.
Kernel enables all port by default.
A list of port can be specified using the following
format: unpromoted 0|1 unpromoted 0|1.
Example: eth0 1 eth1 0
</longdesc>
<shortdesc lang="en">
Enable or disable a port from the multicast router.
</shortdesc>
<content type="string"/>
</parameter>
</parameters>
<actions>
<action name="start" timeout="30s" />
<action name="stop" timeout="20s" />
<action name="status" timeout="20s" depth="0" interval="10s" />
<action name="monitor" timeout="20s" depth="0" interval="10s" />
<action name="meta-data" timeout="5s" />
<action name="validate-all" timeout="20s" />
</actions>
</resource-agent>
END
}
# commodity function
# split_string eth0 100 eth1 1000 eth2 100
# eth0 100
# eth1 1000
# eth2 100
split_string() {
while [ -n "$1" ]; do
echo $1 $2
shift && shift
done
}
# check if the interface is admin up/down
iface_is_up() {
if ! $IP2UTIL -o link show $1 | \
sed -e 's#.*<##g' -e 's#>.*##' -e 's#LOWER_UP##g' | \
grep -q UP; then
return 1
fi
return 0
}
# check if the slaves have link layer up/down
# see kernel network documentation on meaning of LOWER_UP flag
# for more in depth explanation on how it works
# NOTE: this check is not reliable in virt environment
# since interfaces are always LOWER_UP. There is no way
# from the guest to know if the host has disconnected somehow
iface_lower_is_up() {
if ! $IP2UTIL -o link show $1 | \
grep -q LOWER_UP; then
return 1
fi
return 0
}
# wrapup function to check if any interface defined in
# option lists is a slave
iface_is_slave() {
for slave in $OCF_RESKEY_bridge_slaves; do
if [ "$1" = "$slave" ]; then
return 0
fi
done
return 1
}
bridge_validate() {
check_binary $BRCTL
check_binary $IP2UTIL
if [ -z "$OCF_RESKEY_bridge_name" ]; then
ocf_log err "Invalid OCF_RESKEY_bridge_name: value cannot be empty"
return 1
fi
# the echo .. is the equivalent of strlen in bash
#
# /usr/include/linux/if.h:#define IFNAMSIZ 16
# needs to include 0 byte end string
if [ "${#OCF_RESKEY_bridge_name}" -gt 15 ]; then
ocf_log err "Invalid OCF_RESKEY_bridge_name: name is too long"
return 1
fi
if [ ! -d "/sys/class/net" ]; then
ocf_log err "Unable to find sysfs network class in /sys"
return 1
fi
for slave in $OCF_RESKEY_bridge_slaves; do
if [ ! -e "/sys/class/net/$slave" ]; then
ocf_log err "Invalid OCF_RESKEY_bridge_slaves: $slave does not exists"
return 1
fi
done
# check if declared harpin ports are slaves
for hairpin in $OCF_RESKEY_port_hairpin; do
if ! iface_is_slave $hairpin; then
ocf_log err "Invalid OCF_RESKEY_port_hairpin: $hairpin is not listed in OCF_RESKEY_bridge_slaves"
return 1
fi
done
if [ -n "$OCF_RESKEY_bridge_ageing" ]; then
if ! ocf_is_decimal "$OCF_RESKEY_bridge_ageing"; then
ocf_log err "Invalid OCF_RESKEY_bridge_ageing: must be a decimal value (0 or greater)"
return 1
fi
fi
# OCF_RESKEY_stp_fd needs special handling as it can be 0 or greater
# but only when configured before OCF_RESKEY_stp.
# if enabled after OCF_RESKEY_stp with stp=true the value range is
# different. It is not clear from the man page or brctl documentation
# what the range is ahead of time.
if [ -n "$OCF_RESKEY_stp_fd" ]; then
if ! ocf_is_decimal "$OCF_RESKEY_stp_fd" || \
[ "$OCF_RESKEY_stp_fd" -lt 0 ]; then
ocf_log err "Invalid OCF_RESKEY_stp_fd: must be a decimal value (0 or greater)"
return 1
fi
fi
if ocf_is_true "$OCF_RESKEY_stp"; then
if [ -n "$OCF_RESKEY_stp_bridgeprio" ]; then
if ! ocf_is_decimal "$OCF_RESKEY_stp_bridgeprio" || \
[ "$OCF_RESKEY_stp_bridgeprio" -gt 65535 ]; then
ocf_log err "Invalid OCF_RESKEY_stp_bridgeprio: must be a decimal value between 0 and 65535 included"
return 1
fi
fi
if [ -n "$OCF_RESKEY_stp_hello" ]; then
if ! ocf_is_decimal "$OCF_RESKEY_stp_hello"; then
ocf_log err "Invalid OCF_RESKEY_stp_hello: must be a decimal value (0 or greater)"
return 1
fi
fi
if [ -n "$OCF_RESKEY_stp_maxage" ]; then
if ! ocf_is_decimal "$OCF_RESKEY_stp_maxage"; then
ocf_log err "Invalid OCF_RESKEY_stp_maxage: must be a decimal value (0 or greater)"
return 1
fi
fi
if [ -n "$OCF_RESKEY_stp_pathcost" ]; then
split_string $OCF_RESKEY_stp_pathcost | { while read iface cost; do
if ! iface_is_slave $iface; then
ocf_log err "Invalid OCF_RESKEY_stp_pathcost: $iface is not listed in OCF_RESKEY_bridge_slaves"
return 1
fi
if ! ocf_is_decimal $cost; then
ocf_log err "Invalid OCF_RESKEY_stp_pathcost: cost must be a decimal value (0 or great)"
return 1
fi
done
}
fi
if [ -n "$OCF_RESKEY_stp_portprio" ]; then
split_string $OCF_RESKEY_stp_portprio | { while read iface prio; do
if ! iface_is_slave $iface; then
ocf_log err "Invalid OCF_RESKEY_stp_portprio: $iface is not listed in OCF_RESKEY_bridge_slaves"
return 1
fi
if ! ocf_is_decimal $prio || \
[ "$prio" -gt "63" ]; then
ocf_log err "Invalid OCF_RESKEY_stp_portprio: priority must be a decimal value between 0 and 63 included"
return 1
fi
done
}
fi
fi
if [ -n "$OCF_RESKEY_multicast_port_router" ]; then
split_string $OCF_RESKEY_multicast_port_router | { while read iface mcport; do
if ! iface_is_slave $iface; then
ocf_log err "Invalid OCF_RESKEY_multicast_port_router: $iface is not listed in OCF_RESKEY_bridge_slaves"
return 1
fi
if ! ocf_is_decimal $mcport || \
[ "$mcport" -gt "1" ]; then
ocf_log err "Invalid OCF_RESKEY_multicast_port_router: valuer must be 0 (disabled) or 1 (enabled)"
return 1
fi
done
}
fi
return 0
}
bridge_check() {
if [ -e "/sys/class/net/$OCF_RESKEY_bridge_name" ]; then
if [ ! -e "$HA_RSCTMP/iface-bridge.$OCF_RESKEY_bridge_name" ]; then
return $OCF_ERR_GENERIC
fi
else
if [ -e "$HA_RSCTMP/iface-bridge.$OCF_RESKEY_bridge_name" ]; then
error="$(rm -f "$HA_RSCTMP/iface-bridge.$OCF_RESKEY_bridge_name" 2>&1)"
if [ "$?" != "0" ]; then
ocf_log err "Unable to remove stale lock file for bridge $OCF_RESKEY_bridge_name: $error"
return $OCF_ERR_GENERIC
fi
fi
return $OCF_NOT_RUNNING
fi
# we check if all slaves are still part of the bridge
for slave in $OCF_RESKEY_bridge_slaves; do
if [ ! -e "/sys/class/net/$OCF_RESKEY_bridge_name/brif/$slave" ]; then
ocf_log err "Interface $slave is not part of the bridge $OCF_RESKEY_bridge_name"
return $OCF_ERR_GENERIC
fi
if ! iface_is_up $slave; then
ocf_log err "Interface $slave of the bridge $OCF_RESKEY_bridge_name is administratively down"
return $OCF_ERR_GENERIC
fi
done
# check if bridge is still "UP"
# is there a cleaner way?
if ! iface_is_up $OCF_RESKEY_bridge_name; then
ocf_log err "Bridge $OCF_RESKEY_bridge_name is administratively down"
return $OCF_ERR_GENERIC
fi
if ! iface_lower_is_up $OCF_RESKEY_bridge_name; then
ocf_log err "Bridge $OCF_RESKEY_bridge_name has no active link-layer slaves"
return $OCF_ERR_GENERIC
fi
return $OCF_SUCCESS
}
# we need a simpler stop version to clean after us if start fails
# without involving any error checking
# rolling back in case of failure is otherwise complex
bridge_force_stop() {
$IP2UTIL link set dev "$OCF_RESKEY_bridge_name" down 2>&1
for slave in $OCF_RESKEY_bridge_slaves; do
$IP2UTIL link set dev "$slave" down 2>&1
done
$BRCTL delbr "$OCF_RESKEY_bridge_name" 2>&1
rm -f "$HA_RSCTMP/iface-bridge.$OCF_RESKEY_bridge_name" 2>&1
}
bridge_start() {
# check if the bridge already exists
bridge_check
ret=$?
if [ "$ret" != "$OCF_NOT_RUNNING" ]; then
return $ret
fi
# create the bridge
error="$($BRCTL addbr "$OCF_RESKEY_bridge_name" 2>&1)"
if [ "$?" != "0" ]; then
ocf_log err "Unable to create bridge $OCF_RESKEY_bridge_name: $error"
return $OCF_ERR_GENERIC
fi
# add slaves if configured
for slave in $OCF_RESKEY_bridge_slaves; do
error="$($BRCTL addif "$OCF_RESKEY_bridge_name" "$slave" 2>&1)"
if [ "$?" != "0" ]; then
ocf_log err "Unable to add interface $slave to bridge $OCF_RESKEY_bridge_name: $error"
return $OCF_ERR_GENERIC
fi
done
# set haripin forward mode
for hairpin in $OCF_RESKEY_port_hairpin; do
error="$($BRCTL hairpin "$OCF_RESKEY_bridge_name" "$hairpin" on 2>&1)"
if [ "$?" != "0" ]; then
ocf_log err "Unable to set hairpin on for interface $hairpin to bridge $OCF_RESKEY_bridge_name: $error"
return $OCF_ERR_GENERIC
fi
done
# set bridge ageing
if [ -n "$OCF_RESKEY_bridge_ageing" ]; then
error="$($BRCTL setageing "$OCF_RESKEY_bridge_name" "$OCF_RESKEY_bridge_ageing" 2>&1)"
if [ "$?" != "0" ]; then
ocf_log err "Unable to set bridge $OCF_RESKEY_bridge_name ageing to $OCF_RESKEY_bridge_ageing: $error"
return $OCF_ERR_GENERIC
fi
fi
# OCF_RESKEY_stp_fd needs special handling as it can be 0 or greater
# but only when configured before OCF_RESKEY_stp.
# if enabled after OCF_RESKEY_stp with stp=true the value range is
# different. It is not clear from the man page or brctl documentation
# what the range is ahead of time.
if [ -n "$OCF_RESKEY_stp_fd" ]; then
error="$($BRCTL setfd "$OCF_RESKEY_bridge_name" "$OCF_RESKEY_stp_fd" 2>&1)"
if [ "$?" != "0" ]; then
ocf_log err "Unable to set bridge forward delay $OCF_RESKEY_stp_fd on bridge $OCF_RESKEY_bridge_name : $error"
return $OCF_ERR_GENERIC
fi
fi
# enable/disable spanning tree protocol
if ocf_is_true "$OCF_RESKEY_stp"; then
error="$($BRCTL stp "$OCF_RESKEY_bridge_name" on 2>&1)"
if [ "$?" != "0" ]; then
ocf_log err "Unable to enable STP on bridge $OCF_RESKEY_bridge_name : $error"
return $OCF_ERR_GENERIC
fi
# set bridge priority
if [ -n "$OCF_RESKEY_stp_bridgeprio" ]; then
error="$($BRCTL setbridgeprio "$OCF_RESKEY_bridge_name" "$OCF_RESKEY_stp_bridgeprio" 2>&1)"
if [ "$?" != "0" ]; then
ocf_log err "Unable to set bridge priority $OCF_RESKEY_stp_bridgeprio on bridge $OCF_RESKEY_bridge_name : $error"
return $OCF_ERR_GENERIC
fi
fi
# set hello timer
if [ -n "$OCF_RESKEY_stp_hello" ]; then
error="$($BRCTL sethello "$OCF_RESKEY_bridge_name" "$OCF_RESKEY_stp_hello" 2>&1)"
if [ "$?" != "0" ]; then
ocf_log err "Unable to set bridge hello timer $OCF_RESKEY_stp_hello on bridge $OCF_RESKEY_bridge_name : $error"
return $OCF_ERR_GENERIC
fi
fi
# set max age
if [ -n "$OCF_RESKEY_stp_maxage" ]; then
error="$($BRCTL setmaxage "$OCF_RESKEY_bridge_name" "$OCF_RESKEY_stp_maxage" 2>&1)"
if [ "$?" != "0" ]; then
ocf_log err "Unable to set bridge max age $OCF_RESKEY_stp_maxage on bridge $OCF_RESKEY_bridge_name : $error"
return $OCF_ERR_GENERIC
fi
fi
# set path cost per port
if [ -n "$OCF_RESKEY_stp_pathcost" ]; then
split_string $OCF_RESKEY_stp_pathcost | { while read iface cost; do
error="$($BRCTL setpathcost "$OCF_RESKEY_bridge_name" "$iface" "$cost" 2>&1)"
if [ "$?" != "0" ]; then
ocf_log err "Unable to set pathcost $cost for interface $iface on bridge $OCF_RESKEY_bridge_name : $error"
return $OCF_ERR_GENERIC
fi
done
}
fi
# set port priority per port
if [ -n "$OCF_RESKEY_stp_portprio" ]; then
split_string $OCF_RESKEY_stp_portprio | { while read iface prio; do
error="$($BRCTL setportprio "$OCF_RESKEY_bridge_name" "$iface" "$prio" 2>&1)"
if [ "$?" != "0" ]; then
ocf_log err "Unable to set portprio $prio for interface $iface on bridge $OCF_RESKEY_bridge_name : $error"
return $OCF_ERR_GENERIC
fi
done
}
fi
else
# stp off is default via brctl/kernel interface but it
# is best to force it since we don't know if default
# has changed across kernel releases
error="$($BRCTL stp "$OCF_RESKEY_bridge_name" off 2>&1)"
if [ "$?" != "0" ]; then
ocf_log err "Unable to disable STP on bridge $OCF_RESKEY_bridge_name : $error"
return $OCF_ERR_GENERIC
fi
fi
# set slaves up
for slave in $OCF_RESKEY_bridge_slaves; do
error="$($IP2UTIL link set dev "$slave" up 2>&1)"
if [ "$?" != "0" ]; then
ocf_log err "Unable to set slave $slave for bridge $OCF_RESKEY_bridge_name up: $error"
return $OCF_ERR_GENERIC
fi
done
# set the bridge up
error="$($IP2UTIL link set dev "$OCF_RESKEY_bridge_name" up 2>&1)"
if [ "$?" != "0" ]; then
ocf_log err "Unable to set bridge $OCF_RESKEY_bridge_name up: $error"
return $OCF_ERR_GENERIC
fi
# multicast operations can only be executed after the bridge is up
# and configured.
# enable/disable multicast router
if ocf_is_true "$OCF_RESKEY_multicast_router"; then
mcrouter=1
else
mcrouter=0
fi
if [ -e "/sys/class/net/$OCF_RESKEY_bridge_name/bridge/multicast_router" ]; then
- error="$(echo $mcrouter > /sys/class/net/$OCF_RESKEY_bridge_name/bridge/multicast_router 2>&1)"
+ error="$(echo $mcrouter 2>&1 >/sys/class/net/$OCF_RESKEY_bridge_name/bridge/multicast_router)"
if [ "$?" != "0" ]; then
ocf_log err "Unable to set OCF_RESKEY_multicast_router for bridge $OCF_RESKEY_bridge_name: $error"
return $OCF_ERR_GENERIC
fi
else
ocf_log warn "Unable to set multicast router on bridge $OCF_RESKEY_bridge_name because kernel does not support it"
fi
# enable/disable multicast snoopint
if ocf_is_true "$OCF_RESKEY_multicast_snooping"; then
mcsnooping=1
else
mcsnooping=0
fi
if [ -e "/sys/class/net/$OCF_RESKEY_bridge_name/bridge/multicast_snooping" ]; then
- error="$(echo $mcsnooping > /sys/class/net/$OCF_RESKEY_bridge_name/bridge/multicast_snooping 2>&1)"
+ error="$(echo $mcsnooping 2>&1 >/sys/class/net/$OCF_RESKEY_bridge_name/bridge/multicast_snooping)"
if [ "$?" != "0" ]; then
ocf_log err "Unable to set OCF_RESKEY_multicast_snooping for bridge $OCF_RESKEY_bridge_name: $error"
return $OCF_ERR_GENERIC
fi
else
ocf_log warn "Unable to set multicast snooping on bridge $OCF_RESKEY_bridge_name because kernel does not support it"
fi
# enable/disable multicast querier
if ocf_is_true "$OCF_RESKEY_multicast_querier"; then
mcquerier=1
else
mcquerier=0
fi
if [ -e "/sys/class/net/$OCF_RESKEY_bridge_name/bridge/multicast_querier" ]; then
- error="$(echo $mcquerier > /sys/class/net/$OCF_RESKEY_bridge_name/bridge/multicast_querier 2>&1)"
+ error="$(echo $mcquerier 2>&1 >/sys/class/net/$OCF_RESKEY_bridge_name/bridge/multicast_querier)"
if [ "$?" != "0" ]; then
ocf_log err "Unable to set OCF_RESKEY_multicast_querier for bridge $OCF_RESKEY_bridge_name: $error"
return $OCF_ERR_GENERIC
fi
else
ocf_log warn "Unable to set multicast querier on bridge $OCF_RESKEY_bridge_name because kernel does not support it"
fi
# set multicast router per port
if [ -n "$OCF_RESKEY_multicast_port_router" ]; then
split_string $OCF_RESKEY_multicast_port_router | { while read iface mcport; do
if [ -e "/sys/class/net/$iface/brport/multicast_router" ]; then
- error="$(echo $mcport > /sys/class/net/$iface/brport/multicast_router 2>&1)"
+ error="$(echo $mcport 2>&1 >/sys/class/net/$iface/brport/multicast_router)"
if [ "$?" != "0" ]; then
ocf_log err "Unable to set OCF_RESKEY_multicast_port_router $mcport for interface $iface on bridge $OCF_RESKEY_bridge_name : $error"
return $OCF_ERR_GENERIC
fi
else
ocf_log warn "Unable to set multicast port router on bridge $OCF_RESKEY_bridge_name because kernel does not support it"
fi
done
}
fi
error="$(touch "$HA_RSCTMP/iface-bridge.$OCF_RESKEY_bridge_name")"
if [ "$?" != "0" ]; then
ocf_log err "Unable to write lock file for bridge $OCF_RESKEY_bridge_name: $error"
return $OCF_ERR_GENERIC
fi
return $OCF_SUCCESS
}
bridge_stop() {
bridge_check
ret=$?
if [ "$ret" = "$OCF_NOT_RUNNING" ]; then
return $OCF_SUCCESS
fi
if [ "$ret" != "$OCF_SUCCESS" ]; then
return $ret
fi
# set bridge down
error="$($IP2UTIL link set dev "$OCF_RESKEY_bridge_name" down 2>&1)"
if [ "$?" != "0" ]; then
ocf_log err "Unable to set bridge $OCF_RESKEY_bridge_name down: $error"
return $OCF_ERR_GENERIC
fi
# set slaves down
for slave in $OCF_RESKEY_bridge_slaves; do
error="$($IP2UTIL link set dev "$slave" down 2>&1)"
if [ "$?" != "0" ]; then
ocf_log err "Unable to set slave $slave for bridge $OCF_RESKEY_bridge_name down: $error"
return $OCF_ERR_GENERIC
fi
done
# delete bridge
error="$($BRCTL delbr "$OCF_RESKEY_bridge_name" 2>&1)"
if [ "$?" != "0" ]; then
ocf_log err "Unable to delete bridge $OCF_RESKEY_bridge_name: $error"
return $OCF_ERR_GENERIC
fi
error="$(rm -f "$HA_RSCTMP/iface-bridge.$OCF_RESKEY_bridge_name" 2>&1)"
if [ "$?" != "0" ]; then
ocf_log err "Unable to remove lock file for bridge $OCF_RESKEY_bridge_name: $error"
return $OCF_ERR_GENERIC
fi
return $OCF_SUCCESS
}
case $__OCF_ACTION in
meta-data)
bridge_meta_data
exit $OCF_SUCCESS
;;
usage|help)
bridge_usage
exit $OCF_SUCCESS
;;
esac
if [ ! -d "$HA_RSCTMP" ]; then
ocf_log debug "$HA_RSCTMP not found, we are probably being executed manually"
mkdir -p "$HA_RSCTMP"
fi
if [ -n "$__OCF_ACTION" ] && ! bridge_validate; then
exit $OCF_ERR_CONFIGURED
fi
case $__OCF_ACTION in
start|stop)
if ! ocf_is_root; then
ocf_log err "You must be root for $__OCF_ACTION operation."
exit $OCF_ERR_PERM
fi
;;
esac
case $__OCF_ACTION in
start)
bridge_start
ret=$?
if [ "$ret" != "$OCF_SUCCESS" ]; then
bridge_force_stop
fi
exit $ret
;;
stop)
bridge_stop
exit $?
;;
status|monitor)
bridge_check
exit $?
;;
validate-all)
# bridge_validate above does the trick
;;
*)
bridge_usage
exit $OCF_ERR_UNIMPLEMENTED
;;
esac
# vi:sw=4:ts=8:
diff --git a/heartbeat/jira.in b/heartbeat/jira.in
index 66a8e53f0..6094ea18c 100644
--- a/heartbeat/jira.in
+++ b/heartbeat/jira.in
@@ -1,291 +1,291 @@
#!@BASH_SHELL@
#
####################################################################
# Description: OCF Resource Agent to manage JIRA software.
# Author : Saleh A. (saleh.abbas.saber@gmail.com)
#
# License : WTFPL 2
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
# Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
#
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
# as the name is changed.
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
#
# 0. You just DO WHAT THE FUCK YOU WANT TO.
#
####################################################################
# Parameters:
# OCF_RESKEY_statusurl : Status URL to monitor JIRA
# (default: http://localhost:8080/status)
# OCF_RESKEY_java_home : Java Home
# (default: /usr/lib/jvm/jre)
# OCF_RESKEY_jira_installation : Jira installtion directory
# OCF_RESKEY_jira_user : User running Jira software
# (by default: jira)
####################################################################
# Initialization
# Source ocf-shellfuncs
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
# Parameter defaults
OCF_RESKEY_statusurl_default="http://localhost:8080/status"
OCF_RESKEY_java_home_default="/usr/lib/jvm/jre"
OCF_RESKEY_jira_user_default="jira"
: ${OCF_RESKEY_statusurl=${OCF_RESKEY_statusurl_default}}
: ${OCF_RESKEY_java_home=${OCF_RESKEY_java_home_default}}
: ${OCF_RESKEY_jira_user=${OCF_RESKEY_jira_user_default}}
# Usage
jira_usage() {
cat <<_EOF
Usage: $0 action
Supported Actions:
start : start jira
stop : stop jira
monitor : show jira status
meta-data : show the meta-data
validate-all: validate the RA configuration
_EOF
}
# Start
jira_start() {
# exit immediately if configuration is not valid
jira_validate_all || exit $?
# if resource is already running, bail out early
if jira_monitor; then
ocf_log info "Resource is already running"
return $OCF_SUCCESS
fi
# Starting Jira
waittime=300
su -m $jira_user -c "$jira_installation/bin/startup.sh &> /dev/null"
while [[ $waittime -gt 0 ]]; do
- if $(curl --connect-timeout 1 --max-time 3 -s ${statusurl} | grep '{"state":"RUNNING"}' > /dev/null); then
+ if curl --connect-timeout 1 --max-time 3 -s ${statusurl} | grep '{"state":"RUNNING"}' > /dev/null; then
waittime=0
else
sleep 1
waittime=$(($waittime - 1))
fi
done
# Verify jira is running
jira_monitor
rc=$?
return $?
}
# Stop
jira_stop() {
local rc
# exit immediately if configuration is not valid
jira_validate_all || exit $?
jira_monitor
rc=$?
case "$rc" in
"$OCF_SUCCESS")
# Currently running. Normal, expected behavior.
ocf_log debug "Resource is currently running"
;;
"$OCF_NOT_RUNNING")
# Currently not running. Nothing to do.
ocf_log info "Resource is already stopped"
return $OCF_SUCCESS
;;
esac
# Stopping Jira
waittime=300
su -m $jira_user -c "$jira_installation/bin/shutdown.sh &> /dev/null"
while [[ $waittime -gt 0 ]]; do
if $(kill -0 $(cat ${jira_installation}/work/catalina.pid 2> /dev/null) 2> /dev/null) ; then
sleep 1
waittime=$(($waittime - 1))
else
waittime=0
fi
done
# Stop JIRA forcely if it failed
if $(kill -0 $(cat ${jira_installation}/work/catalina.pid 2> /dev/null) 2> /dev/null) ; then
kill -9 $(cat ${jira_installation}/work/catalina.pid)
sleep 1
fi
# Verify jira is stopped
jira_monitor
rc=$?
return $rc
}
# Monitor
jira_monitor() {
local rc
# exit immediately if configuration is not valid
jira_validate_all || exit $?
if $(kill -0 $(cat ${jira_installation}/work/catalina.pid 2> /dev/null) 2> /dev/null) ; then
# Is jira working
- if $(curl --connect-timeout 1 --max-time 3 -s ${statusurl} | grep '{"state":"RUNNING"}' > /dev/null) ; then
+ if curl --connect-timeout 1 --max-time 3 -s ${statusurl} | grep '{"state":"RUNNING"}' > /dev/null; then
rc=0
else
# Jira has a problem
rc=2
fi
else
# Tomcat is stopped (and Jira)
rc=1
fi
case "$rc" in
0)
rc=$OCF_SUCCESS
ocf_log debug "Resource is running"
;;
1)
rc=$OCF_NOT_RUNNING
ocf_log debug "Resource is not running"
;;
*)
ocf_log err "Resource has failed"
exit $OCF_ERR_GENERIC
esac
return $rc
}
# Validat All
jira_validate_all() {
# Check if java is installed
if ! [ -d $OCF_RESKEY_java_home ]; then
ocf_log err "$OCF_RESKEY_java_home does not exist. \
Please ensure that Java is installed and configured correctly"
exit $OCF_ERR_INSTALLED
fi
# Check if JIRA installation directory exists
if ! [ -d $OCF_RESKEY_jira_installation ]; then
ocf_log err "$OCF_RESKEY_jira_installation does not exist."
exit $OCF_ERR_INSTALLED
fi
return $OCF_SUCCESS
}
# Meta-data
jira_meta_data(){
cat <<EOF
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="jira" version="0.1">
<version>1.0</version>
<longdesc lang="en">
OCF Resource Agent to manage JIRA software
</longdesc>
<shortdesc lang="en">JIRA OCF RA</shortdesc>
<parameters>
<parameter name="statusurl" unique="0" required="0">
<longdesc lang="en">
Status URL for JIRA monitoring
</longdesc>
<shortdesc lang="en">JIRA status url</shortdesc>
<content type="string" default="${OCF_RESKEY_statusurl_default}"/>
</parameter>
<parameter name="java_home" unique="0" required="0">
<longdesc lang="en">
Java Home in the Linux instance
</longdesc>
<shortdesc lang="en">Java Home</shortdesc>
<content type="string" default="${OCF_RESKEY_java_home_default}"/>
</parameter>
<parameter name="jira_installation" unique="0" required="1">
<longdesc lang="en">
JIRA installation directory (binaries, ... etc)
</longdesc>
<shortdesc lang="en">JIRA installation directory</shortdesc>
<content type="string"/>
</parameter>
<parameter name="jira_user" unique="0" required="0">
<longdesc lang="en">
User to run Jira software with
</longdesc>
<shortdesc lang="en">Jira user</shortdesc>
<content type="string" default="${OCF_RESKEY_jira_user_default}"/>
</parameter>
</parameters>
<actions>
<action name="start" timeout="300s" />
<action name="stop" timeout="300s" />
<action name="monitor" timeout="30s"
interval="10s" depth="0" />
<action name="meta-data" timeout="5s" />
<action name="validate-all" timeout="20s" />
</actions>
</resource-agent>
EOF
}
# Execution
# Set vars from defined OCF env vars
statusurl=${OCF_RESKEY_statusurl-${OCF_RESKEY_statusurl_default}}
java_home=${OCF_RESKEY_java_home-${OCF_RESKEY_java_home_default}}
jira_installation=${OCF_RESKEY_jira_installation}
jira_user=${OCF_RESKEY_jira_user-${OCF_RESKEY_jira_user_default}}
# Export JAVA_HOME env variable
export JAVA_HOME=${OCF_RESKEY_java_home}
# Make sure meta-data and usage always succeed
case $__OCF_ACTION in
meta-data) jira_meta_data
exit $OCF_SUCCESS
;;
usage|help) jira_usage
exit $OCF_SUCCESS
;;
esac
# Anything other than meta-data and usage must pass validation
jira_validate_all || exit $?
# Translate each action into the appropriate function call
case $__OCF_ACTION in
start) jira_start;;
stop) jira_stop;;
status|monitor) jira_monitor;;
validate-all) ;;
*) jira_usage
exit $OCF_ERR_UNIMPLEMENTED
;;
esac
rc=$?
exit $rc
diff --git a/heartbeat/kamailio.in b/heartbeat/kamailio.in
index 4f6af3dbd..54a97513d 100644
--- a/heartbeat/kamailio.in
+++ b/heartbeat/kamailio.in
@@ -1,741 +1,741 @@
#!@BASH_SHELL@
#
# OCF resource agent for Kamailio for pacemaker
#
# Copyright (c) 2013 FREQUENTIS AG,
# Authors: Stefan Wenk
# Rainer Brestan
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Further, this software is distributed without any warranty that it is
# free of the rightful claim of any third person regarding infringement
# or the like. Any license provided herein, whether implied or
# otherwise, applies only to this software file. Patent licenses, if
# any, provided herein do not apply to combinations of this program with
# other software, or any other product whatsoever.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
#
# OCF input parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_conffile
# OCF_RESKEY_pidfile
# OCF_RESKEY_monitoring_ip
# OCF_RESKEY_listen_address
# OCF_RESKEY_port
# OCF_RESKEY_proto
# OCF_RESKEY_sipsak
# OCF_RESKEY_kamctl
# OCF_RESKEY_kamctlrc
# OCF_RESKEY_kamuser
# OCF_RESKEY_kamgroup
# OCF_RESKEY_extra_options
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
#######################################################################
# Defaults
RESKEY_binary_default="/usr/sbin/kamailio"
RESKEY_conffile_default="/etc/kamailio/kamailio.cfg"
RESKEY_pidfile_default="/var/run/kamailio_${OCF_RESOURCE_INSTANCE}/kamailio.pid"
RESKEY_monitoring_ip_default=127.0.0.1
RESKEY_port_default=5060
RESKEY_proto_default="udptcp"
RESKEY_sipsak_default="/usr/bin/sipsak"
RESKEY_kamctl_default="/usr/bin/kamctl"
RESKEY_kamctlrc_default="/etc/kamailio/kamctlrc"
RESKEY_kamuser_default=""
RESKEY_kamgroup_default=""
RESKEY_extra_options_default=""
#######################################################################
: ${OCF_RESKEY_binary=${RESKEY_binary_default}}
: ${OCF_RESKEY_conffile=${RESKEY_conffile_default}}
: ${OCF_RESKEY_pidfile=${RESKEY_pidfile_default}}
: ${OCF_RESKEY_monitoring_ip=${RESKEY_monitoring_ip_default}}
: ${OCF_RESKEY_port=${RESKEY_port_default}}
: ${OCF_RESKEY_proto=${RESKEY_proto_default}}
: ${OCF_RESKEY_sipsak=${RESKEY_sipsak_default}}
: ${OCF_RESKEY_kamctl=${RESKEY_kamctl_default}}
: ${OCF_RESKEY_kamctlrc=${RESKEY_kamctlrc_default}}
: ${OCF_RESKEY_kamuser=${RESKEY_kamuser_default}}
: ${OCF_RESKEY_kamgroup=${RESKEY_kamgroup_default}}
: ${OCF_RESKEY_extra_options=${RESKEY_extra_options_default}}
#######################################################################
usage() {
cat <<END
usage: $0 {start|stop|status|monitor|validate-all|meta-data}
Expects to have a fully populated OCF RA-compliant environment set.
END
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="kamailio" version="1.0">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the Kamailio SIP proxy/registrar.
Multiple instances are possible when using following parameter combinations:
Parameters for Kamailio instance 1:
listen_address=192.168.159.128
monitoring_ip=192.168.159.128
proto=udptcp
port=5060
Parameters for Kamailio instance 2:
listen_address=192.168.159.128
monitoring_ip=192.168.159.128
proto=udp
port=5070
conffile=/etc/kamailio/kamailio2.cfg
kamctlrc=""
Only one instance can be monitored via the command "kamctl monitor"
because the kamctl tool of kamailio 4.x is not designed for multiple
instances. Therefore, the provided kamctrlrc file path needs to be
empty for instance 2, 3 ...
Parameters for a third Kamailio instance:
listen_address=192.168.159.128
monitoring_ip=192.168.159.128
proto=tcp
port=5080
conffile=/etc/kamailio/kamailio3.cfg
kamctlrc=""
</longdesc>
<shortdesc lang="en">Resource agent for Kamailio</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">The kamailio binary</longdesc>
<shortdesc lang="en">The kamailio binary</shortdesc>
<content type="string" default="${RESKEY_binary_default}" />
</parameter>
<parameter name="conffile" unique="0" required="0">
<longdesc lang="en">
The kamailio configuration file name with full path.
For example, "/etc/kamailio/kamailio.cfg" , which is the default value.
Make sure to use unique names in case of having multiple instances.
</longdesc>
<shortdesc lang="en">Configuration file name with full path</shortdesc>
<content type="string" default="${RESKEY_conffile_default}" />
</parameter>
<parameter name="pidfile" unique="0" required="0">
<longdesc lang="en">
The kamailio PID file. The directory used must be writable by kamailio
process user. Be sure to use unique name for running more than one
instance. Try to use absolute path names.
If empty, resource agent create a unique directory from the resource
instance name for the PID file and assign it to the process user.
</longdesc>
<shortdesc lang="en">PID file</shortdesc>
<content type="string" default="${RESKEY_pidfile_default}" />
</parameter>
<parameter name="monitoring_ip" unique="0" required="0">
<longdesc lang="en">
SIP IP Address of the kamailio instance used for SIP OPTIONS polling monitoring.
Usually the same IP address value as for parameter listen_address should be
provided.
In order to respond with a 200 OK response to the SIP OOPTION requests,
the kamailio.cfg file needs to contain following section:
Note: The following "kamailio.cfg" code snippet is part of an XML section.
Therefore it contains two &amp; characters, which need to be replaced
with two ampersand characters within "kamailio.cfg":
if (is_method("OPTIONS") &amp;&amp; ($ru=~"sip:monitor@.*")) {
##
## If the method is an OPTIONS we are simply going to respond
## with a 200 OK.
# xlog("L_INFO", "Method is an OPTIONS, probably just monitoring\n");
sl_send_reply("200", "Kamailio is alive");
exit;
}
</longdesc>
<shortdesc lang="en">Monitoring IP address used for SIP OPTIONS polling.</shortdesc>
<content type="string" default="${RESKEY_monitoring_ip_default}" />
</parameter>
<parameter name="listen_address" unique="0" required="1">
<longdesc lang="en">
SIP IP address the kamailio will listen on.
</longdesc>
<shortdesc lang="en">Listening SIP address</shortdesc>
<content type="string" />
</parameter>
<parameter name="port" unique="0" required="0">
<longdesc lang="en">
SIP port for the kamailio instance.
</longdesc>
<shortdesc lang="en">SIP Port</shortdesc>
<content type="string" default="${RESKEY_port_default}" />
</parameter>
<parameter name="extra_options" unique="0" required="0">
<longdesc lang="en">
Extra options to add to kamailio start.
</longdesc>
<shortdesc lang="en">extra_options</shortdesc>
<content type="string" default="${RESKEY_extra_options}" />
</parameter>
<parameter name="proto" unique="0" required="0">
<longdesc lang="en">
The protocol used for SIP proto = udp|tcp|udptcp|conf_udp|conf_tcp|conf_udptcp.
Using the options "conf_*" does not add any "-l" parameters to the kamailio command,
the "listen" parameters from kamailio.conf are used instead. The sipsak checks are
performed depending what protocol is defined after the underscore.
</longdesc>
<shortdesc lang="en">protocol</shortdesc>
<content type="string" default="${RESKEY_proto_default}" />
</parameter>
<parameter name="sipsak" unique="0" required="0">
<longdesc lang="en">
The installation path of the sipsak tool, which is used
for monitoring Kamailio via SIP OPTIONS polling.
</longdesc>
<shortdesc lang="en">sipsak path</shortdesc>
<content type="string" default="${RESKEY_sipsak_default}" />
</parameter>
<parameter name="kamctl" unique="0" required="0">
<longdesc lang="en">
The installation path of the "kamctl" control tool.
</longdesc>
<shortdesc lang="en">kamctl path</shortdesc>
<content type="string" default="${RESKEY_kamctl_default}" />
</parameter>
<parameter name="kamctlrc" unique="0" required="0">
<longdesc lang="en">
The location of the "kamctlrc" file for the Kamailio instance.
The file "kamctlrc" is the Kamailio configuration file for its "kamctl" control tool.
This parameter only needs to be provided in case of using multiple Kamailio server
instances on a single cluster node:
In case that the parameter "kamctlrc" is not empty, this resource agent monitors
the health state of the Kamailio server via the command "kamctl monitor 1". This
setting is recommended in case of using a single Kamailio server instance.
In case that the parameter "kamctlrc" is empty, the resource agent does not
monitor the health state of the Kamailio server instance via the "kamctl" command.
Please note that the "kamctl" control command of Kamailio 4.x does not support
running multiple Kamailio instances on one host. Nevertheless this resource agent
does allow multiple Kamailio instances per host. The result of the "kamctl"
limitation in terms of number of Kamailio server instances is that the health
check via "kamctl monitor 1" can be configured for a single Kamailio instance
only.
Please refer to the long description of this resource agent for an example
of parameter combinations in case that multiple instances are to be
configured per cluster node.
</longdesc>
<shortdesc lang="en">kamctlrc path</shortdesc>
<content type="string" default="${RESKEY_kamctlrc_default}" />
</parameter>
<parameter name="kamuser" unique="0" required="0">
<longdesc lang="en">
The user account for kamailio process to run with.
Uses the current user, if not specified or empty.
There is no check, if running kamailio with the specified user account is possible.
</longdesc>
<shortdesc lang="en">kamailio user</shortdesc>
<content type="string" default="${RESKEY_kamuser_default}" />
</parameter>
<parameter name="kamgroup" unique="0" required="0">
<longdesc lang="en">
The group for kamailio process to run with.
Uses the current group, if not specified or empty.
</longdesc>
<shortdesc lang="en">kamailio group</shortdesc>
<content type="string" default="${RESKEY_kamgroup_default}" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="60s" />
<action name="stop" timeout="30s" />
<action name="status" timeout="30s" interval="10s" />
<action name="monitor" timeout="30s" interval="10s" />
<action name="meta-data" timeout="5s" />
<action name="validate-all" timeout="5s" />
<action name="notify" timeout="5s" />
</actions>
</resource-agent>
END
exit $OCF_SUCCESS
}
#######################################################################
###
#Check if a process with given PID is running
# Parameter 1: PID
###
isRunning_PID()
{
kill -s 0 "$1" > /dev/null 2>&1
}
###
#Check if an instance with given command line is running
# Parameter 1: command line.
###
isRunning_cmd()
{
pkill --signal 0 -f -x "$1" > /dev/null 2>&1
}
###
# Formats the result of a command.
#
# Parameter 1: Exit status.
# Parameter 2: Standard output (stdout).
# Parameter 3: Error output (stderr).
# Returns: Formatted result.
kamailio_format_result() {
local exitstatus="$1"
local value="$2"
local error="$3"
echo -n "exit status: ${exitstatus}"
if [ -n "$value" ]; then
echo -n ", value: ${value}"
fi
if [ -n "$error" ]; then
echo -n ", error: ${error}"
fi
echo
}
###
# Put the command line, how the kamailio process is started according
# to the configured parameters, into the variable "kam_cmd".
###
kamailio_cmd()
{
case ${OCF_RESKEY_proto} in
udp) listen_param="-T -l udp:${OCF_RESKEY_listen_address}:${OCF_RESKEY_port} -l udp:127.0.0.1:${OCF_RESKEY_port}"
;;
tcp) listen_param="-l tcp:${OCF_RESKEY_listen_address}:${OCF_RESKEY_port} -l tcp:127.0.0.1:${OCF_RESKEY_port}"
;;
udptcp) listen_param1="-l udp:${OCF_RESKEY_listen_address}:${OCF_RESKEY_port} -l udp:127.0.0.1:${OCF_RESKEY_port}"
listen_param2="-l tcp:${OCF_RESKEY_listen_address}:${OCF_RESKEY_port} -l tcp:127.0.0.1:${OCF_RESKEY_port}"
listen_param="${listen_param1} ${listen_param2}"
;;
conf_*)
# doing nothing, no listen_param set
;;
*) listen_param="-T"
;;
esac
kam_cmd="${OCF_RESKEY_binary} -P ${OCF_RESKEY_pidfile} -f ${OCF_RESKEY_conffile}"
if [ -n "${listen_param}" ]; then
kam_cmd="${kam_cmd} ${listen_param}"
fi
if [ -n "${OCF_RESKEY_kamuser}" ]; then
kam_cmd="${kam_cmd} -u ${OCF_RESKEY_kamuser}"
fi
if [ -n "${OCF_RESKEY_kamgroup}" ]; then
kam_cmd="${kam_cmd} -g ${OCF_RESKEY_kamgroup}"
fi
if [ -n "${OCF_RESKEY_extra_options}" ]; then
kam_cmd="${kam_cmd} ${OCF_RESKEY_extra_options}"
fi
}
###
# Gets the PID for the running Kamailio instance.
#
# Returns: The variable $PID contains the found PID value or an empty string.
# Exit Status: Zero if the PID file was found and this process run under
# the command line parameters of our instance.
# 1) if the PID file is not present and no process running under
# our command line options is active.
# 2) in all other fatal cases, which we classify in the followig
# as OCF_ERR_genering. These are folloing cases:
# a) The PID file contains a PID value which does no match to
# to our instance
# b) The PID contains a empty string in its first line
# c) The PID file contains some text and some processeses
# from our instance are still active
kamailio_get_pid() {
if [ -f ${OCF_RESKEY_pidfile} ]; then
PID=`head -n 1 $OCF_RESKEY_pidfile`
if [ ! -z "$PID" ]; then
#Cross check if the PID file really contains a process of our kamailio instance:
kamailio_cmd
CROSSPID=`pgrep -o -f "${kam_cmd}"`
if [ x"$PID" == x"$CROSSPID" ]; then
#ocf_log debug "Found kamailio process PID with value: $PID."
return 0
fi
#ocf_log debug "PID file does not contain a PID of a $OCF_RESKEY_binary process!"
return 2
fi
#PID file does not contain a valid PID
rm -f ${OCF_RESKEY_pidfile}
return 2
fi
# No PID file found!
# Check if still a process exists even though we don't have the PID any longer:
kamailio_cmd
pgrep -f "${kam_cmd}"
if [ $? -eq 0 ]; then
ocf_log info "PID file does not contain a valid PID, but kamailio process is still active"
return 2
fi
ocf_log info "No PID file found and our kamailio instance is not active"
return 1
}
kamailio_status() {
local not_running_log_level="warn"
local errorfile error output
if [ "$__OCF_ACTION" = "start" ]; then
not_running_log_level="debug"
fi
kamailio_get_pid >/dev/null
RET=$?
if [ $RET -ne 0 ]; then
if [ $RET -eq 2 ]; then
ocf_log $not_running_log_level "PID file does not contain a PID of a ${OCF_RESKEY_binary} process!"
return $OCF_ERR_GENERIC
fi
return $OCF_NOT_RUNNING
fi
PID=`head -n 1 $OCF_RESKEY_pidfile`
isRunning_PID "$PID"
RET=$?
if [ "$RET" -ne 0 ]; then
ocf_log $not_running_log_level "PID from $PID from ${OCF_RESKEY_pidfile} not running"
rm -f ${OCF_RESKEY_pidfile}
return $OCF_NOT_RUNNING
fi
rc=0
# In case that OCF_RESKEY_kamctlrc we perfom a health check via "kamctl monitor 1"
if [ ! -z ${OCF_RESKEY_kamctlrc} ]; then
# PID is running now but it is not save to check via kamctl without care, because
# the implementation analysis in the case that we kill all running processes
# shows that in case that the fifo cannot be read, then kamctl blocks. This needs
# to be avoided.
# In order to be on the safe side, we run this check therefore under "timeout" control:
rc=1
timeout 3 ${OCF_RESKEY_kamctl} monitor 1 |grep "since" ; rc=$?
fi
if [ $rc -ne 0 ]; then
ocf_log $not_running_log_level "Kamailio is not up according to kamctl monitor!"
return $OCF_NOT_RUNNING
fi
errorfile=`mktemp`
case ${OCF_RESKEY_proto} in
- udp) output=`$OCF_RESKEY_sipsak -s sip:monitor@$OCF_RESKEY_monitoring_ip:${OCF_RESKEY_port} -H localhost --transport udp>/dev/null 2>>$errorfile`
+ udp) output=`$OCF_RESKEY_sipsak -s sip:monitor@$OCF_RESKEY_monitoring_ip:${OCF_RESKEY_port} -H localhost --transport udp 2>>$errorfile`
result=$?
;;
- tcp) output=`$OCF_RESKEY_sipsak -s sip:monitor@$OCF_RESKEY_monitoring_ip:${OCF_RESKEY_port} -H localhost --transport tcp>/dev/null 2>>$errorfile`
+ tcp) output=`$OCF_RESKEY_sipsak -s sip:monitor@$OCF_RESKEY_monitoring_ip:${OCF_RESKEY_port} -H localhost --transport tcp 2>>$errorfile`
result=$?
;;
- udptcp) output=`$OCF_RESKEY_sipsak -s sip:monitor@$OCF_RESKEY_monitoring_ip:${OCF_RESKEY_port} -H localhost --transport tcp>/dev/null 2>>$errorfile`
+ udptcp) output=`$OCF_RESKEY_sipsak -s sip:monitor@$OCF_RESKEY_monitoring_ip:${OCF_RESKEY_port} -H localhost --transport tcp 2>>$errorfile`
result=$?
if [ $result -eq 0 ]; then
- output=`$OCF_RESKEY_sipsak -s sip:monitor@$OCF_RESKEY_monitoring_ip:${OCF_RESKEY_port} -H localhost --transport udp>/dev/null 2>>$errorfile`
+ output=`$OCF_RESKEY_sipsak -s sip:monitor@$OCF_RESKEY_monitoring_ip:${OCF_RESKEY_port} -H localhost --transport udp 2>>$errorfile`
result=$?
fi
;;
- *) output=`$OCF_RESKEY_sipsak -s sip:monitor@$OCF_RESKEY_monitoring_ip:${OCF_RESKEY_port} -H localhost --transport udp>/dev/null 2>>$errorfile`
+ *) output=`$OCF_RESKEY_sipsak -s sip:monitor@$OCF_RESKEY_monitoring_ip:${OCF_RESKEY_port} -H localhost --transport udp 2>>$errorfile`
result=$?
;;
esac
error=`cat $errorfile`
rm -f $errorfile
if [ $result -ne 0 ]; then
ocf_log $not_running_log_level "Kamailio is running, but not functional as sipsak ${OCF_RESKEY_proto} failed with $(kamailio_format_result $result "$output" "$error")"
return $OCF_ERR_GENERIC
fi
return $OCF_SUCCESS
}
kamailio_monitor() {
kamailio_status
}
kamailio_start() {
local errorfile error output piddir
if
kamailio_status
then
ocf_log info "kamailio already running."
return $OCF_SUCCESS
fi
# if pidfile directory does not exist, create it with kamailio process owner
piddir=`dirname "${OCF_RESKEY_pidfile}"`
if [ ! -d "$piddir" ]; then
mkdir -p "$piddir"
if [ "$OCF_RESKEY_kamuser" != "" ]; then
chown ${OCF_RESKEY_kamuser} "$piddir"
fi
fi
kamailio_cmd
if [ "$OCF_RESKEY_kamuser" != "" ]; then
kam_cmd="su -s @BASH_SHELL@ $OCF_RESKEY_kamuser -c \"$kam_cmd\""
fi
ocf_log info "start kamailio with $kam_cmd."
errorfile=`mktemp`
output=$(eval ${kam_cmd} 2>>$errorfile)
result=$?
error=`cat $errorfile`
rm -f $errorfile
if [ $result -eq 0 ]; then
result=1
while [ $result -ne 0 ]; do
sleep 1
kamailio_get_pid >/dev/null
result=$?
done
ocf_log info "kamailio instance PID=$PID started."
# check with monitor operation if running correctly
result=$OCF_ERR_GENERIC
while [ $result -ne $OCF_SUCCESS ]; do
sleep 1
kamailio_monitor
result=$?
ocf_log info "monitor in start returned $result"
done
ocf_log info "kamailio started successful."
else
ocf_log err "kamailio instance could not be started, $(kamailio_format_result $result "$output" "$error")"
result=$OCF_ERR_GENERIC
fi
return $result
}
kamailio_stop() {
local piddir
local TRIES=0
result=$OCF_SUCCESS
kamailio_cmd
ocf_log info "Stopping kamailio by sending SIGTERM to ${kam_cmd}"
pkill -SIGTERM -x -f "${kam_cmd}"
if [ $? -eq 1 ]; then
# already stopped. no processes found
# in case of not specified pidfile, delete the created directory
# otherwise only the pidfile itself
if [ "${OCF_RESKEY_pidfile}" == "${RESKEY_pidfile_default}" ]; then
piddir=`dirname "${OCF_RESKEY_pidfile}"`
rm -rf "$piddir"
else
rm -f "${OCF_RESKEY_pidfile}"
fi
return $result
fi
if [ "$OCF_RESKEY_CRM_meta_timeout" != "" ]; then
KAMAILIO_STOP_TIMEOUT=$(( ($OCF_RESKEY_CRM_meta_timeout/1000) - 7 ))
else
KAMAILIO_STOP_TIMEOUT=20
fi
while isRunning_cmd "${kam_cmd}" && [ "$TRIES" -lt "${KAMAILIO_STOP_TIMEOUT}" ]
do
sleep 1
ocf_log info "kamailio ${kam_cmd} is still running after SIGTERM"
((TRIES++))
done
isRunning_cmd "${kam_cmd}"
RET=$?
if [ "$RET" -eq 0 ]; then
ocf_log info "Killing ${kam_cmd} with SIGKILL"
TRIES=0
pkill -SIGKILL -x -f "${kam_cmd}" > /dev/null 2>&1
while isRunning_cmd "${kam_cmd}" && [ "$TRIES" -lt 3 ]
do
sleep 1
ocf_log info "kamailio ${kam_cmd} is still running after SIGKILL"
((TRIES++))
done
isRunning_cmd "${kam_cmd}"
RET=$?
if [ "$RET" -eq 0 ]; then
ocf_log fatal "kamailio is still running even after SIGKILL"
result=$OCF_ERR_GENERIC
fi
else
ocf_log info "${kam_cmd} has stopped."
fi
# in case of not specified pidfile, delete the created directory
# otherwise only the pidfile itself
if [ "${OCF_RESKEY_pidfile}" == "${RESKEY_pidfile_default}" ]; then
piddir=`dirname "${OCF_RESKEY_pidfile}"`
rm -rf "$piddir"
else
rm -f "${OCF_RESKEY_pidfile}"
fi
return $result
}
kamailio_validate_all() {
# Check if kamailio configuration is valid before starting the server
if [ ! -f $OCF_RESKEY_binary ]; then
ocf_log err "File OCF_RESKEY_binary [${OCF_RESKEY_binary}] does not exist!"
return $OCF_NOT_INSTALLED
fi
out=$($OCF_RESKEY_binary -c 2>&1 > /dev/null)
retcode=$?
if [ "$retcode" -ne '0' ]; then
ocf_log info "Not starting kamailio: $OCF_RESKEY_binary does not start!"
return $OCF_ERR_CONFIGURED
fi
case $OCF_RESKEY_monitoring_ip in
"") ocf_log err "Required parameter OCF_RESKEY_monitoring_ip is missing!"
return $OCF_ERR_CONFIGURED
;;
[0-9]*.[0-9]*.[0-9]*.[0-9]*) : OK
;;
*) ocf_log err "Parameter OCF_RESKEY_monitoring_ip [$OCF_RESKEY_monitoring_ip] is not an IP address!"
return $OCF_ERR_CONFIGURED
;;
esac
case $OCF_RESKEY_listen_address in
"") ocf_log err "Required parameter $OCF_RESKEY_listen_address is missing!"
return $OCF_ERR_CONFIGURED
;;
[0-9]*.[0-9]*.[0-9]*.[0-9]*) : OK
;;
*) ocf_log err "Parameter OCF_RESKEY_listen_address [$OCF_RESKEY_listen_address] not an IP address!"
return $OCF_ERR_CONFIGURED
;;
esac
if [ ! -f ${OCF_RESKEY_sipsak} ]; then
ocf_log err "sipsak [${OCF_RESKEY_sipsak}] does not exist!"
return $OCF_NOT_INSTALLED
fi
if [ ! -z ${OCF_RESKEY_kamctlrc} ]; then
if [ ! -f ${OCF_RESKEY_kamctlrc} ]; then
ocf_log err "kamctlrc file [${kamctlrc}] does not exist!"
return $OCF_NOT_INSTALLED
fi
else
ocf_log debug "No monitoring via kamctl monitor because the parameter [kamctlrc] is empty."
fi
if [ ! -f ${OCF_RESKEY_conffile} ]; then
ocf_log err "Kamailio configuration file provided in the parameter conffile [${OCF_RESKEY_conffile}] does not exist!"
return $OCF_ERR_CONFIGURED
fi
case $OCF_RESKEY_proto in
"") ocf_log err "Parameter $OCF_RESKEY_proto is empty!"
return $OCF_ERR_CONFIGURED
;;
udp|tcp|udptcp) : OK
;;
*) ocf_log err "Parameter value $OCF_RESKEY_proto for parameter [proto] not yet supported!"
return $OCF_ERR_CONFIGURED
;;
esac
return $OCF_SUCCESS
}
if [ $# -ne 1 ]; then
usage
exit $OCF_ERR_ARGS
fi
case $__OCF_ACTION in
meta-data) meta_data
exit $OCF_SUCCESS
;;
start|stop|status|monitor)
kamailio_${__OCF_ACTION}
;;
validate-all) kamailio_validate_all
;;
notify) exit $OCF_SUCCESS
;;
usage) usage
exit $OCF_SUCCESS
;;
# reload) #Not supported by Kamailio, but not needed by pacemaker
# ;;
# recover #Not needed by pacemaker
# ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED
;;
esac
exit $?
diff --git a/heartbeat/minio b/heartbeat/minio
index 16ceeed42..8f3b85f1e 100755
--- a/heartbeat/minio
+++ b/heartbeat/minio
@@ -1,289 +1,289 @@
#!/bin/sh
#
# Resource script for Minio
#
# Description: Manages Minio as an OCF resource in
# an Active-Passive High Availability setup.
#
# Author: Ricardo Branco <tsmgeek@gmail.com> : Initial script for minio server
# License: GNU General Public License (GPL)
#
#
# usage: $0 {start|stop|status|monitor|validate-all|meta-data}
#
# The "start" arg starts Minio.
#
# The "stop" arg stops it.
#
# OCF parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_conffile
# OCF_RESKEY_pidfile
# OCF_RESKEY_address
# OCF_RESKEY_volumnpaths
#
##########################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
# Defaults
OCF_RESKEY_binary_default="/opt/minio/minio-server"
OCF_RESKEY_confdir_default="/etc/minio"
OCF_RESKEY_pidfile_default="/var/run/minio.pid"
OCF_RESKEY_address_default=":9000"
OCF_RESKEY_volumepaths_default="/home/shared"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_confdir=${OCF_RESKEY_confdir_default}}
: ${OCF_RESKEY_pidfile=${OCF_RESKEY_pidfile_default}}
: ${OCF_RESKEY_address=${OCF_RESKEY_address_default}}
: ${OCF_RESKEY_volumepaths=${OCF_RESKEY_volumepaths_default}}
USAGE="Usage: $0 {start|stop|status|monitor|validate-all|meta-data}";
##########################################################################
usage() {
echo $USAGE >&2
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="minio" version="1.0">
<version>1.0</version>
<longdesc lang="en">
This script manages Minio in an Active-Passive setup
</longdesc>
<shortdesc lang="en">OCF Resource Agent compliant Minio server script.</shortdesc>
<parameters>
<parameter name="binary">
<longdesc lang="en">The Minio server binary</longdesc>
<shortdesc lang="en">The Minio server binary</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="confdir">
<longdesc lang="en">
The Minio configuration directory path.
For example, "/etc/minio"
</longdesc>
<shortdesc lang="en">Configuration directory path</shortdesc>
<content type="string" default="${OCF_RESKEY_confdir_default}" />
</parameter>
<parameter name="pidfile">
<longdesc lang="en">The Minio PID file. The location of the PID file.</longdesc>
<shortdesc lang="en">PID file</shortdesc>
<content type="string" default="${OCF_RESKEY_pidfile_default}" />
</parameter>
<parameter name="address">
<longdesc lang="en">Address to bind minio to.</longdesc>
<shortdesc lang="en">Bind address</shortdesc>
<content type="string" default="${OCF_RESKEY_address_default}" />
</parameter>
<parameter name="volumepaths">
<longdesc lang="en">The storage volumes for minio to use.</longdesc>
<shortdesc lang="en">Storage Volumes</shortdesc>
<content type="string" default="${OCF_RESKEY_volumepaths_default}" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20s" />
<action name="stop" timeout="20s" />
<action name="monitor" depth="0" timeout="20s" interval="60s" />
<action name="validate-all" timeout="2s" />
<action name="meta-data" timeout="5s" />
</actions>
</resource-agent>
END
exit $OCF_SUCCESS
}
isRunning()
{
kill -0 "$1" > /dev/null 2>&1
}
minio_status()
{
if [ -f "$OCF_RESKEY_pidfile" ]
then
# Minio is probably running
PID=`head -n 1 $OCF_RESKEY_pidfile`
if [ ! -z "$PID" ] ; then
- isRunning "$PID" && `ps -p $PID | grep minio-server > /dev/null 2>&1`
+ isRunning "$PID" && ps -p $PID | grep minio-server > /dev/null 2>&1
return $?
fi
fi
# Minio is not running
return $OCF_NOT_RUNNING;
}
minio_start()
{
# make a few checks and start Minio
if ocf_is_root ; then : ; else
ocf_log err "You must be root"
exit $OCF_ERR_PERM
fi
# if Minio is running return success
if minio_status ; then
ocf_log info "Minio server is running already"
exit $OCF_SUCCESS
fi
# starting Minio
cmd="su - root -c \"nohup ${OCF_RESKEY_binary} server --quiet --config-dir ${OCF_RESKEY_confdir} --address ${OCF_RESKEY_address} ${OCF_RESKEY_volumepaths} >/dev/null &\"'echo \$!' "
ocf_log debug "Starting minio: $cmd"
eval $cmd > ${OCF_RESKEY_pidfile}
if [ "$?" -ne 0 ]; then
ocf_log err "Minio returned error" $?
exit $OCF_ERR_GENERIC
fi
exit $OCF_SUCCESS
}
minio_stop()
{
if minio_status ; then
PID=`head -n 1 $OCF_RESKEY_pidfile`
if [ ! -z "$PID" ]; then
ocf_log info "Killing Minio PID $PID"
kill $PID > /dev/null 2>&1
if [ "$?" -eq 0 ]; then
TRIES=0
while isRunning "$PID" && [ "$TRIES" -lt 30 ]
do
sleep 1
ocf_log info "Minio PID $PID is still running"
TRIES=`expr $TRIES + 1`
done
isRunning "$PID"
RET=$?
if [ "$RET" -eq 0 ]; then
ocf_log info "Killing Minio PID $PID with SIGKILL"
kill -9 $PID > /dev/null 2>&1
while isRunning "$PID"
do
sleep 1
ocf_log info "Minio PID $PID is still running"
done
fi
else
ocf_log err "Killing Minio PID $PID FAILED"
exit $OCF_ERR_GENERIC
fi
fi
fi
exit $OCF_SUCCESS
}
minio_monitor()
{
minio_status
RET=$?
if [ "$RET" -eq 0 ]; then
PID=`head -n 1 $OCF_RESKEY_pidfile`
ocf_log debug "Minio monitor on PID $PID succeeded"
return $OCF_SUCCESS
else
ocf_log debug "Minio monitor on PID $PID failed"
return $OCF_NOT_RUNNING
fi
}
minio_validate_all()
{
# check that the minio binary exists
if [ ! -x "$OCF_RESKEY_binary" ]; then
ocf_log err "Minio server binary $OCF_RESKEY_binary does not exist"
exit $OCF_ERR_INSTALLED
fi
# check that the Minioconfig file exists
if [ ! -d "$OCF_RESKEY_confdir" ]; then
ocf_log err "Minio config dir $OCF_RESKEY_confdir does not exist"
exit $OCF_ERR_CONFIGURED
fi
}
#
# Main
#
if [ $# -ne 1 ]
then
usage
exit $OCF_ERR_ARGS
fi
case $1 in
start)
minio_validate_all
minio_start
;;
stop)
minio_stop
;;
status)
if minio_status; then
ocf_log info "Minio is running"
exit $OCF_SUCCESS
else
ocf_log info "Minio is stopped"
exit $OCF_NOT_RUNNING
fi
;;
monitor)
minio_monitor
;;
validate-all)
minio_validate_all
exit $OCF_SUCCESS
;;
meta-data|metadata|meta_data)
meta_data
;;
usage)
usage
exit $OCF_SUCCESS
;;
*)
usage
ocf_log err "$0 was called with unsupported args: $*"
exit $OCF_ERR_UNIMPLEMENTED
;;
esac
rc=$?
ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
exit $rc
diff --git a/heartbeat/proftpd b/heartbeat/proftpd
index a9fc5ffd7..0bd360503 100755
--- a/heartbeat/proftpd
+++ b/heartbeat/proftpd
@@ -1,311 +1,311 @@
#!/bin/sh
#
# Resource script for Proftpd
#
# Description: Manages Proftpd as an OCF resource in
# an Active-Passive High Availability setup.
#
# Author: Rajat Upadhyaya <urajat@novell.com> : Pure-FTPd script
# Author: Achim Stumpf <hakim.news@googlemail.com> : Rewrite as Proftpd
# License: GNU General Public License (GPL)
#
#
# usage: $0 {start|stop|status|monitor|validate-all|meta-data}
#
# The "start" arg starts Proftpd.
#
# The "stop" arg stops it.
#
# OCF parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_conffile
# OCF_RESKEY_pidfile
# OCF_RESKEY_curl_binary
# OCF_RESKEY_curl_url
# OCF_RESKEY_test_user
# OCF_RESKEY_test_pass
#
##########################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
# Parameter defaults
OCF_RESKEY_binary_default="/usr/sbin/proftpd"
OCF_RESKEY_conffile_default="/etc/proftpd.conf"
OCF_RESKEY_pidfile_default="/var/run/proftpd.pid"
OCF_RESKEY_curl_binary_default="/usr/bin/curl"
OCF_RESKEY_curl_url_default="ftp://localhost/"
OCF_RESKEY_test_user_default="test"
OCF_RESKEY_test_pass_default=""
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_conffile=${OCF_RESKEY_conffile_default}}
: ${OCF_RESKEY_pidfile=${OCF_RESKEY_pidfile_default}}
: ${OCF_RESKEY_curl_binary=${OCF_RESKEY_curl_binary_default}}
: ${OCF_RESKEY_curl_url=${OCF_RESKEY_curl_url_default}}
: ${OCF_RESKEY_test_user=${OCF_RESKEY_test_user_default}}
: ${OCF_RESKEY_test_pass=${OCF_RESKEY_test_pass_default}}
USAGE="Usage: $0 {start|stop|status|monitor|validate-all|meta-data}";
##########################################################################
usage() {
echo $USAGE >&2
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="proftpd" version="1.0">
<version>1.0</version>
<longdesc lang="en">
This script manages Proftpd in an Active-Passive setup
</longdesc>
<shortdesc lang="en">OCF Resource Agent compliant FTP script.</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">The Proftpd binary</longdesc>
<shortdesc lang="en">The Proftpd binary</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="conffile" unique="0" required="0">
<longdesc lang="en">
The Proftpd configuration file name with full path.
For example, "/etc/proftpd.conf"
</longdesc>
<shortdesc lang="en">Configuration file name with full path</shortdesc>
<content type="string" default="${OCF_RESKEY_conffile_default}" />
</parameter>
<parameter name="pidfile" unique="0" required="0">
<longdesc lang="en">The Proftpd PID file. The location of the PID file is configured in the Proftpd configuration file.</longdesc>
<shortdesc lang="en">PID file</shortdesc>
<content type="string" default="${OCF_RESKEY_pidfile_default}" />
</parameter>
<parameter name="curl_binary" unique="0" required="0">
<longdesc lang="en">The absolute path to the curl binary for monitoring with OCF_CHECK_LEVEL greater zero.</longdesc>
<shortdesc lang="en">The absolute path to the curl binary</shortdesc>
<content type="string" default="${OCF_RESKEY_curl_binary_default}" />
</parameter>
<parameter name="curl_url" unique="0" required="0">
<longdesc lang="en">The URL which is checked by curl with OCF_CHECK_LEVEL greater zero.</longdesc>
<shortdesc lang="en">The URL which is checked by curl</shortdesc>
<content type="string" default="${OCF_RESKEY_curl_url_default}" />
</parameter>
<parameter name="test_user" unique="0" required="0">
<longdesc lang="en">The name of the ftp user for monitoring with OCF_CHECK_LEVEL greater zero.</longdesc>
<shortdesc lang="en">The name of the ftp user</shortdesc>
<content type="string" default="${OCF_RESKEY_test_user_default}" />
</parameter>
<parameter name="test_pass" unique="0" required="0">
<longdesc lang="en">The password of the ftp user for monitoring with OCF_CHECK_LEVEL greater zero.</longdesc>
<shortdesc lang="en">The password of the ftp user</shortdesc>
<content type="string" default="${OCF_RESKEY_test_pass_default}" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20s" />
<action name="stop" timeout="20s" />
<action name="monitor" depth="0" timeout="20s" interval="60s" />
<action name="monitor" depth="10" timeout="20s" interval="120s" />
<action name="validate-all" timeout="20s" />
<action name="meta-data" timeout="5s" />
</actions>
</resource-agent>
END
exit $OCF_SUCCESS
}
isRunning()
{
kill -s 0 "$1" > /dev/null 2>&1
}
proftpd_status()
{
if [ -f "$OCF_RESKEY_pidfile" ]
then
# Proftpd is probably running
PID=`head -n 1 $OCF_RESKEY_pidfile`
if [ ! -z "$PID" ] ; then
- isRunning "$PID" && `ps -p $PID | grep proftpd > /dev/null 2>&1`
+ isRunning "$PID" && ps -p $PID | grep proftpd > /dev/null 2>&1
return $?
fi
fi
# Proftpd is not running
return $OCF_NOT_RUNNING;
}
proftpd_start()
{
# make a few checks and start Proftpd
if ocf_is_root ; then : ; else
ocf_log err "You must be root"
exit $OCF_ERR_PERM
fi
# if Proftpd is running return success
if proftpd_status ; then
ocf_log info "Proftpd is running already"
exit $OCF_SUCCESS
fi
# starting Proftpd
${OCF_RESKEY_binary} --config ${OCF_RESKEY_conffile} 2>/dev/null
if [ "$?" -ne 0 ]; then
ocf_log err "Proftpd returned error" $?
exit $OCF_ERR_GENERIC
fi
exit $OCF_SUCCESS
}
proftpd_stop()
{
if proftpd_status ; then
PID=`head -n 1 $OCF_RESKEY_pidfile`
if [ ! -z "$PID" ]; then
ocf_log info "Killing Proftpd PID $PID"
kill $PID > /dev/null 2>&1
if [ "$?" -eq 0 ]; then
TRIES=0
while isRunning "$PID" && [ "$TRIES" -lt 30 ]
do
sleep 1
ocf_log info "Proftpd PID $PID is still running"
TRIES=`expr $TRIES + 1`
done
isRunning "$PID"
RET=$?
if [ "$RET" -eq 0 ]; then
ocf_log info "Killing Proftpd PID $PID with SIGKILL"
kill -s 9 $PID > /dev/null 2>&1
while isRunning "$PID"
do
sleep 1
ocf_log info "Proftpd PID $PID is still running"
done
fi
else
ocf_log err "Killing Proftpd PID $PID FAILED"
exit $OCF_ERR_GENERIC
fi
fi
fi
exit $OCF_SUCCESS
}
proftpd_monitor()
{
proftpd_status
RET=$?
if [ "$RET" -ne 0 -o "$OCF_CHECK_LEVEL" = 0 ]; then
if [ "$RET" -eq 0 ]; then
PID=`head -n 1 $OCF_RESKEY_pidfile`
ocf_log debug "Proftpd monitor on PID $PID succeeded"
return $OCF_SUCCESS
else
ocf_log debug "Proftpd monitor on PID $PID failed"
return $OCF_NOT_RUNNING
fi
else
${OCF_RESKEY_curl_binary} -sS -u "${OCF_RESKEY_test_user}:${OCF_RESKEY_test_pass}" ${OCF_RESKEY_curl_url} > /dev/null 2>&1
if [ "$?" -eq 0 ]; then
ocf_log debug "Proftpd monitor with curl on URL $OCF_RESKEY_curl_url succeeded"
return $OCF_SUCCESS
else
ocf_log err "Proftpd monitor with curl on URL $OCF_RESKEY_curl_url failed"
return $OCF_NOT_RUNNING
fi
fi
}
proftpd_validate_all()
{
# check that the proftpd binary exists
if [ ! -x "$OCF_RESKEY_binary" ]; then
ocf_log err "Proftpd binary $OCF_RESKEY_binary does not exist"
exit $OCF_ERR_INSTALLED
fi
# check that the Proftpd config file exists
if [ ! -f "$OCF_RESKEY_conffile" ]; then
ocf_log err "Proftpd config file $OCF_RESKEY_conffile does not exist"
exit $OCF_ERR_CONFIGURED
fi
# check that the curl binary exists
if [ ! -x "$OCF_RESKEY_curl_binary" ]; then
ocf_log err "$OCF_RESKEY_curl_binary does not exist"
exit $OCF_ERR_INSTALLED
fi
}
#
# Main
#
if [ $# -ne 1 ]
then
usage
exit $OCF_ERR_ARGS
fi
case $1 in
start) proftpd_validate_all
proftpd_start
;;
stop) proftpd_stop
;;
status) if proftpd_status
then
ocf_log info "Proftpd is running"
exit $OCF_SUCCESS
else
ocf_log info "Proftpd is stopped"
exit $OCF_NOT_RUNNING
fi
;;
monitor) proftpd_monitor
exit $?
;;
validate-all) proftpd_validate_all
exit $OCF_SUCCESS
;;
meta-data) meta_data
;;
usage) usage
exit $OCF_SUCCESS
;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED
;;
esac
diff --git a/heartbeat/smb-share.in b/heartbeat/smb-share.in
index 3e5bf60bf..94f573f72 100755
--- a/heartbeat/smb-share.in
+++ b/heartbeat/smb-share.in
@@ -1,494 +1,494 @@
#!@BASH_SHELL@
#
# OCF Resource Agent for create samba config snippets.
#
#
#
# Copyright (c) 2021 B1 Systems GmbH <info@b1-systems.de>
# Author:
# Tobias D. Oestreicher <oestreicher@b1-systems.de>
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Further, this software is distributed without any warranty that it is
# free of the rightful claim of any third person regarding infringement
# or the like. Any license provided herein, whether implied or
# otherwise, applies only to this software file. Patent licenses, if
# any, provided herein do not apply to combinations of this program with
# other software, or any other product whatsoever.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
#
#
#
# OCF parameters are as below:
# OCF_RESKEY_outfile
# OCF_RESKEY_includesfile
# OCF_RESKEY_confd
# OCF_RESKEY_share
# OCF_RESKEY_path
# OCF_RESKEY_hosts_allow
# OCF_RESKEY_browseable
# OCF_RESKEY_writeable
# OCF_RESKEY_read_only
# OCF_RESKEY_guest_ok
# OCF_RESKEY_directory_mask
# OCF_RESKEY_create_mask
# OCF_RESKEY_printable
# OCF_RESKEY_valid_users
# OCF_RESKEY_force_user
# OCF_RESKEY_force_group
# OCF_RESKEY_extraopt
# OCF_RESKEY_extraopt_list
#
#######################################################################
#######################################################################
#
# Purpose:
# --------
# This RA is used to control samba shares on the fly.
# For adding and removing samba shares no restart of the samba daemon
# is needed. This is the equivalent of the exportfs RA which is used
# for nfs shares.
#
# How to use:
# -----------
# For this RA to work as expected you need a cloned samba daemon which
# have to be startet before.
# After this RA manages config snippets placed in the filesystem and
# after a fence of that node these snippets will still located there
# you will have to use a tmpfs mount for this.
# Also you need a basic smb.conf file in which all global parameters an
# permanent shares should be placed.
# Within this smb.conf also you must put a line in the global section
# like this:
#
# include = /etc/samba/conf.d/pacemaker-includes.conf
#
# The filename can be changed by setting the parameter "includesfile".
# Every share created by this RA will create a new file located in:
#
# /etc/samba/conf.d/
#
# This directory also can be changed by setting the RA parameter "confd".
#
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
# Defaults
OCF_RESKEY_outfile_default=""
OCF_RESKEY_includesfile_default="/etc/samba/conf.d/pacemaker-includes.conf"
OCF_RESKEY_confd_default="/etc/samba/conf.d"
OCF_RESKEY_share_default=""
OCF_RESKEY_path_default=""
OCF_RESKEY_hosts_allow_default=""
OCF_RESKEY_browseable_default=""
OCF_RESKEY_writeable_default=""
OCF_RESKEY_read_only_default=""
OCF_RESKEY_guest_ok_default=""
OCF_RESKEY_directory_mask_default=""
OCF_RESKEY_create_mask_default=""
OCF_RESKEY_printable_default=""
OCF_RESKEY_valid_users_default=""
OCF_RESKEY_force_user_default=""
OCF_RESKEY_force_group_default=""
OCF_RESKEY_extraopt_default=""
OCF_RESKEY_extraopt_list_default=""
: ${OCF_RESKEY_outfile=${OCF_RESKEY_outfile_default}}
: ${OCF_RESKEY_includesfile=${OCF_RESKEY_includesfile_default}}
: ${OCF_RESKEY_confd=${OCF_RESKEY_confd_default}}
: ${OCF_RESKEY_share=${OCF_RESKEY_share_default}}
: ${OCF_RESKEY_path=${OCF_RESKEY_path_default}}
: ${OCF_RESKEY_hosts_allow=${OCF_RESKEY_hosts_allow_default}}
: ${OCF_RESKEY_browseable=${OCF_RESKEY_browseable_default}}
: ${OCF_RESKEY_writeable=${OCF_RESKEY_writeable_default}}
: ${OCF_RESKEY_read_only=${OCF_RESKEY_read_only_default}}
: ${OCF_RESKEY_guest_ok=${OCF_RESKEY_guest_ok_default}}
: ${OCF_RESKEY_directory_mask=${OCF_RESKEY_directory_mask_default}}
: ${OCF_RESKEY_create_mask=${OCF_RESKEY_create_mask_default}}
: ${OCF_RESKEY_printable=${OCF_RESKEY_printable_default}}
: ${OCF_RESKEY_valid_users=${OCF_RESKEY_valid_users_default}}
: ${OCF_RESKEY_force_user=${OCF_RESKEY_force_user_default}}
: ${OCF_RESKEY_force_group=${OCF_RESKEY_force_group_default}}
: ${OCF_RESKEY_extraopt=${OCF_RESKEY_extraopt_default}}
: ${OCF_RESKEY_extraopt_list=${OCF_RESKEY_extraopt_list_default}}
#######################################################################
#######################################################################
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="smb-share" version="1.0">
<version>1.0</version>
<longdesc lang="en">
This RA is used to control samba shares on the fly.
For adding and removing samba shares no restart of the samba daemon
is needed. This is the equivalent of the exportfs RA which is used
for nfs shares.
For this RA to work as expected you need a cloned samba daemon which
have to be startet before.
After this RA manages config snippets placed in the filesystem and
after a fence of that node these snippets will still located there
you will have to use a tmpfs mount for this.
Also you need a basic smb.conf file in which all global parameters an
permanent shares should be placed.
Within this smb.conf also you must put a line in the global section
like this:
include = /etc/samba/conf.d/pacemaker-includes.conf
The filename can be changed by setting the parameter includesfile.
Every share created by this RA will create a new file located in:
/etc/samba/conf.d/
This directory also can be changed by setting the RA parameter confd.
</longdesc>
<shortdesc lang="en">Manages samba shares on the fly</shortdesc>
<parameters>
<parameter name="share" unique="1" required="1">
<longdesc lang="en">
Set the name of a windows share which should be added to Samba
example name "myshare" resulting in [myshare].
</longdesc>
<shortdesc lang="en">sharename</shortdesc>
<content type="string" default="${OCF_RESKEY_share_default}" />
</parameter>
<parameter name="path" unique="1" required="0">
<longdesc lang="en">
Set the path to share for cifs clients.
example path "/srv/data/myshare".
</longdesc>
<shortdesc lang="en">path to share</shortdesc>
<content type="string" default="${OCF_RESKEY_path_default}" />
</parameter>
<parameter name="hosts_allow" unique="0" required="0">
<longdesc lang="en">
This parameter is a comma, space, or tab delimited set of hosts which are permitted to access a service.
</longdesc>
<shortdesc lang="en">hosts allow parameter</shortdesc>
<content type="string" default="${OCF_RESKEY_hosts_allow_default}" />
</parameter>
<parameter name="browseable" unique="0" required="0">
<longdesc lang="en">
This controls whether this share is seen in the list of available shares in a net view and in the browse list.
</longdesc>
<shortdesc lang="en">browseable parameter</shortdesc>
<content type="string" default="${OCF_RESKEY_browseable_default}" />
</parameter>
<parameter name="writeable" unique="0" required="0">
<longdesc lang="en">
Inverted synonym for read only.
</longdesc>
<shortdesc lang="en">writeable parameter</shortdesc>
<content type="string" default="${OCF_RESKEY_writeable_default}" />
</parameter>
<parameter name="read_only" unique="0" required="0">
<longdesc lang="en">
This option can be used to turn the writing backends tdb, tdb2, and ldap into read only mode.
This can be useful e.g. in cases where a pre-filled database exists that should not be extended automatically.
</longdesc>
<shortdesc lang="en">read only parameter</shortdesc>
<content type="string" default="${OCF_RESKEY_read_only_default}" />
</parameter>
<parameter name="guest_ok" unique="0" required="0">
<longdesc lang="en">
If this parameter is yes for a service, then no password is required to connect to the service. Privileges will be those of the guest account.
</longdesc>
<shortdesc lang="en">guest ok parameter</shortdesc>
<content type="string" default="${OCF_RESKEY_guest_ok_default}" />
</parameter>
<parameter name="directory_mask" unique="0" required="0">
<longdesc lang="en">
This parameter is the octal modes which are used when converting DOS modes to UNIX modes when creating UNIX directories.
</longdesc>
<shortdesc lang="en">directory mask parameter</shortdesc>
<content type="string" default="${OCF_RESKEY_directory_mask_default}" />
</parameter>
<parameter name="create_mask" unique="0" required="0">
<longdesc lang="en">
When a file is created, the necessary permissions are calculated according to the mapping from DOS modes to UNIX permissions,
and the resulting UNIX mode is then bit-wise ANDed with this parameter. This parameter may be thought of as a bit-wise MASK for the UNIX modes of a file.
</longdesc>
<shortdesc lang="en">create mask parameter</shortdesc>
<content type="string" default="${OCF_RESKEY_create_mask_default}" />
</parameter>
<parameter name="printable" unique="0" required="0">
<longdesc lang="en">
If this parameter is yes, then clients may open, write to and submit spool files on the directory specified for the service.
</longdesc>
<shortdesc lang="en">printable parameter</shortdesc>
<content type="string" default="${OCF_RESKEY_printable_default}" />
</parameter>
<parameter name="valid_users" unique="0" required="0">
<longdesc lang="en">
This is a list of users that should be allowed to login to this service. Names starting with @, + and &amp; are interpreted
using the same rules as described in the invalid users parameter.
</longdesc>
<shortdesc lang="en">valid users parameter</shortdesc>
<content type="string" default="${OCF_RESKEY_valid_users_default}" />
</parameter>
<parameter name="force_user" unique="0" required="0">
<longdesc lang="en">
This specifies a UNIX user name that will be assigned as the default user for all users connecting to this service. This is useful for sharing files.
</longdesc>
<shortdesc lang="en">force user parameter</shortdesc>
<content type="string" default="${OCF_RESKEY_force_user_default}" />
</parameter>
<parameter name="force_group" unique="0" required="0">
<longdesc lang="en">
This specifies a UNIX group name that will be assigned as the default primary group for all users connecting to this service.
This is useful for sharing files by ensuring that all access to files on service will use the named group for their permissions checking.
</longdesc>
<shortdesc lang="en">force group parameter</shortdesc>
<content type="string" default="${OCF_RESKEY_force_group_default}" />
</parameter>
<parameter name="extraopt" unique="0" required="0">
<longdesc lang="en">
This option can be used to define an additional key = value pair.
In this parameter also a semicolon could be placed.
Need to set e.g somthinspecial = value
</longdesc>
<shortdesc lang="en">additional key value pair</shortdesc>
<content type="string" default="${OCF_RESKEY_extraopt_default}" />
</parameter>
<parameter name="extraopt_list" unique="0" required="0">
<longdesc lang="en">
This option can be used to define multiple additional key = value pairs.
Define the list of element semicolon separated.
e.g somethingspecial = value;one more = value2
</longdesc>
<shortdesc lang="en">additional key value pairs as semicolon separated list</shortdesc>
<content type="string" default="${OCF_RESKEY_extraopt_list_default}" />
</parameter>
<parameter name="outfile" unique="1" required="1">
<longdesc lang="en">
Set the path and filename where the snipped should be written.
example "/etc/samba/conf.d/myshare.inc".
</longdesc>
<shortdesc lang="en">outputfile</shortdesc>
<content type="string" default="${OCF_RESKEY_outfile_default}" />
</parameter>
<parameter name="confd" unique="0" required="0">
<longdesc lang="en">
Set the path where the includes will be written. This folder have to be a tmpfs mount
This defaults to "/etc/samba/conf.d".
</longdesc>
<shortdesc lang="en">confd directory</shortdesc>
<content type="string" default="${OCF_RESKEY_confd_default}" />
</parameter>
<parameter name="includesfile" unique="0" required="0">
<longdesc lang="en">
Set the path and filename in which the include should be placed.
example includesfile "/etc/samba/conf.d/pacemaker-includes.conf".
This option manages the include= parameter within this file
</longdesc>
<shortdesc lang="en">includesfile for smb.conf</shortdesc>
<content type="string" default="${OCF_RESKEY_includesfile_default}" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20s" />
<action name="stop" timeout="20s" />
<action name="status" depth="0" timeout="20s" interval="10s" />
<action name="monitor" depth="0" timeout="20s" interval="10s" />
<action name="meta-data" timeout="5s" />
<action name="validate-all" timeout="20s" />
</actions>
</resource-agent>
END
exit $OCF_SUCCESS
}
smb_share_addinclude() {
if [ ! -e ${OCF_RESKEY_includesfile} ];then
echo '[global]' > ${OCF_RESKEY_includesfile}
fi
if [ $(grep -c "include = $OCF_RESKEY_outfile" ${OCF_RESKEY_includesfile}) -eq 0 ];then
echo "include = $OCF_RESKEY_outfile" >> ${OCF_RESKEY_includesfile}
fi
}
smb_share_delinclude() {
ESCAPED=$(echo $OCF_RESKEY_outfile|sed 's,/,\\/,g')
sed -i /include.=.$ESCAPED/d ${OCF_RESKEY_includesfile}
}
smb_share_create() {
echo "[${OCF_RESKEY_share}]" > $OCF_RESKEY_outfile
if [ ! -z "$OCF_RESKEY_path" ];then echo " path = $OCF_RESKEY_path" >> $OCF_RESKEY_outfile; fi
if [ ! -z "$OCF_RESKEY_hosts_allow" ];then echo " hosts allow = $OCF_RESKEY_hosts_allow" >> $OCF_RESKEY_outfile; fi
if [ ! -z "$OCF_RESKEY_browseable" ];then echo " browseable = $OCF_RESKEY_browseable" >> $OCF_RESKEY_outfile; fi
if [ ! -z "$OCF_RESKEY_writeable" ];then echo " writeable = $OCF_RESKEY_writeable" >> $OCF_RESKEY_outfile; fi
if [ ! -z "$OCF_RESKEY_read_only" ];then echo " read only = $OCF_RESKEY_read_only" >> $OCF_RESKEY_outfile; fi
if [ ! -z "$OCF_RESKEY_guest_ok" ];then echo " guest ok = $OCF_RESKEY_guest_ok" >> $OCF_RESKEY_outfile; fi
if [ ! -z "$OCF_RESKEY_directory_mask" ];then echo " directory mask = $OCF_RESKEY_directory_mask" >> $OCF_RESKEY_outfile; fi
if [ ! -z "$OCF_RESKEY_create_mask" ];then echo " create mask = $OCF_RESKEY_create_mask" >> $OCF_RESKEY_outfile; fi
if [ ! -z "$OCF_RESKEY_printable" ];then echo " printable = $OCF_RESKEY_printable" >> $OCF_RESKEY_outfile; fi
if [ ! -z "$OCF_RESKEY_valid_users" ];then echo " valid users = $OCF_RESKEY_valid_users" >> $OCF_RESKEY_outfile; fi
if [ ! -z "$OCF_RESKEY_force_user" ];then echo " force user = $OCF_RESKEY_force_user" >> $OCF_RESKEY_outfile; fi
if [ ! -z "$OCF_RESKEY_force_group" ];then echo " force group = $OCF_RESKEY_force_group" >> $OCF_RESKEY_outfile; fi
if [ ! -z "$OCF_RESKEY_extraopt" ];then echo " $OCF_RESKEY_extraopt" >> $OCF_RESKEY_outfile; fi
if [ ! -z "$OCF_RESKEY_extraopt_list" ];then
IFS=';' read -r -a array <<< "$OCF_RESKEY_extraopt_list"
for i in "${array[@]}";do
echo " $i" >> $OCF_RESKEY_outfile;
done
fi
smb_share_addinclude
}
smb_share_delete() {
if [ -e $OCF_RESKEY_outfile ];then
rm -f $OCF_RESKEY_outfile 2>/dev/null
smb_share_delinclude
exit $OCF_SUCCESS
fi
}
smb_share_reloadconfig() {
smbcontrol smbd reload-config 2>/dev/null
if [ $? -eq 0 ];then
exit $OCF_SUCCESS
else
ocf_log err "Seems you have an error in your samba configuration"
exit $OCF_ERR_CONFIGURED
fi
}
smb_share_checktmpmount() {
ISMOUNT=$(grep $OCF_RESKEY_confd /proc/mounts|grep -c tmpfs)
if [ $ISMOUNT -eq 0 ];then
ocf_log err "The directoy /etc/samba/conf.d need to be a tmpfs mount"
exit $OCF_ERR_CONFIGURED
fi
}
######################################################################
smb_share_usage() {
cat <<END
usage: $0 {start|stop|status|monitor|validate-all|meta-data}
Expects to have a fully populated OCF RA-compliant environment set.
END
return $OCF_SUCCESS
}
smb_share_start() {
smb_share_create
smb_share_reloadconfig
}
smb_share_stop() {
smbcontrol smbd close-share $OCF_RESKEY_share > /dev/null 2>&1
smb_share_delete
smb_share_reloadconfig
}
smb_share_monitor() {
- RES=$(smbcontrol smbd ping > /dev/null 2>&1)
+ smbcontrol smbd ping > /dev/null 2>&1
if [ $? -eq 0 ];then
if [ $(testparm -s 2>/dev/null| $EGREP -c \\[$OCF_RESKEY_share\\]) -eq 1 ];then
return $OCF_SUCCESS
else
return $OCF_NOT_RUNNING
fi
else
return $OCF_NOT_RUNNING
fi
}
smb_share_state() {
smb_share_checktmpmount
- RES=$(smbcontrol smbd ping > /dev/null 2>&1)
+ smbcontrol smbd ping > /dev/null 2>&1
if [ $? -eq 0 ];then
if [ $(testparm -s 2>/dev/null| $EGREP -c \\[$OCF_RESKEY_share\\]) -eq 1 ];then
ocf_log info "Samba share $OCF_RESKEY_share is active"
return $OCF_SUCCESS
else
ocf_log info "Samba share $OCF_RESKEY_share is not active"
return $OCF_NOT_RUNNING
fi
else
ocf_log info "Samba share $OCF_RESKEY_share is not active"
return $OCF_NOT_RUNNING
fi
}
smb_share_validate() {
return $OCF_SUCCESS
}
case $__OCF_ACTION in
meta-data) meta_data
;;
usage|help) smb_share_usage
;;
esac
case $__OCF_ACTION in
start) smb_share_start
;;
stop) smb_share_stop
;;
status) smb_share_state
;;
monitor) smb_share_monitor
;;
validate-all) smb_share_validate
;;
*) smb_share_usage
exit $OCF_ERR_UNIMPLEMENTED
;;
esac
exit $?
# vi:sw=4:ts=8:

File Metadata

Mime Type
text/x-diff
Expires
Wed, Oct 15, 11:55 PM (2 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2465790
Default Alt Text
(105 KB)

Event Timeline