This is the OCF RA for Pure-FTPd.
This takes 2 arguments
1) the Pure-FTPd Perl/Python script which parses the Pure-FTPd
configuration file (full path)
2) the Pure-FTPd configuration file itself (full path again).
-------------------------
File : PureFTPd
#!/bin/sh
#
# License: GNU General Public License (GPL)
#
# This script is an OCF resource script for using Pure-FTPd in
# an Active-Passive setup.
#
# usage: $0 {start|stop|status|monitor|validate-all|meta-data}
#
# The "start" arg starts Pure-FTPd.
#
# Surprisingly, the "stop" arg stops it.
#
# OCF parameters are as below
# OCF_RESKEY_script
# OCF_RESKEY_conffile
#
#######################################################################
# Initialization:
. /usr/lib/heartbeat/ocf-shellfuncs
HA_VARRUNDIR=/var/run/heartbeat
IFCONFIG=/sbin/ifconfig
IFCONFIG_A_OPT=
USAGE="usage: $0 {start|stop|status|monitor|validate-all|meta-data}";
#######################################################################
LC_ALL=C
export LC_ALL
HA_D=/etc/ha.d
. ${HA_D}/shellfuncs
SYSTYPE="`uname -s`"
case "$SYSTYPE" in
SunOS)
# `uname -r` = 5.9 -> SYSVERSION = 9
SYSVERSION="`uname -r | cut -d. -f 2`"
;;
Darwin)
# Treat Darwin the same as the other BSD variants (matched as
*BSD)
SYSTYPE="${SYSTYPE}BSD"
;;
*)
;;
esac
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="Pure-FTPd">
<version>1.0</version>
<longdesc lang="en">
This script manages Pure-FTPd in an Active-Passive setup
</longdesc>
<shortdesc lang="en">OCF Resource Agent compliant FTP
script.</shortdesc>
<parameters>
<parameter name="script" unique="1" required="1">
<longdesc lang="en">
The full path to the Pure-FTPd startup script.
For example, "/sbin/pure-config.pl"
</longdesc>
<shortdesc lang="en">Script name with full path</shortdesc>
<content type="string" default="/sbin/pure-config.pl" />
</parameter>
<parameter name="conffile" unique="1" required="1">
<longdesc lang="en">
The Pure-FTPd configuration file name with full path.
For example, "/etc/pure-ftpd/pure-ftpd.conf"
</longdesc>
<shortdesc lang="en">Configuration file name with full
path</shortdesc>
<content type="string" default="/etc/pure-ftpd/pure-ftpd.conf" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="90" />
<action name="stop" timeout="100" />
<action name="monitor" depth="10" timeout="20s" interval="5s"
start-delay="1s" />
<action name="validate-all" timeout="30s" />
<action name="meta-data" timeout="5s" />
</actions>
</resource-agent>
END
exit $OCF_SUCCESS
}
PureFTPd_status()
{
pgrep pure-ftpd >> /dev/null
return $?
}
PureFTPd_start() {
#
# make a few checks and start pure-ftpd
#
if ocf_is_root ; then : ; else
ocf_log err "You must be root."
exit $OCF_ERR_PERM
fi
#if pure-ftpd is running return success
PureFTPd_status
if [ $? -eq 0 ]; then
exit $OCF_SUCCESS
fi
if [ -n $OCF_RESKEY_script -a -n $OCF_RESKEY_conffile ]; then
$OCF_RESKEY_script $OCF_RESKEY_conffile
else
ocf_log err "One or more empty arguments"
exit $OCF_ERR_GENERIC
fi
if [ $? -ne 0 ]; then
ocf_log info "Pure-FTPd returned error" $?
exit $OCF_ERR_GENERIC
fi
exit $OCF_SUCCESS
}
PureFTPd_stop()
{
PureFTPd_status
if [ $? -eq 0 ] ; then
pkill pure-ftpd
exit $OCF_SUCCESS
fi
exit $OCF_SUCCESS
}
PureFTPd_monitor() {
PureFTPd_status
if [ $? = "" ]; then
return $OCF_NOT_RUNNING
fi
return $OCF_SUCCESS
}
PureFTPd_validate_all() {
return $OCF_SUCCESS
}
usage() {
echo $USAGE >&2
}
#
#
#
if
[ $# -ne 1 ]
then
usage
exit $OCF_ERR_ARGS
fi
case $1 in
info) cat <<-!INFO
Abstract=Pure-FTPd starter
Argument=Full paths to the Pure-FTPd startup script and
configuration file
Description:
Uses the supplied script and the Pure-FTPd
configuration file to start Pure-FTPd.
Please rerun with the meta-data command for a list of
valid arguments and their defaults.
!INFO
exit $OCF_SUCCESS;;
esac
case $1 in
start) PureFTPd_start ;;
stop) PureFTPd_stop ;;
status) PureFTPd_status ;;
monitor) PureFTPd_monitor ;;
validate-all) PureFTPd_validate_all;;
meta-data) meta_data;;
usage) usage; exit $OCF_SUCCESS;;
*) usage
exit $OCF_ERR_ARGS
;;
esac
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/