diff --git a/configure.in b/configure.in index 4591456c2..dc4bd0c92 100644 --- a/configure.in +++ b/configure.in @@ -1,2991 +1,2998 @@ dnl dnl autoconf for heartbeat dnl Started by David Lee December 2000 dnl automake stuff dnl added by Michael Moerz February 2001 dnl dnl License: GNU General Public License (GPL) dnl Initialiase, with sanity check of a unique file in the hierarchy AC_INIT(heartbeat.spec.in) AC_CONFIG_AUX_DIR(.) AC_REVISION($Revision: 1.552 $) dnl cvs revision AC_CANONICAL_HOST dnl Where #defines go (e.g. `AC_CHECK_HEADERS' below) dnl dnl Internal header: include/config.h dnl - Contains ALL defines dnl - include/config.h.in is generated automatically by autoheader dnl - NOT to be included in any header files except lha_internal.h dnl (which is also not to be included in any other header files) dnl dnl External header: include/hb_config.h dnl - Contains a subset of defines checked here dnl - Manually edit include/hb_config.h.in to have configure include dnl new defines dnl - Should not include HAVE_* defines dnl - Safe to include anywhere AM_CONFIG_HEADER(include/config.h include/hb_config.h) ALL_LINGUAS="en fr" AC_ARG_WITH(hapkgversion, [ --with-hapkgversion=name Override package version (if you're a packager needing to pretend) ], [ HAPKGVERSION="$withval" ], [ HAPKGVERSION="" ], ) if test -z "$HAPKGVERSION" ; then HAPKGVERSION="2.0.9" fi AM_INIT_AUTOMAKE(heartbeat, $HAPKGVERSION) RPMREL=1 AC_SUBST(RPMREL) HB_PKG=heartbeat AC_SUBST(HB_PKG) DISTDIR=$HB_PKG-$VERSION TARFILE=$DISTDIR.tar.gz AC_SUBST(DISTDIR) AC_SUBST(TARFILE) CC_IN_CONFIGURE=yes export CC_IN_CONFIGURE INIT_EXT="" USE_MODULES=0 echo Our Host OS: $host_os/$host dnl This OS-based decision-making is poor autotools practice; dnl feature-based mechanisms are strongly preferred. dnl dnl So keep this section to a bare minimum; regard as a "necessary evil". pf_argv_set="" case "$host_os" in *bsd*) LIBS="-L/usr/local/lib" CPPFLAGS="$CPPFLAGS -I/usr/local/include" INIT_EXT=".sh" REBOOT_OPTIONS="-f" ;; *solaris*) pf_argv_set="PF_ARGV_NONE" REBOOT_OPTIONS="-f" ;; *linux*) USE_MODULES=1 REBOOT_OPTIONS="-nf" ;; dnl anything? darwin*) AC_DEFINE_UNQUOTED(ON_DARWIN, 1, Compiling for Darwin platform) LIBS="$LIBS -L${prefix}/lib" CFLAGS="$CFLAGS -I${prefix}/include" REBOOT_OPTIONS="-f" ;; esac AC_SUBST(INIT_EXT) AC_SUBST(USE_MODULES) AC_SUBST(REBOOT_OPTIONS) dnl Info for building/packaging systems. dnl dnl "pkg" (typically Solaris) generally suggests package names of the form: dnl COMPname dnl where: dnl COMP: (upper case) resembles a four character company "stock ticker"; dnl name: (lower case) is short-form (few character) product name. dnl dnl It is also conventional for the name to be closely related to the dnl installation location, typically "/opt/COMPname". dnl dnl See "linux-ha-dev" discussion, "heartbeat package name", from 12/Oct/2005. dnl "LXHAhb" seems the least evil compromise for a default. dnl Any site or packager may, of course, override this. dnl AC_ARG_WITH(pkgname, [ --with-pkgname=name name for pkg (typically for Solaris) ], [ PKGNAME="$withval" ], [ PKGNAME="LXHAhb" ], ) AC_SUBST(PKGNAME) MISSINGTHINGS="" MISSINGOPTIONALS="" FatalMissingThing() { if test X"$MISSINGTHINGS" = X; then MISSINGTHINGS="$MISSINGTHINGS $1" else MISSINGTHINGS="$MISSINGTHINGS, $1" fi shift AC_MSG_RESULT(configure: ERROR: $1 ====================) shift for j in "$@" do if test "X$j" != X-; then AC_MSG_RESULT(configure: $j ==) fi done } WarnMissingThing() { if test X"$MISSINGOPTIONALS" = X; then MISSINGOPTIONALS="$MISSINGOPTIONALS $1" else MISSINGOPTIONALS="$MISSINGOPTIONALS, $1" fi shift AC_MSG_RESULT(configure: WARNING: $1 ====================) shift for j in "$@" do if test "X$j" != X-; then AC_MSG_RESULT(configure: $j ==) fi done } CheckMissingThings() { if test "X$MISSINGOPTIONALS" != "X" then AC_MSG_WARN(The following recommended components noted earlier are missing: $MISSINGOPTIONALS We will continue but you may have lost some non-critical functionality.) fi if test "X$MISSINGTHINGS" != "X" then AC_MSG_ERROR(The following required components noted earlier are missing: $MISSINGTHINGS Please supply them and try again.) fi } dnl dnl dnl Don't ya just hate working around buggy code? dnl dnl At least code that doesn't do what you want... dnl dnl This is to make substitutions work right in RPM specfiles. dnl dnl Horms says "This is pretty ugly". dnl Alanr says: "It works. s/ ugly//" dnl dnl Patches are being accepted... dnl prefix=`eval echo "$prefix"` case $prefix in NONE) prefix=/usr/local;; esac var() { case $1 in *'${'*) res=`eval echo "$1"`;; *) res="$1";; esac case "$res" in ""|NONE) echo "$2";; *) echo "$res";; esac } dnl Keep copy of original (default) localstatedir localstatedir_orig="$localstatedir" exec_prefix=`var "$exec_prefix" "$prefix"` bindir=`var "$bindir" "$exec_prefix/bin"` sbindir=`var "$sbindir" "$exec_prefix/sbin"` datadir=`var "$datadir" "$prefix/share"` sysconfdir=`var "$sysconfdir" "$prefix/etc"` sharedstatedir=`var "$sharedstatedir" "$prefix/com"` localstatedir=`var "$localstatedir" "$prefix/var"` includedir=`var "$includedir" "$exec_prefix/include"` oldincludedir=`var "$oldincludedir" "$exec_prefix/include"` infodir=`var "$infodir" "$prefix/info"` mandir=`var "$mandir" "$exec_prefix/man"` docdir=${datadir}/doc/${HB_PKG}-${VERSION} libdir=`var "$libdir" "$exec_prefix/lib"` libexecdir=`var "$libexecdir" "$exec_prefix/libexec"` for var in libdir libexecdir do dir=`eval echo '${'${var}'}'` case $dir in *64) if test ! -d "$dir" then newdir=`echo "$dir" | sed 's%64$%%'` if test -d "$newdir" then eval $var="$newdir" AC_MSG_WARN([$var value now set to $newdir since $dir doesn't exist]) fi fi;; esac done for j in exec_prefix bindir sbindir datadir sysconfdir localstatedir \ includedir oldincludedir mandir docdir libdir do dirname=`eval echo '${'${j}'}'` if test ! -d "$dirname" then AC_MSG_WARN([$j directory ($dirname) does not exist!]) fi done dnl The GNU conventions for installation directories don't always dnl sit well with this software. In particular, GNU's stated: dnl dnl '$(localstatedir)' should normally be '/usr/local/var', ... dnl dnl is poor for us: much better would be somewhere under '/var'. dnl dnl Here within "configure" it would be poor practice for us to interfere dnl with such values, irrespective of our opinion: dnl 1. user perspective: we would have gone behind their back; dnl 2. autoconf perspective: autoconf should avoid any OS-specific mindset. dnl dnl So if localstatedir still has its default value, we issue an advisory dnl warning and inform folk of our own "ConfigureMe", which is ideally dnl suited for setting such aspects (by user, and per-OS). dnl dnl [ Another option would be to detect, and to warn of, (post-expansion) dnl non-"/var/[...]" values: something like: dnl if test `expr "$localstatedir" : '^/var/.*'` -ge '5' \ dnl -o `expr "$localstatedir" : '^/var.*'` -eq '4' dnl then else fi dnl ] # If original localstatedir had defaulted then sanity-check the result. if test "x$localstatedir_orig" = 'x${prefix}/var' # Note quote types then SNOOZING=10 AC_MSG_WARN(value/default "--localstatedir=$localstatedir" is poor.) AC_MSG_WARN("/var/something" is strongly recommended.) AC_MSG_WARN(We also recommend using "ConfigureMe".) AC_MSG_WARN(Sleeping for $SNOOZING seconds.) sleep $SNOOZING fi AC_DEFINE_UNQUOTED(HA_SYSCONFDIR, "$sysconfdir", Location of system configuration files) HA_URLBASE="http://linux-ha.org/" AC_SUBST(HA_URLBASE) AC_DEFINE_UNQUOTED(HA_URLBASE, "$HA_URLBASE", Web site base URL) HA_LIBDIR="${libdir}" AC_SUBST(HA_LIBDIR) AC_DEFINE_UNQUOTED(HA_LIBDIR,"$HA_LIBDIR", lib directory) HA_LIBHBDIR="$HA_LIBDIR/${HB_PKG}" AC_SUBST(HA_LIBHBDIR) AC_DEFINE_UNQUOTED(HA_LIBHBDIR,"$HA_LIBHBDIR", lib heartbeat directory) HA_VARRUNDIR="${localstatedir}/run" AC_SUBST(HA_VARRUNDIR) AC_DEFINE_UNQUOTED(HA_VARRUNDIR,"$HA_VARRUNDIR", var run directory) HA_VARRUNHBDIR="$HA_VARRUNDIR/${HB_PKG}" AC_SUBST(HA_VARRUNHBDIR) AC_DEFINE_UNQUOTED(HA_VARRUNHBDIR,"$HA_VARRUNHBDIR", var run heartbeat directory) +HA_VARRUNHBRSCDIR="$HA_VARRUNHBDIR/rsctmp" +AC_SUBST(HA_VARRUNHBRSCDIR) +AC_DEFINE_UNQUOTED(HA_VARRUNHBRSCDIR,"$HA_VARRUNHBRSCDIR", var run heartbeat rsctmp directory) + dnl Test the default first (priority) and last (to make sure some value is set) AC_MSG_CHECKING(for the location of the lock directory) for HA_VARLOCKDIR in ${localstatedir}/lock ${localstatedir}/spool/lock ${localstatedir}/spool/locks ${localstatedir}/lock do if test -d "$HA_VARLOCKDIR" then AC_MSG_RESULT($HA_VARLOCKDIR) break fi done AC_SUBST(HA_VARLOCKDIR) AC_DEFINE_UNQUOTED(HA_VARLOCKDIR,"$HA_VARLOCKDIR", System lock directory) HA_VARLIBDIR="${localstatedir}/lib" AC_SUBST(HA_VARLIBDIR) AC_DEFINE_UNQUOTED(HA_VARLIBDIR,"$HA_VARLIBDIR", var lib directory) HA_VARLIBHBDIR="${HA_VARLIBDIR}/${HB_PKG}" AC_SUBST(HA_VARLIBHBDIR) AC_DEFINE_UNQUOTED(HA_VARLIBHBDIR,"$HA_VARLIBHBDIR", var lib heartbeat directory) HA_COREDIR="${HA_VARLIBHBDIR}/cores" AC_SUBST(HA_COREDIR) AC_DEFINE_UNQUOTED(HA_COREDIR,"$HA_COREDIR", top directory of area to drop core files in) HA_LOGDAEMON_IPC="${HA_VARLIBDIR}/log_daemon" AC_SUBST(HA_LOGDAEMON_IPC) AC_DEFINE_UNQUOTED(HA_LOGDAEMON_IPC, "$HA_LOGDAEMON_IPC", Logging Daemon IPC socket name) dnl This IS a default but we should make sure we can override it for any dnl odd OS requirements. HA_VARLOGDIR="/var/log" AC_SUBST(HA_VARLOGDIR) AC_DEFINE_UNQUOTED(HA_VARLOGDIR,"$HA_VARLOGDIR", var log directory) STONITHPKG=stonith AC_SUBST(STONITHPKG) PILSPKG=pils AC_SUBST(PILSPKG) pils_includedir="${includedir}/${PILSPKG}" pils_plugindir="${libdir}/${PILSPKG}/plugins" stonith_includedir="${includedir}/${STONITHPKG}" stonith_plugindir="${libdir}/${STONITHPKG}/plugins" stonith_ext_plugindir="${stonith_plugindir}/external" base_includedir="${includedir}" saf_includedir="${includedir}/saf" AC_SUBST(pils_includedir) AC_SUBST(pils_plugindir) AC_SUBST(stonith_includedir) AC_SUBST(stonith_plugindir) AC_SUBST(stonith_ext_plugindir) AC_DEFINE_UNQUOTED(STONITH_EXT_PLUGINDIR, "$stonith_ext_plugindir", directory for the external stonith plugins) AC_SUBST(base_includedir) AC_SUBST(saf_includedir) AC_SUBST(docdir) # # Other interesting variables: ${host_vendor} and ${host_os} # sample values: suse linux # dnl We use this in the RPM specfile... AC_SUBST(ac_configure_args) dnl ************************************************************************* PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin" export PATH dnl checks for programs dnl dnl Which C compiler? dnl Defaults to GNU C compiler if available. dnl Always tries to set the compiler to ANSI C via options (AM) dnl Can force other with environment variable "CC". AC_PROG_CC AC_PROG_CC_STDC AC_PROG_YACC AC_DECL_YYTEXT AM_PROG_LEX AM_PATH_PYTHON AC_LIBTOOL_DLOPEN dnl Enable dlopen support... AC_LIBLTDL_CONVENIENCE dnl make libltdl a convenience lib AC_PROG_LIBTOOL dnl Replacing AC_PROG_LIBTOOL with AC_CHECK_PROG because LIBTOOL dnl was NOT being expanded all the time thus causing things to fail. AC_CHECK_PROGS(LIBTOOL, glibtool libtool libtool15 libtool13) AC_MSG_CHECKING(for glibtool or libtool*) if test x"${LIBTOOL}" = x""; then FatalMissingThing "libtool" "You need libtool to build heartbeat." \ "You can get the source from ftp://www.gnu.org/pub/gnu/" \ "or you can locate it via http://www.gnu.org/software/libtool" else AC_MSG_RESULT($LIBTOOL has been found.) fi AC_CHECK_PROGS(MAKE, gmake make) AC_MSG_CHECKING(for gmake or make) if test x"${MAKE}" = x""; then FatalMissingThing "gmake" "You need gmake to build heartbeat." \ "You can get the source from ftp://www.gnu.org/pub/gnu/" \ "or you can locate it via http://www.gnu.org/software/make/" else AC_MSG_RESULT($MAKE has been found.) fi AC_SYS_LARGEFILE AC_PATH_PROGS(HTML2TXT, lynx w3m) case $HTML2TXT in */*) ;; *) HTML2TXT="";; esac AC_PATH_PROGS(POD2MAN, pod2man, pod2man) AC_PATH_PROGS(ROUTE, route) AC_PATH_PROGS(RPM, rpmbuild) if test x"${RPM}" = x""; then AC_PATH_PROGS(RPM, rpm) fi AC_DEFINE_UNQUOTED(ROUTE, "$ROUTE", path to route command) AC_PATH_PROGS(NETSTAT, netstat, /sbin/netstat) AC_DEFINE_UNQUOTED(NETSTAT, "$NETSTAT", path to the netstat command) AC_PATH_PROGS(PING, ping, /bin/ping) AC_PATH_PROGS(IFCONFIG, ifconfig, /sbin/ifconfig) AC_PATH_PROGS(SSH, ssh, /usr/bin/ssh) AC_PATH_PROGS(SCP, scp, /usr/bin/scp) AC_PATH_PROGS(PYTHON, python) dnl - Determine which mail program exists. Mailx is Solaris AC_PATH_PROGS(MAILCMD, mail, mailx) AC_SUBST(MAILCMD) AC_DEFINE_UNQUOTED(IFCONFIG, "$IFCONFIG", path to the ifconfig command) AC_PATH_PROGS(BLOCKDEV, blockdev, /sbin/blockdev) AC_PATH_PROGS(BASENAME, basename, basename) AC_PATH_PROGS(FUSER, fuser, fuser) AC_PATH_PROGS(MOUNT, mount, mount) AC_PATH_PROGS(UMOUNT, umount, umount) AC_PATH_PROGS(FSCK, fsck, fsck) AC_PATH_PROGS(MODPROBE, modprobe, modprobe) AC_PATH_PROGS(RAIDSTART, raidstart, raidstart) AC_PATH_PROGS(RAIDSTOP, raidstop, raidstop) AC_PATH_PROGS(MDADM, mdadm, /sbin/mdadm) AC_PATH_PROGS(LIBNETCONFIG, libnet-config) AC_PATH_PROGS(GETENT, getent) AC_PATH_PROGS(IP2UTIL, ip, /sbin/ip) AC_PATH_PROGS(IPTABLES, iptables, /usr/sbin/iptables) AC_PATH_PROGS(XML2CONFIG, xml2-config) AC_PATH_PROGS(REBOOT, reboot, /sbin/reboot) AC_SUBST(REBOOT) dnl "whoami", if it exists, may be hidden away on some System-V (e.g. Solaris) AC_PATH_PROGS(WHOAMI, whoami, , ${PATH}:/usr/ucb) AC_PATH_PROGS(STRINGSCMD, strings) AC_DEFINE_UNQUOTED(STRINGSCMD, "$STRINGSCMD", path to strings command) AC_SUBST(STRINGSCMD) AC_PATH_PROGS(PERL, perl) AC_SUBST(PERL) AC_PATH_PROGS(SWIG, swig) AC_SUBST(SWIG) AC_PATH_PROGS(EGREP, egrep) AC_SUBST(EGREP) AC_PATH_PROGS(MSGFMT, msgfmt, [msgfmt not found],) AC_SUBST(MSGFMT) AC_PATH_PROGS(HG, hg, /usr/local/hg) AC_SUBST(HG) AC_PATH_PROGS(GZIP_PROG, gzip) AC_PATH_PROGS(TAR, tar) AC_PATH_PROGS(CP, cp) AC_PATH_PROGS(LS, ls) AC_PATH_PROGS(LN, ln) AC_PATH_PROGS(MD5, md5) AC_SUBST(GZIP_PROG) AC_SUBST(TAR) AC_SUBST(CP) AC_SUBST(LS) AC_SUBST(LN) AC_SUBST(MD5) dnl The "test" program can be different from the "sh" builtin. AC_PATH_PROGS(TEST, test) AC_PATH_PROGS(DRBDADM, drbdadm, /sbin/drbdadm) AC_PATH_PROGS(DRBDSETUP, drbdsetup, /sbin/drbdsetup) AC_PATH_PROGS(PKGCONFIG, pkg-config) dnl ************************************************************************ dnl Check whether non-root user can chown. dnl ************************************************************************ AC_PATH_PROGS(MKTEMP, mktemp) if test -n "$WHOAMI"; then IAM=`$WHOAMI` fi AC_MSG_CHECKING(if chown works for non-root) dnl Prefer "mktemp" command. But some OSes lack it; they can "touch". if test -n "$MKTEMP"; then F=`$MKTEMP "./.chown-testXXXXX"` else F="./.chown-test.$$" touch $F fi if case "$IAM" in root) chown nobody $F; su nobody -c "chown root $F";; *) chown root $F esac >/dev/null 2>&1 then nonroot_chown=yes AC_MSG_RESULT(yes) else nonroot_chown=no AC_MSG_RESULT(no) fi rm -f $F AM_CONDITIONAL(NONROOT_CHOWN, test "$nonroot_chown" = yes ) dnl ************************************************************************ dnl checks for libraries dnl Needed for libnet test. dnl ************************************************************************ AC_CHECK_LIB(nsl, t_open) dnl -lnsl AC_CHECK_LIB(socket, socket) dnl -lsocket AC_CHECK_LIB(posix4, sched_getscheduler) dnl -lposix4 AC_CHECK_LIB(c, dlopen) dnl if dlopen is in libc... AC_CHECK_LIB(dl, dlopen) dnl -ldl (for Linux) AC_CHECK_LIB(rt, sched_getscheduler) dnl -lrt (for Tru64) AC_CHECK_LIB(gnugetopt, getopt_long) dnl -lgnugetopt ( if available ) AC_CHECK_LIB(pam, pam_start) dnl -lpam (if available) # Not sure what OSes need this... Linux and AIX don't... # and AIX barfs on it... if test "$DLPREOPEN" = yes; then DLOPEN_FORCE_FLAGS="-dlpreopen force -dlopen-self" AC_DEFINE(DLPREOPEN, 1, [enable -dlpreopen flag]) else DLOPEN_FORCE_FLAGS="" fi AC_SUBST(DLOPEN_FORCE_FLAGS) dnl ************ uuid ********************** AC_ARG_WITH(uuid, [ --with-uuid=UUID mechanism for uuid {e2fsprogs|ossp|any|no} "e2fsprogs": e2fsprogs, typically Linux "ossp": not yet implemented "any": (default) any of the above, fallback to inbuilt "no": use inbuilt ], [ uuidimpl="$withval" ], [ uuidimpl="any" ], ) case $uuidimpl in e2fsprogs) AC_CHECK_LIB(uuid, uuid_parse,, AC_MSG_ERROR([e2fsprogs uuid library was explicitly requested but not found]) ) ;; ossp) AC_CHECK_LIB(uuid, uuid_create,, AC_MSG_ERROR([ossp uuid library was explicitly requested but not found]) ) ;; no) # Do not define anything; so use inbuilt (replace) implementation. ;; any) # Default: try to discover an implementation that we can use. AC_CHECK_LIB(uuid, uuid_parse) dnl e2fsprogs dnl AC_CHECK_LIB(uuid, uuid_create) dnl ossp ;; *) AC_MSG_ERROR([An invalid uuid library was explicitly requested]) ;; esac case "$host_os" in darwin*) dnl Recent Darwin versions do not need to link against a uuid library dnl Maybe this can be moved up into the previous block but it also might dnl break things (ie. the later check for uuid_parse) AC_CHECK_FUNCS(uuid_parse) esac AC_MSG_CHECKING(uuid implementation:) if test "$ac_cv_lib_uuid_uuid_parse" = yes; then AC_MSG_RESULT(e2fsprogs) elif test "$ac_cv_func_uuid_parse" = yes; then AC_MSG_RESULT(native) elif test "$ac_cv_lib_uuid_uuid_create" = yes; then AC_MSG_RESULT(ossp) AC_MSG_ERROR([heartbeat does not yet support ossp implementation of uuid]) else AC_MSG_RESULT(inbuilt) if test x"$uuidimpl" != x"no"; then WarnMissingThing "uuid library" \ "e2fsprogs uuid library is recommended" \ "On Linux this is the e2fsprogs-devel package" \ "See also http://sourceforge.net/projects/e2fsprogs/" fi fi dnl ************ uuid ********************** EXTRAGLIBMSG="-" if test "X${PKGCONFIG}" = "X"; then AC_MSG_RESULT(not found) FatalMissingThing "pkgconfig" "Package pkgconfig is required" \ "See http://pkgconfig.sourceforge.net/" EXTRALIBMSG="(this message might be bogus because pkgconfig is missing)" fi if test "x${enable_thread_safe}" = "xyes"; then GPKGNAME="gthread-2.0" else GPKGNAME="glib-2.0" fi if test "X${PKGCONFIG}" != "X" && $PKGCONFIG --exists $GPKGNAME; then GLIBCONFIG="$PKGCONFIG $GPKGNAME" else set -x echo PKG_CONFIG_PATH=$PKG_CONFIG_PATH $PKGCONFIG --exists $GPKGNAME; echo $? $PKGCONFIG --cflags $GPKGNAME; echo $? $PKGCONFIG $GPKGNAME; echo $? set +x FatalMissingThing "glib2-devel" \ "Package glib2-devel is missing." \ "You can get the source from ftp://ftp.gtk.org/pub/gtk/" \ "or you can locate it via http://www.gtk.org/download/" "$EXTRALIBMSG" fi AC_MSG_RESULT(using $GLIBCONFIG) AC_MSG_CHECKING(which libnet version is installed) if test x"${LIBNETCONFIG}" = x""; then AC_MSG_RESULT(using old version of API) dnl The old version of the API REQUIRES $LIBNETCONFIG dnl so we can only deal with new API unless we have it. AC_CHECK_LIB(net, libnet_get_hwaddr, [], [FatalMissingThing "libnet" "You need libnet to continue." \ "You can get libnet from http://www.packetfactory.net/libnet" \ "Note that some RPMs split libnet up into libnet and libnet-devel." \ "In this case you have to install libnet-devel"]) LIBNETDEFINES="" LIBNETLIBS=" -lnet" if test "$ac_cv_lib_nsl_t_open" = yes; then LIBNETLIBS="-lnsl $LIBNETLIBS" fi if test "$ac_cv_lib_socket_socket" = yes; then LIBNETLIBS="-lsocket $LIBNETLIBS" fi libnet=net else LIBNETDEFINES="`$LIBNETCONFIG --defines` `$LIBNETCONFIG --cflags`"; LIBNETLIBS="`$LIBNETCONFIG --libs`"; AC_MSG_RESULT(using $LIBNETCONFIG) case $LIBNETLIBS in *-l*) libnet=`echo $LIBNETLIBS | sed 's%.*-l%%'`;; *) libnet=$LIBNETLIBS;; esac dnl Add any libnet definitions to the compiler flags. CPPFLAGS="$CPPFLAGS $LIBNETDEFINES" AC_CHECK_HEADERS(libnet.h) if test "$ac_cv_header_libnet_h" = no; then FatalMissingThing "libnet" "You need libnet (headers) to continue." \ "You can get libnet from http://www.packetfactory.net/libnet" \ "Note that some RPMs split libnet up into libnet and libnet-devel." \ "In this case you have to install libnet-devel" fi fi AC_SUBST(LIBNETDEFINES) AC_SUBST(LIBNETLIBS) AC_CHECK_LIB($libnet,libnet_init, [new_libnet=yes; AC_DEFINE(HAVE_LIBNET_1_1_API, 1, Libnet 1.1 API)], [new_libnet=no; AC_DEFINE(HAVE_LIBNET_1_0_API, 1, Libnet 1.0 API)],$LIBNETLIBS) AC_MSG_CHECKING(where is python installed) if test "x${PYTHON}" = x; then PYTHON="/usr/bin/env python"; fi AC_MSG_RESULT(using $PYTHON); AC_MSG_CHECKING(if netstat supports -f inet flag) $NETSTAT -rn -f inet > /dev/null 2>&1 if test x"$?" = x"0"; then AC_DEFINE(NETSTATPARM, "-rn -f inet ", parameters to netstat to retrieve route information) AC_MSG_RESULT(yes) else AC_DEFINE(NETSTATPARM, "-rn ", parameters to netstat to retrieve route information) AC_MSG_RESULT(no) fi if test X${PING} = X then FatalMissingThing "ping" "ping command is mandantory" fi dnl Determine if we use -w1 or -t1 for ping (in PYTHON Scripts) AC_MSG_CHECKING(ping option for timeout - w or t) for PING_TIMEOUT_OPT in "-w1" "-t1" do $PING -nq -c1 $PING_TIMEOUT_OPT localhost > /dev/null 2>&1 if test "$?" = 0 then AC_DEFINE_UNQUOTED(PING_TIMEOUT_OPT, "$PING_TIMEOUT_OPT", option for ping timeout) AC_MSG_RESULT($PING_TIMEOUT_OPT) break fi done AC_SUBST(PING_TIMEOUT_OPT) dnl Determining a route (particularly for "findif"). dnl There are various mechanisms on different systems. dnl Some mechanisms require root access to evaluate, but configure is often dnl (indeed, some say should be always) running non-root. dnl dnl Therefore much of the determination has to be run-time. dnl So the principle here, at configure time, is to explore what might be dnl available, and offer as much as possible to run-time. dnl AC_DEFINE(ROUTEPARM, "-n get", paramters for route to retrieve route information) AC_DEFINE(PROCROUTE, "/proc/net/route", path were to find route information in proc) AC_MSG_CHECKING(ifconfig option to list interfaces) for IFCONFIG_A_OPT in "" "-A" "-a" do $IFCONFIG $IFCONFIG_A_OPT > /dev/null 2>&1 if test "$?" = 0 then AC_DEFINE_UNQUOTED(IFCONFIG_A_OPT, "$IFCONFIG_A_OPT", option for ifconfig command) AC_MSG_RESULT($IFCONFIG_A_OPT) break fi done AC_SUBST(IFCONFIG_A_OPT) AC_SUBST(WHOAMI) AC_SUBST(HTML2TXT) AC_SUBST(POD2MAN) AC_SUBST(ROUTEPARM) AC_SUBST(PROCROUTE) dnl Locales check - is a real ugly workaround for now til I find dnl something more useful dnl dnl "Eric Z. Ayers" wrote: dnl > dnl > Here are some more data points: dnl > dnl > SUN: /usr/lib/locale/ dnl > HP : /usr/lib/nls/loc/ dnl > OSF: /usr/lib/nls/loc/ dnl > LINUX: /usr/share/locale/ dnl > UNIXWARE: /usr/lib/locale/ dnl > FREEBSD: /usr/share/locale dnl > VMS: just kidding dnl FindADir() { type="$1" whatfor="$2" shift; shift; AC_MSG_CHECKING(for $whatfor directory) for dir do if test -d "$dir" then AC_MSG_RESULT($dir) echo $dir return 0 fi done AC_MSG_RESULT(not found) return 1 } locale_locations="/usr/share/locale /usr/lib/locale /usr/lib/nls/loc" LOCALE=`FindADir error "locale" $locale_locations` if test "X$LOCALE" = X then FatalMissingThing "Locale directory" "Locale directory is mandantory." fi RPMDIR=`FindADir warn "RPM" /usr/src/packages /usr/src/redhat` if test x"${HAVE_LIBRT}" = x""; then LIBRT="" else LIBRT=-lrt fi AC_SUBST(LIBRT) # # Where is dlopen? # if test "$ac_cv_lib_c_dlopen" = yes; then LIBADD_DL="" elif test "$ac_cv_lib_dl_dlopen" = yes; then LIBADD_DL=-ldl else LIBADD_DL=${lt_cv_dlopen_libs} fi dnl dnl Check for location of gettext dnl dnl On at least Solaris 2.x, where it is in libc, specifying lintl causes dnl grief. Ensure minimal result, not the sum of all possibilities. dnl And do libc first. dnl Known examples: dnl c: Linux, Solaris 2.6+ dnl intl: BSD, AIX FunIsInLib() { fun=$1 lib=$2 lib_var1="ac_cv_lib_${lib}_$fun" lib_var2="ac_cv_lib_${lib}___$fun" for v in $lib_var1 $lib_var2 do var=`eval echo '${'${v}'}'` case $var in yes) return 0;; no) return 1;; esac done return 0 } for gt_test_lib in c intl do AC_CHECK_LIB($gt_test_lib, gettext) if FunIsInLib gettext $gt_test_lib; then break fi done # # Where is gettext()? # if FunIsInLib gettext c ; then LIBADD_INTL="" elif FunIsInLib gettext intl ; then LIBADD_INTL=-lintl elif test -f /usr/local/lib/libintl.so -a -s /usr/local/lib/libintl.so; then # This was added for FreeBSD LIBADD_INTL="-lintl" elif test -f /sw/lib/libintl.a -a -s /sw/lib/libintl.la -a -s /sw/lib/libintl.dylib; then # This was added for Darwin + Fink LIBADD_INTL="-lintl" else FatalMissingThing "gettext function" "no library providing gettext found" fi dnl dnl Glib allows its headers/libraries to be installed anywhere. dnl And they provide a command to let you know where they are. dnl This is nice, but having them in standard places is nice too ;-) dnl if test "X$GLIBCONFIG" != X; then AC_MSG_CHECKING(for special glib includes: ) GLIBHEAD=`$GLIBCONFIG --cflags` AC_MSG_RESULT($GLIBHEAD) CPPFLAGS="$CPPFLAGS $GLIBHEAD" AC_SUBST(GLIBHEAD) dnl Note: Not bundling "GLIBLIB" with general "LIBS". dnl 1. Only very few programs require GLIBLIB dnl (This isn't true anymore -- AlanR) dnl 2. Danger of creating run-time dependency on build-time LD_LIBRARY_PATH AC_MSG_CHECKING(for glib library flags) GLIBLIB=`$GLIBCONFIG --libs` AC_MSG_RESULT($GLIBLIB) AC_SUBST(GLIBLIB) fi dnl ************************************************************************ dnl checks for header files dnl dnl check for ANSI *.h files first dnl asm/page.h: Linux, for system PAGE_SIZE AC_HEADER_STDC AC_CHECK_HEADERS(db.h) AC_CHECK_HEADERS(asm/page.h) AC_CHECK_HEADERS(time.h) AC_CHECK_HEADERS(stdarg.h) AC_CHECK_HEADERS(tcpd.h) AC_CHECK_HEADERS(uuid.h) AC_CHECK_HEADERS(uuid/uuid.h) AC_CHECK_HEADERS(sys/param.h) AC_CHECK_HEADERS(netinet/in.h) AC_CHECK_HEADERS([stdint.h unistd.h]) AC_CHECK_HEADERS(sys/termios.h) AC_CHECK_HEADERS(termios.h) dnl ************************************************************************ dnl FreeBSD requires sys/param.h and in.h to compile test netinet headers. dnl ************************************************************************ if test "$ac_cv_header_sys_param_h" -a "$ac_cv_header_netinet_in_h" = no; then AC_CHECK_HEADERS(netinet/in_systm.h) AC_CHECK_HEADERS(netinet/ip.h) AC_CHECK_HEADERS(netinet/ip_var.h) AC_CHECK_HEADERS(netinet/ip_compat.h) AC_CHECK_HEADERS(netinet/ip_fw.h) else AC_CHECK_HEADERS(netinet/in_systm.h,[],[],[#include #include ]) if test "$ac_cv_header_in_systm_h" = no; then AC_CHECK_HEADERS(netinet/ip.h,[],[],[#include #include ]) else AC_CHECK_HEADERS(netinet/ip.h,[],[],[#include #include #include ]) fi AC_CHECK_HEADERS(netinet/ip_var.h,[],[],[#include #include ]) AC_CHECK_HEADERS(netinet/ip_compat.h,[],[],[#include #include ]) AC_CHECK_HEADERS(netinet/ip_fw.h,[],[],[#include #include ]) fi AC_CHECK_HEADERS(sys/sockio.h) AC_CHECK_HEADERS(libintl.h) AC_CHECK_HEADERS(sys/types.h) AC_CHECK_HEADERS(sys/socket.h) AC_CHECK_HEADERS(arpa/inet.h) AC_CHECK_HEADERS(net/ethernet.h) AC_CHECK_HEADERS(malloc.h) AC_CHECK_HEADERS(termio.h) AC_CHECK_HEADERS(getopt.h) AC_CHECK_HEADERS(sys/prctl.h) AC_CHECK_HEADERS(linux/watchdog.h,[],[],[#include ]) dnl Sockets are our preferred and supported comms mechanism. But the dnl implementation needs to be able to convey credentials: some don't. dnl So on a few OSes, credentials-carrying streams might be a better choice. dnl dnl Solaris releases up to and including "9" fall into this category dnl (its sockets don't carry credentials; streams do). dnl dnl At Solaris 10, "getpeerucred()" is available, for both sockets and dnl streams, so it should probably use (preferred) socket mechanism. AC_CHECK_HEADERS(stropts.h) dnl streams available (fallback option) AC_CHECK_HEADERS(ucred.h) dnl e.g. Solaris 10 decl. of "getpeerucred()" AC_CHECK_FUNCS(getpeerucred) dnl ************************************************************************ dnl checks for headers needed by clplumbing On BSD AC_CHECK_HEADERS(sys/syslimits.h) if test "$ac_cv_header_sys_param_h" = no; then AC_CHECK_HEADERS(sys/ucred.h) else AC_CHECK_HEADERS(sys/ucred.h,[],[],[#include ]) fi dnl ************************************************************************ dnl checks for headers needed by clplumbing On Solaris AC_CHECK_HEADERS(sys/cred.h xti.h) dnl ************************************************************************ dnl checks for headers needed by clplumbing On FreeBSD/Solaris AC_CHECK_HEADERS(sys/filio.h) dnl dnl These next two are used to help us figure out whether to include dnl some optional STONITH plugins... dnl AC_CHECK_HEADERS(vacmclient_api.h) AC_CHECK_HEADERS(curl/curl.h) +AC_CHECK_HEADERS(openhpi/SaHpi.h) AC_MSG_CHECKING(For libOpenIPMI version 2 or greater) AC_TRY_COMPILE([#include ], [ #if (OPENIPMI_VERSION_MAJOR < 2 ) #error "Too Old" #endif ], AC_MSG_RESULT("yes") AM_CONDITIONAL(USE_OPENIPMI, true), AC_MSG_RESULT("no") AM_CONDITIONAL(USE_OPENIPMI, false)) AC_MSG_CHECKING(for special libxml2 includes) if test "x$XML2CONFIG" = "x"; then AC_MSG_RESULT(libxml2 config not found) else XML2HEAD=`$XML2CONFIG --cflags` AC_MSG_RESULT($XML2HEAD) AC_CHECK_LIB(xml2, xmlReadMemory) fi CPPFLAGS="$CPPFLAGS $XML2HEAD" dnl ************************************************************************ dnl * Check for linux/icmpv6.h to make enable the IPv6addr resource agent AC_CHECK_HEADERS(linux/icmpv6.h,[],[],[#include ]) AM_CONDITIONAL(USE_IPV6ADDR, test "$ac_cv_header_linux_icmpv6_h" = yes -a $new_libnet = yes ) AC_CHECK_HEADERS(libxml/xpath.h) dnl dnl Could check for the libraries, but if you have the headers, dnl you're a dolt for not having installed the libs ;-) dnl AM_CONDITIONAL(USE_VACM, test "$ac_cv_header_vacmclient_api_h" = yes) AM_CONDITIONAL(USE_DRAC3, test "$ac_cv_header_curl_curl_h" = yes -a "$ac_cv_header_libxml_xpath_h" = yes) +AM_CONDITIONAL(USE_OPENHPI, test "$ac_cv_header_openhpi_SaHpi_h" = yes) dnl dnl SNMP checks dnl SNMPLIB="" SNMPAGENTLIB="" SNMPCONFIG="" ENABLE_SNMP="yes" if test "x${enable_snmp}" = "xno"; then ENABLE_SNMP="no" enable_snmp_subagent="no" fi AC_CHECK_HEADERS(ucd-snmp/snmp.h,[],[],[#include #include ]) AC_CHECK_HEADERS(net-snmp/net-snmp-config.h) if test "x${ENABLE_SNMP}" = "xno"; then # nothing : elif test "x${ac_cv_header_net_snmp_net_snmp_config_h}" = "xyes"; then AC_PATH_PROGS(SNMPCONFIG, net-snmp-config) if test "X${SNMPCONFIG}" = "X"; then AC_MSG_RESULT(You need the net_snmp development package to continue.) ENABLE_SNMP="no" else AC_MSG_CHECKING(for special snmp libraries) SNMPLIB=`net-snmp-config --libs` SNMPAGENTLIB=`net-snmp-config --agent-libs` # KLUDGE!! # Apparently some versions of SUSE Linux don't include -lwrap in $SNMPAGENTLIB case $SNMPAGENTLIB in *wrap*) ;; *) SNMPAGENTLIB="$SNMPAGENTLIB -lwrap";; esac AC_MSG_RESULT($SNMPLIB) fi elif test "x${ac_cv_header_ucd_snmp_snmp_h}" = "xyes"; then # UCD SNMP # ucd-snmp-config does not seem to exist, so just # rely on people having their LDFLAGS set to the path where AC_CHECK_LIB(snmp, init_snmp, SNMPLIB="-lsnmp") if test "X${SNMPLIB}" = "X"; then AC_CHECK_LIB(ucdsnmp, init_snmp, SNMPLIB="-lucdsnmp") fi SNMPAGENTLIB="$SNMPLIB" if test "X${SNMPLIB}" = "X"; then ENABLE_SNMP="no" AC_MSG_RESULT("Could not find ucdsnmp libary." "Please make sure that libsnmp or libucdsnmp" "are in your library path. Or the path to LDFLAGS") fi else ENABLE_SNMP="no" fi if test "$ENABLE_SNMP" = "no" -a "x${enable_snmp_subagent}" = "xyes"; then FatalMissingThing "SNMP Development package" "Missing SNMP development libraries and/or headers" "" "Install net-snmp-devel to enable SNMP features" fi if test "$ENABLE_SNMP" = "no" -o "x${enable_snmp_subagent}" != "xyes"; then enable_snmp_subagent="no" RPM_ENABLE_SNMP_SUBAGENT="0" else RPM_ENABLE_SNMP_SUBAGENT="1" fi check_snmp_libs () { OLDLIBS="$LIBS" LIBS="$LIBS $@" AC_MSG_CHECKING(snmp libraries: $LIBS) AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], , AC_MSG_ERROR(cannot link with requested libraries ($LIBS). Reported errors follow: $(cat conftest.err))) AC_MSG_RESULT(ok) LIBS="$OLDLIBS" } if test "$ENABLE_SNMP" = "yes"; then check_snmp_libs $SNMPLIB fi if test "$enable_snmp_subagent" = "yes"; then check_snmp_libs $SNMPAGENTLIB fi AC_ARG_WITH(mibsdir, [ --with-miBsdir=DIR directory for mib files. ], [ MIBS_DIR="$withval" ]) if test "x${enable_snmp_subagent}" = "xyes" -a "X${MIBS_DIR}" = "X"; then AC_MSG_CHECKING(which MIB directory to use) for mibs_dir in /usr/share/snmp/mibs \ /usr/local/share/snmp/mibs; do if test -d "$mibs_dir"; then MIBS_DIR="$mibs_dir" fi done if test "X${MIBS_DIR}" = "X"; then AC_MSG_ERROR(Could not find mibs directory, please specify with --with-mibsdir); fi AC_MSG_RESULT($MIBS_DIR); fi AC_SUBST(MIBS_DIR) AC_SUBST(SNMPCONFIG) AC_SUBST(SNMPLIB) AC_SUBST(SNMPAGENTLIB) AC_SUBST(RPM_ENABLE_SNMP_SUBAGENT) AM_CONDITIONAL(USE_APC_SNMP, test "$ENABLE_SNMP" = "yes") AM_CONDITIONAL(SNMP_SUBAGENT_BUILD, test "x${enable_snmp_subagent}" = "xyes") if test x"$VERSION" \> x"1.9"; then AC_DEFINE(HAVE_NEW_HB_API, 1, [have new heartbeat api]) fi dnl dnl On many systems libcrypto is needed when linking against libsnmp. dnl Check to see if it exists, and if so use it. dnl AC_CHECK_LIB(crypto, CRYPTO_free, CRYPTOLIB="-lcrypto",) AC_SUBST(CRYPTOLIB) dnl *************************************************************************** dnl TIPC communication module dnl *************************************************************************** AC_ARG_ENABLE([tipc], [ --enable-tipc Enable TIPC Communication module, [default=try]], [], [enable_tipc=try]) AC_ARG_WITH([tipc], [ --with-tipc-source TIPC source code directory], [], []) TIPC_DEV_ROOT=${with_tipc_source} tipc_headers_found=yes if test "x${TIPC_DEV_ROOT}" != "x"; then dnl checking tipc.h in specified directory TIPC_HEADER_DIR=${TIPC_DEV_ROOT}/include AC_CHECK_HEADER([${TIPC_HEADER_DIR}/net/tipc/tipc.h], [], \ [tipc_headers_found=no] ) TIPC_INCLUDE="-I${TIPC_HEADER_DIR}" else dnl checking tipc.h in standard include directory AC_CHECK_HEADERS(net/tipc/tipc.h, [], [tipc_headers_found=no]) fi AC_SUBST(TIPC_INCLUDE) AM_CONDITIONAL(BUILD_TIPC_MODULE, test "x${tipc_headers_found}" = "xyes" && test "x${enable_tipc}" != "xno") dnl *************************************************************************** dnl CIM provider configuration dnl *************************************************************************** AC_ARG_ENABLE([cim-provider], [ --enable-cim-provider Enable CIM providers. [default=no]]) AC_ARG_WITH([cimom], [ --with-cimom Specify CIM server], [], []) AC_ARG_WITH([cmpiheader], [ --with-cmpi-headers Specify CMPI header files], [], []) AC_ARG_WITH([cmpiprovider], [ --with-provider-dir Specify CMPI providers directory], [], []) CMPI_HEADER_PATH=${with_cmpi_headers} CIMOM=${with_cimom} CMPI_PROVIDER_DIR=${with_provider_dir} if test "x${enable_cim_provider}" != "xyes"; then enable_cim_provider="no" fi if test "x${CIMOM}" = "x"; then if test "x${CIMOM}" = "x"; then AC_CHECK_PROG([CIMOM], [cimserver], [pegasus]) fi if test "x${CIMOM}" = "x"; then AC_CHECK_PROG([CIMOM], [sfcbd], [sfcb]) fi if test "x${CIMOM}" = "x"; then AC_CHECK_PROG([CIMOM], [owcimomd], [openwbem]) fi if test "x${CIMOM}" = "x"; then AC_MSG_WARN([Cimom not found, MOF will not be installed!]) fi fi if test "x${enable_cim_provider}" = "xyes"; then if test "x${CMPI_HEADER_PATH}" != "x"; then CPPFLAGS="$CPPFLAGS -I${CMPI_HEADER_PATH}" fi for header in cmpidt.h cmpift.h cmpimacs.h do AC_CHECK_HEADER([${header}], [], [AC_MSG_ERROR([Sorry, can't find CMPI header files, \ specify CMPI header files with --with-cmpi-headers please.])] ) done if test "x${CMPI_PROVIDER_DIR}" = "x"; then case ${CIMOM} in sfcbd) SFCBD_PREFIX=`which sfcbd` SFCBD_PREFIX=`dirname ${SFCBD_PREFIX}` SFCBD_PREFIX=`dirname ${SFCBD_PREFIX}` CMPI_PROVIDER_DIR=${SFCBD_PREFIX}/lib/cmpi;; openwbem) OPENWBEM_PREFIX=`which owcimomd` OPENWBEM_PREFIX=`dirname ${OPENWBEM_PREFIX}` OPENWBEM_PREFIX=`dirname ${OPENWBEM_PREFIX}` OPENWBEM_CONFIG=${OPENWBEM_PREFIX}/etc/openwbem/openwbem.conf OPENWBEM_CMPI_DIR=`grep -e "cmpiprovifc.prov_location.*=" \ ${OPENWBEM_CONFIG} | sed -e 's/.*=\s*\(\.*\)/\1/'` if test "x${OPENWBEM_CMPI_DIR}" != "x"; then CMPI_PROVIDER_DIR=${OPENWBEM_CMPI_DIR} echo cmpi provider dir set, using openwbem config file: \ ${OPENWBEM_CONFIG}. else CMPI_PROVIDER_DIR=${OPENWBEM_PREFIX}/lib/openwbem/cmpiproviders echo openwbem config not found, cmpi provider dir set to \ $(CMPI_PROVIDER_DIR) by default. fi;; pegasus) CMPI_PROVIDER_DIR=/opt/tog-pegasus/providers/lib;; *);; esac if test x"$CMPI_PROVIDER_DIR" = x ; then CMPI_PROVIDER_DIR="$libdir"/cmpi AC_MSG_RESULT(default directory: $CMPI_PROVIDER_DIR) fi fi fi AM_CONDITIONAL(CIM_PROVIDER_BUILD, test "x${enable_cim_provider}" = "xyes") AC_SUBST(CMPI_PROVIDER_DIR) AC_SUBST(CIMOM) AC_SUBST(CMPI_HEADER_PATH) dnl *************************************************************************** dnl Thread safe configuration dnl *************************************************************************** AM_CONDITIONAL(ENABLE_THREAD_SAFE, test "x${enable_thread_safe}" = "xyes") dnl ************************************************************************ dnl Handy function for checking for typedefs or struct defs dnl ************************************************************************ check_for_type() { type="$1" headers="" shift for arg do headers="${headers}${arg} " done program="if ((${type} *) 0) return 0; if (sizeof(${type})) return 0; return 0;" have="HAVE_`echo "$type" | tr ' ' '_' | dd conv=ucase 2>/dev/null`" varhave="heartbeat_cv_$have" AC_CACHE_CHECK([for type $type ],$varhave,[ AC_TRY_COMPILE([$headers], [$program], eval $varhave=yes, eval $varhave=no , eval $varhave=cross) ]) if test x"`eval echo '${'$varhave'}'`" = xyes; then return 0 fi return 1 } check_for_type_member() { type="$1" member="$2" headers="" shift shift for arg do headers="${headers}${arg} " done program="${type} foo; if ((${type} *) 0) return 0; if (sizeof(${type})) return 0; if (sizeof(foo)) return 0; (void*)foo.${member}; return 0;" have="HAVE_`echo "$type" | tr ' ' '_' | dd conv=ucase 2>/dev/null`" varhave="heartbeat_cv_$have" AC_CACHE_CHECK([for type $type ],$varhave,[ AC_TRY_COMPILE([$headers], [$program], eval $varhave=yes, eval $varhave=no , eval $varhave=cross) ]) if test x"`eval echo '${'$varhave'}'`" = xyes; then return 0 fi return 1 } dnl ************************************************************************ dnl checks for typedefs dnl dnl if not known on this system, #define size_t unsigned AC_TYPE_SIZE_T dnl dnl Check poll.h for nfds_t (Linux Only), if not define it as an unsigned long int. dnl if check_for_type "nfds_t" "#include "; then AC_DEFINE(HAVE_NFDS_T,1,[Do we have nfds_t?]) fi dnl ************************************************************************ dnl checks for structures dnl # # Look for all the variants of local/UNIX socket credentials # # Include all of these headers that we can find... # headers="" for hdr in "sys/param.h" "sys/socket.h" "sys/ucred.h" do hdrvar=ac_cv_header_`echo $hdr | sed -e 's%\.%_%' -e 's%/%_%'` if test x"`eval echo '${'$hdrvar'}'`" = xyes; then headers="$headers #include <$hdr>" fi done if check_for_type_member "struct ucred" "cr_ref" "$headers"; then AC_DEFINE(HAVE_STRUCT_UCRED_DARWIN,1,[Do we have the Darwin version of struct ucred?]) fi if check_for_type "struct ucred" "$headers"; then AC_DEFINE(HAVE_STRUCT_UCRED,1,[Do we have struct ucred?]) fi if check_for_type "struct cmsgcred" "$headers" ; then AC_DEFINE(HAVE_STRUCT_CMSGCRED,1,[Do we have struct cmsgcred?]) fi if check_for_type "struct fcred" "$headers"; then AC_DEFINE(HAVE_STRUCT_FCRED,1,[Do we have struct fcred?]) fi if check_for_type "struct cred" "$headers"; then AC_DEFINE(HAVE_STRUCT_CRED,1,[Do we have struct cred?]) fi if check_for_type "struct sockcred" "$headers"; then AC_DEFINE(HAVE_STRUCT_SOCKCRED,1,[Do we have struct sockcred?]) fi dnl Check TERMIOS for components (e.g. c_line not present on Solaris) dnl AC_CACHE_CHECK([for c_line in termios],samba_cv_HAVE_TERMIOS_C_LINE,[ AC_TRY_COMPILE([#include #include ], [struct termios ti; ti.c_line = 'a';], samba_cv_HAVE_TERMIOS_C_LINE=yes,samba_cv_HAVE_TERMIOS_C_LINE=no,samba_cv_HAVE_TERMIOS_C_LINE=cross)]) if test x"$samba_cv_HAVE_TERMIOS_C_LINE" = x"yes"; then AC_DEFINE(HAVE_TERMIOS_C_LINE,1,[ ]) fi dnl Check sockaddr_in for components (e.g. sin_len not present on Solaris) dnl AC_CACHE_CHECK([for sin_len in sockaddr_in],samba_cv_HAVE_SOCKADDR_IN_SIN_LEN,[ AC_TRY_COMPILE([#include #include ], [struct sockaddr_in si; si.sin_len = 1;], samba_cv_HAVE_SOCKADDR_IN_SIN_LEN=yes,samba_cv_HAVE_SOCKADDR_IN_SIN_LEN=no,samba_cv_HAVE_SOCKADDR_IN_SIN_LEN=cross)]) if test x"$samba_cv_HAVE_SOCKADDR_IN_SIN_LEN" = x"yes"; then AC_DEFINE(HAVE_SOCKADDR_IN_SIN_LEN,1,[ ]) fi dnl Check msghdr for components (e.g. msg_control/msg_controlen not present on Solaris) dnl AC_CACHE_CHECK([for msg_control in msghdr],samba_cv_HAVE_MSG_CONTROL_MSGHDR,[ AC_TRY_COMPILE([#include #include ], [struct msghdr mh; mh.msg_control = (void *)0;], samba_cv_HAVE_MSG_CONTROL_MSGHDR=yes,samba_cv_HAVE_MSG_CONTROL_MSGHDR=no,samba_cv_HAVE_MSG_CONTROL_MSGHDR=cross)]) if test x"$samba_cv_HAVE_MSG_CONTROL_MSGHDR" = x"yes"; then MSGHDR_TYPE="msghdr" IPCSOCKET_C="ipcsocket.c" IPCSOCKET_LO="ipcsocket.lo" else MSGHDR_TYPE="nmsghdr" IPCSOCKET_C="" IPCSOCKET_LO="" fi dnl Check syslog.h for 'facilitynames' table dnl AC_CACHE_CHECK([for facilitynames in syslog.h],ac_cv_HAVE_SYSLOG_FACILITYNAMES,[ AC_TRY_COMPILE([ #define SYSLOG_NAMES #include #include ], [ void *fnames; fnames = facilitynames; ], ac_cv_HAVE_SYSLOG_FACILITYNAMES=yes,ac_cv_HAVE_SYSLOG_FACILITYNAMES=no,ac_cv_HAVE_SYSLOG_FACILITYNAMES=cross)]) if test x"$ac_cv_HAVE_SYSLOG_FACILITYNAMES" = x"yes"; then AC_DEFINE(HAVE_SYSLOG_FACILITYNAMES,1,[ ]) fi dnl dnl Check for ALIGN in /sys/param.h dnl AC_MSG_CHECKING("for ALIGN in sys/param.h") AC_EGREP_CPP(FoundAlign, [#include #ifdef ALIGN FoundAlign #endif ], [ ALIGN="ALIGN" AC_MSG_RESULT(Yes) ], AC_MSG_RESULT("No")) AC_MSG_CHECKING("for T_ALIGN in xti.h") AC_EGREP_CPP(FoundAlign, [#include #ifdef T_ALIGN FoundAlign #endif ], [ ALIGN="T_ALIGN" AC_MSG_RESULT(Yes) ], AC_MSG_RESULT(No)) AC_SUBST(IPCSOCKET_C) AC_SUBST(IPCSOCKET_LO) AC_SUBST(ALIGN) AC_SUBST(MSGHDR_TYPE) dnl ************************************************************************ dnl checks for compiler characteristics dnl dnl Warnings for C compilers. Note: generic, portable warnings only. dnl Things likely to be specific to a particular OS or module should be dnl carefully handled afterwards. AC_C_STRINGIZE dnl ********************************************************************** dnl time-related declarations etc. AC_STRUCT_TIMEZONE if check_for_type_member "struct tm" "tm_gmtoff" "#include "; then AC_DEFINE(HAVE_TM_GMTOFF,1,[Do we have structure member tm_gmtoff?]) fi dnl ********************************************************************** dnl Check the size of the integer types dnl So we can have integers of known sizes as needed dnl AC_CHECK_SIZEOF(char) AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(long long) AC_ARG_ENABLE([all], [ --enable-all Activate ALL features [default=no]]) AC_ARG_ENABLE([ansi], [ --enable-ansi force GCC to compile to ANSI/ANSI standard for older compilers. [default=yes]]) AC_ARG_ENABLE([fatal-warnings], [ --enable-fatal-warnings very pedantic and fatal warnings for gcc [default=yes]], [], [enable_fatal_warnings=unknown]) AC_ARG_ENABLE([times-kludge], [ --enable-times-kludge enables a kludge to workaround a bug in glibc's times(2) call [default=yes]], [], [enable_times_kludge=unknown]) AC_ARG_ENABLE([no-long-long], [ --enable-no-long-long removes no long long warning for gcc [default=yes]], [], [enable_no_long_long=yes]) AC_ARG_ENABLE([traditional-warnings], [ --enable-traditional-warnings enable traditional warnings gcc (-Wtraditional) [default=no]]) AC_ARG_ENABLE([pretty], [ --enable-pretty Pretty-print compiler output unless there is an error [default=no]]) AC_ARG_ENABLE([quiet], [ --enable-quiet Supress make output unless there is an error [default=no]]) AC_ARG_ENABLE([ldirectord], [ --enable-ldirectord enable Linix Director Daemon for use with LVS [default=yes]], [], [enable_ldirectord=yes]) AM_CONDITIONAL(LDIRECTORD_BUILD, test "X$enable_ldirectord" = "Xyes") AC_ARG_ENABLE([thread-safe], [ --enable-thread-safe Enable some client libraries to be thread safe. [default=no]]) AC_ARG_ENABLE([snmp], [ --enable-snmp Enable building of SNMP related functionality. [default=yes]]) AC_ARG_ENABLE([snmp-subagent], [ --enable-snmp-subagent Enable building of our SNMP subagent (lots of dependencies). [default=try]]) CC_WARNINGS="" dnl - If requested, enable ALL subsystems. if test "${enable_all}" = "yes" ; then echo "Enabling all optional features." enable_ansi=yes; enable_crm=yes; enable_fatal_warnings=yes; enable_lrm=yes; enable_snmp_subagent=try; enable_mgmt=try; enable_quorumd=try; enable_cim_provider=try; fi AC_ARG_ENABLE([bundled-ltdl], [ --enable-bundled-ltdl Configure, build and install the standalone ltdl library bundled with Heartbeat [default=no]]) LTDL_LIBS="" dnl Check before we enable -Wstrict-prototypes as it causes the test to fail AC_CHECK_LIB(ltdl, lt_dlopen, [LTDL_foo=1]) if test "x${enable_bundled_ltdl}" = "xyes"; then if test $ac_cv_lib_ltdl_lt_dlopen = yes; then AC_MSG_NOTICE([Disabling usage of installed ltdl]) fi ac_cv_lib_ltdl_lt_dlopen=no fi LIBLTDL_DIR="" if test $ac_cv_lib_ltdl_lt_dlopen != yes ; then AC_MSG_NOTICE([Installing local ltdl]) LIBLTDL_DIR=libltdl ( cd $srcdir ; $TAR -xvf libltdl.tar ) if test "$?" -ne 0; then AC_MSG_ERROR([$TAR of libltdl.tar in $srcdir failed]) fi AC_CONFIG_SUBDIRS(libltdl) else LIBS="$LIBS -lltdl" AC_MSG_NOTICE([Using installed ltdl]) INCLTDL="" LIBLTDL="" fi dnl libltdl additions AC_SUBST(INCLTDL) AC_SUBST(LIBLTDL) AC_SUBST(LIBLTDL_DIR) dnl ************ curses ********************** dnl A few OSes (e.g. Linux) deliver a default "ncurses" alongside "curses". dnl Many non-Linux deliver "curses"; sites may add "ncurses". dnl dnl However, the source-code recommendation for both is to #include "curses.h" dnl (i.e. "ncurses" still wants the include to be simple, no-'n', "curses.h"). dnl dnl Andrew Beekhof (author of heartbeat code that uses this functionality) dnl wishes "ncurses" to take precedence. So the following ordering has dnl been devised to implement this. dnl dnl Look first for the headers, then set the libraries accordingly. dnl (Normally autoconf suggests looking for libraries first.) dnl AC_CHECK_HEADERS(curses.h) AC_CHECK_HEADERS(curses/curses.h) AC_CHECK_HEADERS(ncurses.h) AC_CHECK_HEADERS(ncurses/ncurses.h) dnl Although n-library is preferred, only look for it if the n-header was found. CURSESLIBS='' if test "$ac_cv_header_ncurses_h" = "yes"; then AC_CHECK_LIB(ncurses, printw, [CURSESLIBS='-lncurses'; AC_DEFINE(HAVE_LIBNCURSES,1, have ncurses library)] ) fi if test "$ac_cv_header_ncurses_ncurses_h" = "yes"; then AC_CHECK_LIB(ncurses, printw, [CURSESLIBS='-lncurses'; AC_DEFINE(HAVE_LIBNCURSES,1, have ncurses library)] ) fi dnl Only look for non-n-library if there was no n-library. if test X"$CURSESLIBS" = X"" -a "$ac_cv_header_curses_h" = "yes"; then AC_CHECK_LIB(curses, printw, [CURSESLIBS='-lcurses'; AC_DEFINE(HAVE_LIBCURSES,1, have curses library)] ) fi dnl Only look for non-n-library if there was no n-library. if test X"$CURSESLIBS" = X"" -a "$ac_cv_header_curses_curses_h" = "yes"; then AC_CHECK_LIB(curses, printw, [CURSESLIBS='-lcurses'; AC_DEFINE(HAVE_LIBCURSES,1, have curses library)] ) fi AC_SUBST(CURSESLIBS) dnl ************ curses ********************** if test "$GCC" = yes; then dnl dnl We make sure warnings are carefully scrubbed out of the output if dnl you're running on some platforms. You can enable that behavior with dnl the option "fatal-warnings", by specifying --enable-fatal-warnings. dnl Or, you can disable it with --disable-fatal-warnings. dnl dnl Horms 10th August 2001 dnl Don't do this, it seems to cause configure in dnl the libltdl/ directory to die under Debian Woody dnl I'm suspecting it will be a problem on other systems too. dnl For this reason it now defaults to off. dnl AlanR 11 August 2001 dnl Show no mercy to broken OSes and other software. If you have broken dnl software, turn this feature off. dnl NO warnings WHATSOVER will be tolerated without good reason. dnl A distribution being broken isn't a good reason. dnl The cure for that is fix the distribution, not destroy the integrity dnl of the entire project by defaulting it to "off". dnl In my experience, there are ways of making individual warnings go dnl away. dnl The only way I know to keep them out is to make them an absolute dnl pain to deal with. Otherwise they're a pain to fix. dnl This policy is not an accident, nor was it chosen without significant dnl thought and experience. dnl cc_supports_flag() { AC_MSG_CHECKING(whether $CC supports "$@") Cfile=/tmp/foo${$} touch ${Cfile}.c $CC -c "$@" ${Cfile}.c -o ${Cfile}.o >/dev/null 2>&1 rc=$? rm -f ${Cfile}.c ${Cfile}.o case $rc in 0) AC_MSG_RESULT(yes);; *) AC_MSG_RESULT(no);; esac return $rc } dnl ************ printw ********************** if test X"$CURSESLIBS" != X"" && cc_supports_flag -Wcast-qual \ && cc_supports_flag -Werror; then dnl Check for printw() prototype compatibility dnl FIXME: We can check che prototype compatibility only if $CC supports dnl -Wcast-qual and -Werror AC_MSG_CHECKING(whether printw() requires argument of "const char *") ac_save_LIBS=$LIBS LIBS="$CURSESLIBS $LIBS" ac_save_CFLAGS=$CFLAGS CFLAGS="-Wcast-qual -Werror" AC_LINK_IFELSE( [AC_LANG_PROGRAM( [ #if defined(HAVE_CURSES_H) # include #elif defined(HAVE_NCURSES_H) # include #endif ], [printw((const char *)"Test");] )], [ac_cv_compatible_printw=yes], [ac_cv_compatible_printw=no] ) LIBS=$ac_save_LIBS CFLAGS=$ac_save_CFLAGS AC_MSG_RESULT([$ac_cv_compatible_printw]) if test "$ac_cv_compatible_printw" = no; then AC_MSG_WARN([The printw() function of your ncurses or curses library is old, we will disable usage of the library. If you want to use this library anyway, please update to newer version of the library, ncurses 5.4 or later is recommended. You can get the library from http://www.gnu.org/software/ncurses/.]) AC_MSG_NOTICE([Disabling curses]) AC_DEFINE(HAVE_INCOMPATIBLE_PRINTW, 1, [Do we have incompatible printw() in curses library?]) dnl AC_DEFINE(HAVE_CURSES_H, 0) dnl AC_DEFINE(HAVE_NCURSES_H, 0) fi fi dnl ************ printw ********************** EXTRA_WARNINGS="" # We had to eliminate -Wnested-externs because of libtool changes WARNLIST="all missing-prototypes missing-declarations strict-prototypes declaration-after-statement pointer-arith write-strings cast-qual cast-align bad-function-cast inline missing-format-attribute format=2 format-security format-nonliteral no-long-long no-strict-aliasing" for j in $WARNLIST do if cc_supports_flag -W$j then case $j in "no-long-long") if test "${enable_no_long_long}" = "yes"; then EXTRA_WARNINGS="$EXTRA_WARNINGS -W$j" fi;; *) EXTRA_WARNINGS="$EXTRA_WARNINGS -W$j";; esac fi done dnl Add any system specific options here. if test "${enable_ansi}" = "unknown"; then enable_ansi=yes fi case "$host_os" in *linux*|*bsd*) if test "${enable_fatal_warnings}" = "unknown"; then enable_fatal_warnings=yes fi ;; *solaris*) ;; esac case "$host_os" in *linux*) if test "${enable_times_kludge}" = "unknown"; then enable_times_kludge=yes fi ;; esac if test "${enable_ansi}" = yes && cc_supports_flag -std=iso9899:199409 ; then echo "Enabling ANSI Compatibility on this platform" ANSI="-ansi -D_GNU_SOURCE -DANSI_ONLY" fi if test "${enable_fatal_warnings}" = yes && cc_supports_flag -Werror ; then echo "Enabling Fatal Warnings (-Werror) on this platform" FATAL_WARNINGS="-Werror" fi if test "$enable_traditional_warning" = yes && \ cc_supports_flag -Wtraditional; then echo "Enabling traditional warnings" EXTRA_WARNINGS="$EXTRA_WARNINGS -Wtraditional" fi CC_WARNINGS="$EXTRA_WARNINGS $FATAL_WARNINGS $ANSI" NON_FATAL_CC_WARNINGS="$EXTRA_WARNINGS" fi if test "${enable_times_kludge}" = no; then echo "Disabling times(2) kludge" AC_DEFINE(DISABLE_TIMES_KLUDGE, 1, [disable times(2) kludge]) fi AC_SUBST(DISABLE_TIMES_KLUDGE) AC_MSG_CHECKING(which init (rc) directory to use) INITDIR="" for initdir in /etc/init.d /etc/rc.d/init.d /sbin/init.d \ /usr/local/etc/rc.d /etc/rc.d do if test -d $initdir then INITDIR=$initdir AC_MSG_RESULT($INITDIR); break fi done AC_ARG_WITH(initdir, [ --with-initdir=DIR directory for init (rc) scripts [${INITDIR}]], [ if test x"$withval" = xprefix; then INITDIR=${prefix}; else INITDIR="$withval"; fi ]) if test "X$INITDIR" = X then FatalMissingThing "init directory" "Could not locate init directory" fi AC_SUBST(INITDIR) dnl ********************************************************************** dnl checks for group to install fifos as dnl dnl These checks aren't right. We need to locate the lowest dnl unused group id if haclient isn't in the /etc/group file dnl and no one has overridden group-id with a --with-group-id dnl option. dnl AC_ARG_WITH( group-name, [ --with-group-name=GROUP_NAME GROUP_NAME to run our programs as. [default=haclient] ], [ HA_APIGROUP="$withval" ], [ HA_APIGROUP="haclient" ], ) AC_SUBST(HA_APIGROUP) AC_DEFINE_UNQUOTED(HA_APIGROUP, "$HA_APIGROUP", group for our programs) if test -z "${GETENT}" -o ! -x "${GETENT}" then GETENT=getent getent() { grep "^${2}:" /etc/$1 } fi if test -z "${IP2UTIL}" -o ! -x "${IP2UTIL}" then IP2UTIL=/sbin/ip fi AC_ARG_WITH( group-id, [ --with-group-id=GROUP_ID GROUP_ID to run our programs as. [default=60] ], [ HA_APIGID="$withval" ], [ HA_APIGID=65 ], ) if getent group "$HA_APIGROUP" > /dev/null then HA_APIGID=`getent group "$HA_APIGROUP" | cut -d: -f3` fi AC_SUBST(HA_APIGID) AC_DEFINE_UNQUOTED(HA_APIGID, "$HA_APIGID", id for api group) AC_ARG_WITH( ccmuser-name, [ --with-ccmuser-name=HA_CCMUSER_NAME HA_CCMUSER_NAME to run privileged non-root things as. [default=hacluster] ], [ HA_CCMUSER="$withval" ], [ HA_CCMUSER="hacluster" ], ) AC_SUBST(HA_CCMUSER) AC_DEFINE_UNQUOTED(HA_CCMUSER, "$HA_CCMUSER", user to run privileged non-root things as) AC_ARG_WITH( ccmuser-id, [ --with-ccmuser-id=HA_HA_CCMUSER_ID USER_ID to run privileged non-root things as. [default=17] ], [ HA_CCMUID="$withval" ], [ HA_CCMUID=17 ], ) if getent passwd "$HA_CCMUSER" >/dev/null then HA_CCMUID=`getent passwd "$HA_CCMUSER" | cut -d: -f3` fi AC_SUBST(HA_CCMUID) AC_DEFINE_UNQUOTED(HA_CCMUID, "$HA_CCMUID", id for ccm user) # # Priority for starting via init startup scripts # AC_ARG_WITH( start-init-priority, [ --with-start-init-priority=number Init start priority. [default=75] ], [ HB_INITSTARTPRI="$withval" ], [ HB_INITSTARTPRI=75 ], ) AC_SUBST(HB_INITSTARTPRI) AC_DEFINE_UNQUOTED(HB_INITSTARTPRI,"$HB_INITSTARTPRI", init start priority) # # Priority for stopping via init shutdown scripts # AC_ARG_WITH( stop-init-priority, [ --with-stop-init-priority=number Init stop priority. [default=5] ], [ HB_INITSTOPPRI="$withval" ], [ HB_INITSTOPPRI=05 ], ) AC_SUBST(HB_INITSTOPPRI) AC_DEFINE_UNQUOTED(HB_INITSTOPPRI,"$HB_INITSTOPPRI", init stop priority) # # Name of UCD-SNMP development package # AC_ARG_WITH( ucd-snmp-devel, [ --with-snmp-name=name Name of ucd snmp developemnt RPM. [default=ucd-snmp-devel] ], [ UCDSNMPDEVEL=$withval ], [ UCDSNMPDEVEL=ucd-snmp-devel ], ) if test "$ac_cv_header_ucd_snmp_snmp_h" = no; then UCDSNMPDEVEL="" fi AC_SUBST(UCDSNMPDEVEL) AC_DEFINE_UNQUOTED(UCDSNMPDEVEL, $UCDSNMPDEVEL, Name of UCD SNMP development package) dnl ************************************************************************ dnl checks for library functions to replace them dnl dnl alphasort: Only on BSD. dnl System-V systems may have it, but hidden and/or deprecated. dnl A replacement function is supplied for it. dnl dnl NoSuchFunctionName: dnl is a dummy function which no system supplies. It is here to make dnl the system compile semi-correctly on OpenBSD which doesn't know dnl how to create an empty archive dnl dnl scandir: Only on BSD. dnl System-V systems may have it, but hidden and/or deprecated. dnl A replacement function is supplied for it. dnl dnl setenv: is some bsdish function that should also be avoided (use dnl putenv instead) dnl On the other hand, putenv doesn't provide the right API for the dnl code and has memory leaks designed in (sigh...) Fortunately this dnl A replacement function is supplied for it. dnl dnl setproctitle: sets the process title to a given string dnl dnl strerror: returns a string that corresponds to an errno. dnl A replacement function is supplied for it. dnl dnl unsetenv: is some bsdish function that should also be avoided (No dnl replacement) dnl A replacement function is supplied for it. dnl dnl strnlen: is a gnu function similar to strlen, but safer. dnl We wrote a tolearably-fast replacement function for it. dnl dnl strndup: is a gnu function similar to strdup, but safer. dnl We wrote a tolearably-fast replacement function for it. dnl dnl daemon: is a GNU function. The daemon() function is for programs wishing to dnl detach themselves from the controlling terminal and run in the dnl background as system daemon dnl A replacement function is supplied for it. dnl dnl Check Only dnl dnl getopt: If this is valid, define HAVE_DECL_GETOPT to make the getopt.h header compile cleanly. dnl AC_REPLACE_FUNCS(alphasort inet_pton NoSuchFunctionName scandir setenv strerror unsetenv strnlen strndup daemon uuid_parse) dnl AC_CHECK_FUNCS(alphasort inet_pton NoSuchFunctionName scandir setenv strerror unsetenv strnlen strndup daemon uuid_parse) AC_CHECK_FUNCS(getopt, AC_DEFINE(HAVE_DECL_GETOPT, 1, [Have getopt function])) AC_SUBST(HA_HAVE_ALPHASORT) AC_SUBST(HA_HAVE_INET_PTON) AC_SUBST(HA_HAVE_SCANDIR) AC_SUBST(HA_HAVE_SETENV) AC_SUBST(HA_HAVE_STRERROR) AC_SUBST(HA_HAVE_UNSETENV) AC_SUBST(HA_HAVE_STRNLEN) AC_SUBST(HA_HAVE_STRNDUP) AC_SUBST(HA_HAVE_DAEMON) AC_SUBST(HA_HAVE_UUID_PARSE) AC_SUBST(HAVE_DECL_GETOPT) AC_CHECK_FUNCS(fcntl) AC_CHECK_FUNCS(flock) AC_CHECK_FUNCS(inet_aton) AC_CHECK_FUNCS(mallinfo) AC_CHECK_FUNCS(mallopt) AC_CHECK_FUNCS(__default_morecore) AC_CHECK_FUNCS(seteuid) AC_CHECK_FUNCS(setegid) AC_CHECK_FUNCS(getpeereid) dnl ********************************************************************** dnl Check for various argv[] replacing functions on various OSs dnl dnl Borrowed from Proftpd dnl Proftpd is Licenced under the terms of the GNU General Public Licence dnl and is available from http://www.proftpd.org/ dnl AC_CHECK_FUNCS(setproctitle) AC_CHECK_HEADERS(libutil.h) AC_CHECK_LIB(util, setproctitle, [AC_DEFINE(HAVE_SETPROCTITLE,1,[ ]) ac_cv_func_setproctitle="yes" ; LIBS="$LIBS -lutil"]) if test "$ac_cv_func_setproctitle" = "yes"; then pf_argv_set="PF_ARGV_NONE" fi if test "$pf_argv_set" = ""; then AC_CHECK_HEADERS(sys/pstat.h) if test "$ac_cv_header_pstat_h" = "yes"; then AC_CHECK_FUNCS(pstat) if test "$ac_cv_func_pstat" = "yes"; then pf_argv_set="PF_ARGV_PSTAT" else pf_argv_set="PF_ARGV_WRITEABLE" fi fi if test "$pf_argv_set" = ""; then AC_EGREP_HEADER([#define.*PS_STRINGS.*],sys/exec.h, have_psstrings="yes",have_psstrings="no") if test "$have_psstrings" = "yes"; then pf_argv_set="PF_ARGV_PSSTRINGS" fi fi if test "$pf_argv_set" = ""; then AC_CACHE_CHECK(whether __progname and __progname_full are available, pf_cv_var_progname, AC_TRY_LINK([extern char *__progname, *__progname_full;], [__progname = "foo"; __progname_full = "foo bar";], pf_cv_var_progname="yes", pf_cv_var_progname="no")) if test "$pf_cv_var_progname" = "yes"; then AC_DEFINE(HAVE___PROGNAME,1,[ ]) fi AC_CACHE_CHECK(which argv replacement method to use, pf_cv_argv_type, AC_EGREP_CPP(yes,[ #if defined(__GNU_HURD__) yes #endif ],pf_cv_argv_type="new", pf_cv_argv_type="writeable")) if test "$pf_cv_argv_type" = "new"; then pf_argv_set="PF_ARGV_NEW" fi if test "$pf_argv_set" = ""; then pf_argv_set="PF_ARGV_WRITEABLE" fi fi fi AC_DEFINE_UNQUOTED(PF_ARGV_TYPE, $pf_argv_set, mechanism to pretty-print ps output: setproctitle-equivalent) dnl End of tests borrowed from Proftpd dnl check if header file and lib are there for hbaping hbaping_build="yes" AC_CHECK_HEADERS(time.h hbaapi.h, , [hbaping_build="no"],[[#if HAVE_TIME_H #include #endif]]) AC_CHECK_LIB(HBAAPI, HBA_SendScsiInquiry, , [hbaping_build="no"]) AM_CONDITIONAL(HBAAPI_BUILD, test "x${hbaping_build}" = "xyes") dnl check if header file and lib are there for zlib zlib_installed="yes" AC_CHECK_HEADERS(zlib.h, , [zlib_installed="no"],) AC_CHECK_LIB(z, compress , , [zlib_intalled="no"]) AM_CONDITIONAL(BUILD_ZLIB_COMPRESS_MODULE, test "x${zlib_installed}" = "xyes") dnl check if header file and lib are there for zlib bz2_installed="yes" AC_CHECK_HEADERS(bzlib.h, , [bz2_installed="no"],) AC_CHECK_LIB(bz2, BZ2_bzBuffToBuffCompress , , [bz2_intalled="no"]) AM_CONDITIONAL(BUILD_BZ2_COMPRESS_MODULE, test "x${bz2_installed}" = "xyes") dnl check if header file and lib are there for openais module openais_installed="yes" AC_CHECK_HEADERS(evs.h, , [openais_installed="no"],) AC_CHECK_LIB(evs, evs_initialize , , [openais_intalled="no"]) AM_CONDITIONAL(BUILD_OPENAIS_MODULE, test "x${openais_installed}" = "xyes") AC_MSG_CHECKING(if clock_t is long enough) if test $ac_cv_sizeof_long -ge 8; then AC_MSG_RESULT(yes) AC_DEFINE(CLOCK_T_IS_LONG_ENOUGH, 1, [Set if CLOCK_T is adequate by itself for the "indefinite future" (>= 100 years)]) else AC_MSG_RESULT(no) fi dnl check if there are getpid() inconsistency dnl Note: reduce LIBS; in particular, ltdl can cause confusion. dnl Possibly better: move 'LIBS="$LIBS -lltdl"' from above to beyond here. dnl AC_MSG_CHECKING(for getpid() consistency in multi-process/threads program) ac_save_LIBS=$LIBS LIBS="-lpthread" AC_TRY_RUN(`cat $srcdir/config/pidtest.c`, AC_MSG_RESULT(ok), [AC_MSG_RESULT(fail); AC_DEFINE(GETPID_INCONSISTENT, 1 , [pid inconsistent])],) LIBS=$ac_save_LIBS dnl check byte order AC_MSG_CHECKING(for byteorder) AC_TRY_RUN(`cat $srcdir/config/byteorder_test.c`, [AC_MSG_RESULT(little-endian); AC_DEFINE(CONFIG_LITTLE_ENDIAN, 1, [little-endian])], [AC_MSG_RESULT(big-endian); AC_DEFINE(CONFIG_BIG_ENDIAN, 1, [big-endian])],) dnl dnl Lex and yacc can't be trusted to produce code that won't produce dnl warnings dnl NON_FATAL_CFLAGS="$CFLAGS $NON_FATAL_CC_WARNINGS" AC_SUBST(NON_FATAL_CFLAGS) dnl dnl We reset CFLAGS to include our warnings *after* all function dnl checking goes on, so that our warning flags don't keep the dnl AC_*FUNCS() calls above from working. In particular, -Werror will dnl *always* cause us troubles if we set it before here. dnl dnl CFLAGS="$CFLAGS $CC_WARNINGS" dnl NOTE: dnl This check should only be done after CFLAGS is set. Otherwise dnl linux box will complain because of a warning of the undefined dnl function sigignore(). dnl dnl In theory, all function checks should be done after the CFLAGS is dnl set since we are enforcing the -Werror. But this would have a big dnl impact on the whole source tree so I am only moving the dnl sigignore for now. A bit of a hack. dnl dnl sigignore: Only on Solaris. dnl it is a solaris replacement for signal(s,SIG_IGN). dnl AC_CHECK_FUNCS(sigignore) dnl dnl Make sure that CFLAGS is not exported. If the user did dnl not have CFLAGS in their environment then this should have dnl no effect. However if CFLAGS was exported from the user's dnl environment, then the new CFLAGS will also be exported dnl to sub processes. This causes a problem when configure dnl is run in the libltdl directory. Horms 16th July 2002 dnl if export | fgrep " CFLAGS=" > /dev/null; then export -n CFLAGS || true # We don't want to bomb out if this fails fi if test "$GCC" = yes; then CFLAGS="$CFLAGS -ggdb3" if cc_supports_flag -funsigned-char then CFLAGS="$CFLAGS -funsigned-char" fi else CFLAGS="$CFLAGS -g" fi dnl AC_SUBST(CC_WARNINGS) dnl ************************************************************************ dnl pre AC_OUTPUT stuff dnl dnl th aux dir (for holding config & autogenerated stuff) dnl AC_SUBST(ac_aux_dir) dnl for libtool to work LTLIBOJS is needed (currently bug of autoconf) Xsed="sed -e s/^X//" dnl This line breaks on every single version other than the newest Suse (United Linux) dnl the following lines are marked do not change because they are used dnl to provide context to a patch which adapts this script dnl to run with automake 2.53 so, make changes outside this range of lines, dnl or make sure you fix the diff autoconf-2.53.diff file. dnl do not change this line #1! dnl do not change this line #2! dnl do not change this line #3! dnl This version is this incompatible with older versions of autoconf AC_PREREQ(2.53) LTLIBOBJS=`echo X"$LIB@&t@OBJS"|[$Xsed -e "s,\.[^.]* ,.lo ,g;s,\.[^.]*$,.lo,"]` dnl LTLIBOBJS=`echo X"$LIBOBJS"|[$Xsed -e "s,\.[^.]* ,.lo ,g;s,\.[^.]*$,.lo,"]` dnl do not change this line #4! dnl do not change this line #5! dnl do not change this line #6! AC_SUBST(LTLIBOBJS) AC_SUBST(LIBADD_DL) dnl extra flags for dynamic linking libraries AC_SUBST(LIBADD_INTL) dnl extra flags for GNU gettext stuff... AC_SUBST(LOCALE) HA_HBCONF_DIR=$sysconfdir/ha.d AC_SUBST(HA_HBCONF_DIR) AC_DEFINE_UNQUOTED(HA_HBCONF_DIR,"$HA_HBCONF_DIR", Heartbeat configuration directory) HA_RC_DIR=$HA_HBCONF_DIR/rc.d AC_SUBST(HA_RC_DIR) AC_DEFINE_UNQUOTED(HA_RC_DIR,"$HA_RC_DIR", heartbeat v1 script directory) AC_ARG_ENABLE([crm], [ --enable-crm Compile the Version 2 Cluster Resource Manager. [default=yes]], [], [enable_crm=yes]) CRM_DIR="" if test "x${enable_crm}" = "xyes"; then CRM_ENABLED=1 CRM_DIR=crm AC_DEFINE_UNQUOTED(WITH_CRM, 1, Use the new Cluster Resource Manager) else if test -z "${enable_crm}"; then enable_crm="no" fi dnl None of the following items build without the CRM available enable_mgmt=no enable_dopd=no enable_cim_provider=no fi AC_SUBST(CRM_DIR) AC_MSG_NOTICE([whether to enable the Cluster Resource Manager... ${enable_crm}]) AM_CONDITIONAL(CRM_BUILD, test "x${enable_crm}" = "xyes") AC_SUBST(CRM_ENABLED) dnl lrm configuration AC_ARG_ENABLE([lrm], [ --enable-lrm Compile the new Local Resource Manager. [default=yes]], [], [enable_lrm=yes]) LRM_ENABLED=0 if test "x${enable_crm}" = "xyes"; then if test "x${enable_lrm}" = "xno"; then AC_MSG_WARN([crm enabled, overriding --enable-lrm=no with --enable-lrm=yes]) elif test -z "${enable_lrm}"; then AC_MSG_WARN([crm enabled, defaulting to --enable-lrm=yes]) fi enable_lrm="yes" elif test -z "${enable_lrm}"; then enable_lrm="no" fi if test "x${enable_lrm}" = "xyes"; then LRM_ENABLED=1 fi AC_SUBST(LRM_ENABLED) AM_CONDITIONAL(LRM_BUILD, test "x${enable_lrm}" = "xyes") AC_MSG_NOTICE([whether to enable the Local Resource Manager... ${enable_lrm}]) dnl ************************************************************************ dnl management and quorum daemons. AC_CHECK_HEADERS(gnutls/gnutls.h) AC_CHECK_HEADERS(security/pam_appl.h pam/pam_appl.h) dnl GNUTLS library: Attempt to determine by 'libgnutls-config' program. dnl If no 'libgnutls-config', try traditional autoconf means. AC_PATH_PROGS(LIBGNUTLS_CONFIG, libgnutls-config) if test -n "$LIBGNUTLS_CONFIG"; then AC_MSG_CHECKING(for gnutls header flags) GNUTLSHEAD="`$LIBGNUTLS_CONFIG --cflags`"; AC_MSG_RESULT($GNUTLSHEAD) AC_MSG_CHECKING(for gnutls library flags) GNUTLSLIBS="`$LIBGNUTLS_CONFIG --libs`"; AC_MSG_RESULT($GNUTLSLIBS) else AC_CHECK_LIB(gnutls, gnutls_init) fi AC_SUBST(GNUTLSHEAD) AC_SUBST(GNUTLSLIBS) dnl management tool configuration AC_ARG_ENABLE([mgmt], [ --enable-mgmt Compile the management tool. [default=try]], [], [enable_mgmt=try]) if test "x${enable_mgmt}" != "xno"; then MGMT_ENABLED=1 if test "x${enable_mgmt}" = "xtry"; then MISSING_FN="WarnMissingThing" else MISSING_FN="FatalMissingThing" fi AM_CHECK_PYTHON_HEADERS(,PYTHON_INCLUDES='') AC_SUBST(PYTHON_INCLUDES) if test "x${PYTHON_INCLUDES}" = "x"; then $MISSING_FN "Python.h" \ "The GUI managment module needs Python.h (Linux: python-devel package)" enable_mgmt="no" MGMT_ENABLED=0 fi if test "$ac_cv_header_security_pam_appl_h" = "no" -a "$ac_cv_header_pam_pam_appl_h" = "no"; then $MISSING_FN "security/pam_appl.h" \ "The GUI managment module needs the pam-devel package" enable_mgmt="no" MGMT_ENABLED=0 fi if test "$ac_cv_header_gnutls_gnutls_h" = "no"; then $MISSING_FN "gnutls/gnutls.h" \ "The GUI managment module needs GNU/TLS header files" enable_mgmt="no" MGMT_ENABLED=0 fi if test -z "$LIBGNUTLS_CONFIG"; then $MISSING_FN "libgnutls-config" \ "The GUI managment module needs libgnutls-config" enable_mgmt="no" MGMT_ENABLED=0 fi if test -z "$SWIG"; then $MISSING_FN "swig" \ "The GUI managment module needs swig" \ "You can get it from http://swig.org/" enable_mgmt="no" MGMT_ENABLED=0 fi fi if test "x${enable_mgmt}" != "xno"; then RPM_ENABLE_MGMT_CONFIG=1 else RPM_ENABLE_MGMT_CONFIG=0 fi AC_SUBST(RPM_ENABLE_MGMT_CONFIG) AM_CONDITIONAL(MGMT_BUILD, test "x${enable_mgmt}" != "xno") if test "x${enable_mgmt}" != "xno"; then AC_DEFINE_UNQUOTED(MGMT_ENABLED, 1, Define to 1 if the mgmt-daemon and friends are enabled.) dnl If this system might be RPM-based, then adjust some RPM-build details if test x"${RPM}" != x""; then dnl FIXME: a flawy solution but no better one now if rpm -q python-gtk > /dev/null; then RPM_MGMT_RUNTIME_REQUIRES="libglade2, python-gtk"; else RPM_MGMT_RUNTIME_REQUIRES="libglade2, pygtk2"; fi else RPM_MGMT_RUNTIME_REQUIRES= fi else RPM_MGMT_RUNTIME_REQUIRES= fi AC_SUBST(RPM_MGMT_RUNTIME_REQUIRES) AC_MSG_NOTICE([whether to enable the management tool... ${enable_mgmt}]) dnl quorum server configuration AC_ARG_ENABLE([quorumd], [ --enable-quorumd Compile the quorum server. [default=try]], [], [enable_quorumd=try]) if test "x${enable_quorumd}" != "xno"; then QUORUMD_ENABLED=1 if test "x${enable_quorumd}" = "xtry"; then MISSING_FN="WarnMissingThing" else MISSING_FN="FatalMissingThing" fi if test "$ac_cv_header_gnutls_gnutls_h" = "no"; then $MISSING_FN "gnutls/gnutls.h" \ "The quorum server module needs GNU/TLS header files" enable_quorumd="no" QUORUMD_ENABLED=0 fi if test -z "$LIBGNUTLS_CONFIG"; then $MISSING_FN "libgnutls-config" \ "The quorum server module needs libgnutls-config" enable_quorumd="no" QUORUMD_ENABLED=0 fi fi AC_SUBST(QUORUMD_ENABLED) AM_CONDITIONAL(QUORUMD_BUILD, test "x${enable_quorumd}" != "xno") AC_MSG_NOTICE([whether to enable the quorum server... ${enable_quorumd}]) dnl ********************************************** dnl TSA plugin configuration dnl ********************************************** AC_ARG_ENABLE([tsa-plugin], [ --enable-tsa-plugin Enable TSA plugin. [default=no]], [], [enable_tsa_plugin=no]) AC_ARG_WITH([JAVA_HOME], [ --with-java-home JAVA_HOME dir], [], []) AC_ARG_WITH([TSA_DIR], [ --with-tsa-dir TSA diretory, default = /opt/IBM/tsamp/], [], []) JAVA_HOME=${with_java_home} TSA_DIR=${with_tsa_dir} if test "x${enable_tsa_plugin}" != "xno"; then if test "x${JAVA_HOME}" = "x"; then JAVA_BIN=`which java` JAVA_BIN_DIR=`dirname ${JAVA_BIN}` JAVA_HOME=`dirname ${JAVA_BIN_DIR}` fi if test "x${TSA_DIR}" = "x"; then TSA_DIR="/opt/IBM/tsamp/" fi fi AC_SUBST(JAVA_HOME) AC_SUBST(TSA_DIR) AM_CONDITIONAL(TSA_PLUGIN_BUILD, test "x${enable_tsa_plugin}" != "xno") dnl ********************************************** dnl drbd peer outdate plugin configuration dnl ********************************************** case "$host_os" in *linux*) AC_ARG_ENABLE([dopd], [ --enable-dopd Compile the Drbd Outdate Peer Daemon and tools. [default=yes]], [], [enable_dopd=yes]) ;; *) enable_dopd=no ;; esac AM_CONDITIONAL(BUILD_DRBD_OUTDATE_PEER, test "x${enable_dopd}" != "xno") hb_libdir="${libdir}/${HB_PKG}" AC_SUBST(hb_libdir) HA_PLUGIN_DIR="${hb_libdir}/plugins" AC_SUBST(HA_PLUGIN_DIR) AC_DEFINE_UNQUOTED(HA_PLUGIN_DIR,"$HA_PLUGIN_DIR", PILS plugin dir) LRM_PLUGIN_DIR="${hb_libdir}/plugins/RAExec" AC_SUBST(LRM_PLUGIN_DIR) AC_DEFINE_UNQUOTED(LRM_PLUGIN_DIR,"$LRM_PLUGIN_DIR", LRM plugin dir) HB_RA_DIR="${sysconfdir}/ha.d/resource.d/" AC_SUBST(HB_RA_DIR) AC_DEFINE_UNQUOTED(HB_RA_DIR,"$HB_RA_DIR", Location for v1 Heartbeat v1 RAs) dnl ************ OCF (Open Cluster Framework) ********************** dnl Must be consistent with remainder of platform (analogy with "initdir"). OCF_ROOT_DIR="/usr/lib/ocf" AC_ARG_WITH(ocf-root, [ --with-ocf-root=DIR directory for OCF scripts [${OCF_ROOT_DIR}]], [ if test x"$withval" = xprefix; then OCF_ROOT_DIR=${prefix}; else OCF_ROOT_DIR="$withval"; fi ]) if test "X$OCF_ROOT_DIR" = X; then FatalMissingThing "OCF directory" "Could not locate OCF directory" fi AC_SUBST(OCF_ROOT_DIR) AC_DEFINE_UNQUOTED(OCF_ROOT_DIR,"$OCF_ROOT_DIR", OCF root dir) OCF_RA_DIR="${OCF_ROOT_DIR}/resource.d/" AC_SUBST(OCF_RA_DIR) AC_DEFINE_UNQUOTED(OCF_RA_DIR,"$OCF_RA_DIR", Location for OCF RAs) LSB_RA_DIR="${INITDIR}" AC_SUBST(LSB_RA_DIR) AC_DEFINE_UNQUOTED(LSB_RA_DIR,"$LSB_RA_DIR", Location for LSB RAs) STONITH_RA_DIR="${hb_libdir}/stonith.d/" AC_SUBST(STONITH_RA_DIR) AC_DEFINE_UNQUOTED(STONITH_RA_DIR,"$STONITH_RA_DIR", Location for STONITH RAs) AC_ARG_ENABLE([valgrind], [ --enable-valgrind "Run selected heartbeat components using Valgrind." [default=no]], [], [enable_valgrind=no]) AC_ARG_WITH(valgrind-log, [ --with-valgrind-log=options Logging options to pass to valgrind], [ VALGRIND_LOG="$withval" ], []) AC_ARG_WITH(valgrind-suppress, [ --with-valgrind-suppress=file Name of a suppression file to pass to Valgrind [default=/dev/null]], [ VALGRIND_SUPP="$withval" ], [ VALGRIND_SUPP="/dev/null" ]) if test "x" = "x$VALGRIND_LOG"; then VALGRIND_LOG="--log-socket=127.0.0.1:1234" AC_MSG_NOTICE(Set default Valgrind options to: $VALGRIND_OPTS) AC_MSG_NOTICE(Remember to start a receiver on localhost:1234) fi AC_PATH_PROG(VALGRIND_BIN, valgrind) if test "xyes" = "x$enable_valgrind" -a "x$VALGRIND_BIN" != "x"; then enable_libc_malloc=yes fi AC_DEFINE_UNQUOTED(VALGRIND_BIN, "$VALGRIND_BIN", Valgrind command) AC_DEFINE_UNQUOTED(VALGRIND_LOG, "$VALGRIND_LOG", Valgrind logging options) AC_DEFINE_UNQUOTED(VALGRIND_SUPP, "$VALGRIND_SUPP", Name of a suppression file to pass to Valgrind) AC_ARG_ENABLE([libc-malloc], [ --enable-libc-malloc Use libc malloc instead of Heartbeat's custom one. [default=no]], [], [enable_libc_malloc=no]) if test "xyes" = "x$enable_libc_malloc" -o "x1" = "x$enable_libc_malloc"; then AC_DEFINE_UNQUOTED(CL_USE_LIBC_MALLOC, 1, Use libc malloc instead of Heartbeat's custom one.) fi dnl ********************************************************************** dnl 'AWK' had been determined via 'aclocal.m4' as the simple name, using dnl the current PATH (i.e. in the context of 'configure'). dnl dnl Things within heartbeat will use 'AWK', but from a different context, dnl so we should determine, and substitute, the full path. dnl dnl Note: Even that may have a flaw, e.g. if 'configure' finds (say) 'gawk', dnl which we here convert to '/path/to/gawk', but the run-time machine lacks it. dnl We won't worry about that for now. dnl (David Lee; March 2007) AC_PATH_PROGS([AWK], $AWK) dnl ********************************************************************** dnl Enable optional, experimental directories here... dnl XPERIMENTALDIRS="" AC_SUBST(XPERIMENTALDIRS) CheckMissingThings dnl Options for cleaning up the compiler output PRETTY_CC="" QUIET_LIBTOOL_OPTS="" QUIET_MAKE_OPTS="" if test x"${enable_pretty}" = "xyes"; then enable_quiet="yes" echo "install_sh: ${install_sh}" PRETTY_CC="`pwd`/tools/ccdv" dnl It would be nice if this was rebuilt when needed too... mkdir `pwd`/tools/ 2>/dev/null gcc $CFLAGS -o `pwd`/tools/ccdv ${srcdir}/tools/ccdv.c CC="\$(PRETTY_CC) ${CC}" fi if test "x${enable_quiet}" = "xyes"; then QUIET_LIBTOOL_OPTS="--quiet" QUIET_MAKE_OPTS="--quiet" fi AC_MSG_RESULT(Supressing make details: ${enable_quiet}) AC_MSG_RESULT(Pretty printing of compiler output: ${enable_pretty}) dnl Put the above variables to use LIBTOOL="${LIBTOOL} --tag=CC \$(QUIET_LIBTOOL_OPTS)" MAKE="${MAKE} \$(QUIET_MAKE_OPTS)" AC_SUBST(CC) AC_SUBST(MAKE) AC_SUBST(LIBTOOL) AC_SUBST(PRETTY_CC) AC_SUBST(QUIET_MAKE_OPTS) AC_SUBST(QUIET_LIBTOOL_OPTS) dnl *** "echo" adjustments (begin) *** dnl Some run-time scripts require options to "echo". dnl This configure is already determining and using "ac_n" and "ac_c" dnl for internal use, so make available externally. dnl (Not sure how "future proof" this is, but it at least seems clean.) dnl dnl This must be close to the end of "configure.in" otherwise it interferes dnl with output from the AC_MSG_*() macros. ECHO_N="$ac_n" ECHO_C="$ac_c" case $ac_n in -n) ECHO_E="-e";; *) ECHO_E="";; esac ECHO_CMD="echo" if test -x /usr/linux/bin/echo then # This is for AIX. I'm not sure it's necessary... ECHO_CMD="/usr/linux/bin/echo" ECHO_N="-n" ECHO_E="-e" fi AC_SUBST(ECHO_N) AC_SUBST(ECHO_C) AC_SUBST(ECHO_E) AC_SUBST(ECHO_CMD) dnl *** "echo" adjustments (end) *** dnl The Makefiles and shell scripts we output AC_CONFIG_FILES(heartbeat.spec \ Makefile \ README \ logd/Makefile \ config/Makefile \ cts/Makefile \ cts/CM_fs.py \ cts/CM_hb.py \ cts/CTS.py \ cts/CTSaudits.py \ cts/CTSlab.py \ cts/CTStests.py \ cts/CM_LinuxHAv2.py \ cts/CTSproxy.py \ cts/extracttests.py \ cts/OCFIPraTest.py \ cts/CIB.py \ cts/LSBDummy \ crm/Makefile \ crm/cib/Makefile \ crm/crmd/Makefile \ crm/pengine/Makefile \ crm/tengine/Makefile \ crm/admin/Makefile \ crm/admin/crm_primitive.py \ crm/admin/crm_sh \ crm/admin/crm_utils.py \ crm/admin/crm_commands.py \ debian/Makefile \ doc/Makefile \ doc/startstop \ doc/cibadmin.8 \ doc/crm_resource.8 \ contrib/Makefile \ contrib/ipfail/Makefile \ contrib/mlock/Makefile \ contrib/drbd-outdate-peer/Makefile \ include/Makefile \ include/clplumbing/Makefile \ include/crm/Makefile \ include/crm/common/Makefile \ include/crm/pengine/Makefile \ include/lrm/Makefile \ include/mgmt/Makefile \ include/ocf/Makefile \ include/pils/Makefile \ include/pils/plugin.h \ include/saf/Makefile \ include/stonith/Makefile \ include/fencing/Makefile \ replace/Makefile \ lib/Makefile \ lib/apphb/Makefile \ lib/clplumbing/Makefile \ lib/hbclient/Makefile \ lib/crm/Makefile \ lib/crm/common/Makefile \ lib/crm/cib/Makefile \ lib/crm/pengine/Makefile \ lib/crm/transition/Makefile \ lib/lrm/Makefile \ lib/mgmt/Makefile \ lib/pils/Makefile \ lib/plugins/Makefile \ lib/plugins/InterfaceMgr/Makefile \ lib/plugins/HBauth/Makefile \ lib/plugins/HBcomm/Makefile \ lib/plugins/lrm/Makefile \ lib/plugins/stonith/Makefile \ lib/plugins/stonith/ribcl.py \ lib/plugins/stonith/external/Makefile \ lib/plugins/stonith/external/ibmrsa \ lib/plugins/stonith/external/riloe \ lib/plugins/stonith/external/ssh \ lib/plugins/AppHBNotification/Makefile \ lib/plugins/HBcompress/Makefile \ lib/plugins/quorum/Makefile \ lib/plugins/quorumd/Makefile \ lib/plugins/tiebreaker/Makefile \ lib/recoverymgr/Makefile \ lib/stonith/Makefile \ lib/fencing/Makefile \ lrm/Makefile \ lrm/lrmd/Makefile \ lrm/admin/Makefile \ lrm/test/LRMBasicSanityCheck \ lrm/test/Makefile \ lrm/test/simple_ops \ mgmt/Makefile \ mgmt/daemon/Makefile \ mgmt/client/Makefile \ mgmt/client/haclient.py \ mgmt/client/mgmtcmd.py \ heartbeat/Makefile \ heartbeat/rc.d/Makefile \ heartbeat/rc.d/ask_resources \ heartbeat/rc.d/hb_takeover \ heartbeat/init.d/Makefile \ heartbeat/init.d/heartbeat \ heartbeat/lib/Makefile \ heartbeat/lib/BasicSanityCheck \ heartbeat/lib/ha_config \ heartbeat/lib/ha_propagate \ heartbeat/lib/hb_standby \ heartbeat/lib/mach_down \ heartbeat/lib/req_resource \ heartbeat/lib/ResourceManager \ heartbeat/lib/TestHeartbeatComm \ heartbeat/lib/hb_takeover \ heartbeat/lib/hb_addnode \ heartbeat/lib/hb_delnode \ heartbeat/lib/hb_setweight \ heartbeat/lib/hb_setsite \ heartbeat/shellfuncs \ heartbeat/libnet_util/Makefile \ heartbeat/logrotate.d/Makefile \ ldirectord/Makefile \ ldirectord/ldirectord \ ldirectord/init.d/Makefile \ ldirectord/init.d/ldirectord \ ldirectord/logrotate.d/Makefile \ membership/Makefile \ membership/ccm/Makefile \ membership/quorumd/Makefile \ pkg/Makefile \ pkg/InfoFiles/pkginfo \ pkg/InfoFiles/preinstall \ pkg/InfoFiles/postinstall \ port/Makefile \ port/portMakefile \ port/heartbeat/pkg-deinstall \ port/heartbeat/pkg-descr \ port/heartbeat/pkg-install \ port/heartbeat/pkg-plist \ snmp_subagent/Makefile \ snmp_subagent/SNMPAgentSanityCheck \ cim/Makefile \ cim/mof/Makefile \ cim/mof/register_providers.sh \ cim/mof/unregister_providers.sh \ tsa_plugin/Makefile \ tsa_plugin/testrun.sh \ tsa_plugin/linuxha-adapter \ telecom/Makefile \ telecom/apphbd/Makefile \ telecom/recoverymgrd/Makefile \ fencing/Makefile \ fencing/stonithd/Makefile \ fencing/test/Makefile \ fencing/test/STONITHDBasicSanityCheck \ tools/Makefile \ tools/haresources2cib.py \ resources/Makefile \ resources/OCF/Makefile \ resources/OCF/ocf-shellfuncs \ resources/OCF/ClusterMon \ resources/OCF/Dummy \ resources/OCF/pingd \ resources/OCF/apache \ resources/OCF/AudibleAlarm \ resources/OCF/Delay \ resources/OCF/db2 \ resources/OCF/drbd \ resources/OCF/EvmsSCC \ + resources/OCF/Evmsd \ resources/OCF/Filesystem \ resources/OCF/ICP \ resources/OCF/IPaddr \ resources/OCF/IPaddr2 \ resources/OCF/IPsrcaddr \ resources/OCF/LinuxSCSI \ resources/OCF/LVM \ resources/OCF/MailTo \ resources/OCF/ManageRAID \ resources/OCF/ManageVE \ resources/OCF/mysql \ resources/OCF/oracle \ resources/OCF/oralsnr \ resources/OCF/portblock \ resources/OCF/Raid1 \ resources/OCF/rsyncd \ resources/OCF/pgsql \ resources/OCF/Pure-FTPd \ resources/OCF/SAPDatabase \ resources/OCF/SAPInstance \ resources/OCF/SendArp \ resources/OCF/ServeRAID \ resources/OCF/Stateful \ resources/OCF/SysInfo \ resources/OCF/VIPArip \ resources/OCF/WAS \ resources/OCF/WAS6 \ resources/OCF/WinPopup \ resources/OCF/Xen \ resources/OCF/Xinetd \ resources/heartbeat/Makefile \ resources/heartbeat/apache \ resources/heartbeat/AudibleAlarm \ resources/heartbeat/Delay \ resources/heartbeat/db2 \ resources/heartbeat/Filesystem \ resources/heartbeat/hto-mapfuncs \ resources/heartbeat/ICP \ resources/heartbeat/IPaddr \ resources/heartbeat/IPaddr2 \ resources/heartbeat/IPsrcaddr \ resources/heartbeat/IPv6addr \ resources/heartbeat/LinuxSCSI \ resources/heartbeat/LVM \ resources/heartbeat/LVSSyncDaemonSwap \ resources/heartbeat/MailTo \ resources/heartbeat/OCF \ resources/heartbeat/portblock \ resources/heartbeat/Raid1 \ resources/heartbeat/ServeRAID \ resources/heartbeat/SendArp \ resources/heartbeat/WAS \ resources/heartbeat/WinPopup \ resources/heartbeat/Xinetd \ ) dnl Now process the entire list of files added by previous dnl calls to AC_CONFIG_FILES() AC_OUTPUT() dnl subpackages configuration - perhaps configure it properly some other time dnl when it has been discussed at linux-ha-dev dnl AC_CONFIG_SUBDIRS(stonith heartbeat) dnl ***************** dnl Configure summary dnl ***************** eval my_datadir="`eval echo ${datadir}`" eval my_includedir="`eval echo ${includedir}`" eval my_initdir="${INITDIR}" eval my_libdir="`eval echo ${libdir}`" eval my_localstatedir="`eval echo ${localstatedir}`" eval my_mandir="`eval echo ${mandir}`" eval my_sbindir="`eval echo ${sbindir}`" eval my_sysconfdir="`eval echo ${sysconfdir}`" AC_MSG_RESULT([]) AC_MSG_RESULT([$PACKAGE configuration:]) AC_MSG_RESULT([ Version = "$VERSION"]) AC_MSG_RESULT([ Executables = "$my_sbindir"]) AC_MSG_RESULT([ Man pages = "$my_mandir"]) AC_MSG_RESULT([ Libraries = "$my_libdir"]) AC_MSG_RESULT([ Header files = "$my_includedir"]) AC_MSG_RESULT([ Data files = "$my_datadir"]) AC_MSG_RESULT([ State information = "$my_localstatedir"]) AC_MSG_RESULT([ System configuration = "$my_sysconfdir"]) AC_MSG_RESULT([ Init (rc) scripts = "$my_initdir"]) AC_MSG_RESULT([ Use system LTDL = "${ac_cv_lib_ltdl_lt_dlopen}"]) AC_MSG_RESULT([ HA group name = "${HA_APIGROUP}"]) AC_MSG_RESULT([ HA group id = "${HA_APIGID}"]) AC_MSG_RESULT([ HA user name = "${HA_CCMUSER}"]) AC_MSG_RESULT([ HA user user id = "${HA_CCMUID}"]) AC_MSG_RESULT([ Build snmp subagent = "${enable_snmp_subagent}"]) if test "x${enable_snmp_subagent}" = "xyes"; then AC_MSG_RESULT([ SNMP MIB directory = "${MIBS_DIR}"]) AC_MSG_RESULT([ SNMP agent libraries = "${SNMPAGENTLIB}"]) fi AC_MSG_RESULT([ SNMP libraries = "${SNMPLIB}"]) AC_MSG_RESULT([ ucd_snmp_devel name = "${UCDSNMPDEVEL}"]) AC_MSG_RESULT([ Build New CRM = "${enable_crm}"]) AC_MSG_RESULT([ Build New LRM = "${enable_lrm}"]) AC_MSG_RESULT([ Build Ldirectord = "${enable_ldirectord}"]) AC_MSG_RESULT([ Build CIM providers = "${enable_cim_provider}"]) if test "x${enable_cim_provider}" = "xyes"; then AC_MSG_RESULT([ CIM server = "${CIMOM}"]) AC_MSG_RESULT([ CIM providers dir = "${CMPI_PROVIDER_DIR}"]) AC_MSG_RESULT([ CMPI header files = "${CMPI_HEADER_PATH}"]) fi AC_MSG_RESULT([ Build TSA plugin = "${enable_tsa_plugin}"]) if test "x${enable_tsa_plugin}" != "xno"; then AC_MSG_RESULT([ JAVA_HOME = "${JAVA_HOME}"]) AC_MSG_RESULT([ TSA_DIR = "${TSA_DIR}"]) fi AC_MSG_RESULT([ Build dopd plugin = "${enable_dopd}"]) AC_MSG_RESULT([ Enable times kludge = "${enable_times_kludge}"]) AC_SUBST(DISABLE_TIMES_KLUDGE) AC_MSG_RESULT([ CC_WARNINGS = "${CC_WARNINGS}"]) AC_MSG_RESULT([ Mangled CFLAGS = "${CFLAGS}"]) AC_MSG_RESULT([ Libraries = "${LIBS}"]) diff --git a/heartbeat/AudibleAlarm.in b/heartbeat/AudibleAlarm.in index 38a6ce60c..69a0986e7 100644 --- a/heartbeat/AudibleAlarm.in +++ b/heartbeat/AudibleAlarm.in @@ -1,186 +1,186 @@ #!/bin/sh # # Startup script for the Audible Alarm # # author: Kirk Lawson # Horms # # description: sets an audible alarm running by beeping at a set interval # processname: alarm # config: /etc/AudibleAlarm/AudibleAlarm.conf - not yet implemented # # OCF parameters are as below: # OCF_RESKEY_nodelist # # License: GNU General Public License (GPL) ####################################################################### # Source function library. . @hb_libdir@/ocf-shellfuncs ####################################################################### -PIDFILE=@localstatedir@/run/heartbeat-bell +PIDFILE=@HA_VARRUNDIR@/heartbeat-bell #For testing #PIDFILE=/tmp/heartbeat-bell # What host are we running on? us=`uname -n` usage() { echo "Usage: $0 {start|stop|restart|status|monitor|meta-data|validate-all}" echo " The node list is an optional space delimited" echo " list of hosts that should never sound the alarm." } meta_data() { cat < 1.0 Resource script for AudibleAlarm. It sets an audible alarm running by beeping at a set interval. AudibleAlarm resource agent The node list that should never sound the alarm. Node list END } audiblealarm_start () { ocf_log info "$0: Starting" if [ -f $PIDFILE ]; then PID=`head -n 1 $PIDFILE` if [ -n "$PID" ]; then ocf_log info "$0: Appears to already be running, killing [$PID]" kill $PID > /dev/null fi fi # Use () to create a subshell to make the redirection be synchronized. ( while [ 1 ]; do sleep 1 #Sleep first, incase we bail out echo -ne "\a" > /dev/console # Uncomment this line to cause floppy drive light # to flash (requires fdutils package). # /usr/bin/floppycontrol --pollstate > /dev/null # # To avoid issues when called by lrmd, redirect stdout->stderr. done & if echo $! > $PIDFILE; then : else ocf_log info "$0: Could not write to pid file \"$PIDFILE\", bailing" kill $! return $OCF_ERR_GENERIC fi) >&2 return $? } audiblealarm_stop () { ocf_log info "$0: Shutting down" if [ -f $PIDFILE ]; then PID=`head -n 1 $PIDFILE` # ocf_log info "$0: Appears to already be running, killing [$PID]" # commented by Phost, since the confusion in the log. if [ -n "$PID" ]; then # Donnot remove PIDFILE in case the `kill` fails. kill $PID > /dev/null && rm -f $PIDFILE fi fi return $? } audiblealarm_restart () { audiblealarm_stop audiblealarm_start return $? } audiblealarm_status () { if [ -f $PIDFILE ]; then PID=`head -n 1 $PIDFILE` if [ -n "$PID" ]; then echo running return $OCF_SUCCESS fi fi echo stopped return $OCF_NOT_RUNNING } audiblealarm_validate_all () { # Is there anything to check? echo "Validate OK" return $OCF_SUCCESS } if [ $# -ne 1 ]; then usage exit $OCF_ERR_ARGS fi case "$1" in meta-data) meta_data exit $OCF_SUCCESS ;; start) for arg in "$OCF_RESKEY_nodelist" do if [ "$us" = "$arg" ]; then # We should not start because we are on a host # listed in our argument list. exit $OCF_SUCCESS fi done audiblealarm_start ;; stop) audiblealarm_stop ;; restart) audiblealarm_restart ;; status|monitor) audiblealarm_status ;; validate-all) audiblealarm_validate_all ;; usage) usage exit $OCF_SUCCESS ;; *) usage exit $OCF_ERR_ARGS ;; esac exit $? diff --git a/heartbeat/Delay.in b/heartbeat/Delay.in index 1c1e1c2d0..eb72e3d82 100644 --- a/heartbeat/Delay.in +++ b/heartbeat/Delay.in @@ -1,225 +1,225 @@ #!/bin/sh # # # Support: linux-ha@lists.linux-ha.org # License: GNU General Public License (GPL) # # This script is a test resource for introducing delay. # # usage: $0 {start|stop|status|monitor|meta-data} # # OCF parameters are as below: # OCF_RESKEY_startdelay # OCF_RESKEY_stopdelay # OCF_RESKEY_mondelay # # # OCF_RESKEY_startdelay defaults to 30 (seconds) # OCF_RESKEY_stopdelay defaults to $OCF_RESKEY_startdelay # OCF_RESKEY_mondelay defaults to $OCF_RESKEY_startdelay # # # This is really a test resource script. # ####################################################################### # Initialization: . @hb_libdir@/ocf-shellfuncs ####################################################################### -HA_VARRUNDIR=@localstatedir@/run/@HB_PKG@ -VLFILE="$HA_VARRUNDIR/rsctmp/Delay-${OCF_RESOURCE_INSTANCE}" +HA_VARRUNHBRSCDIR=@HA_VARRUNHBRSCDIR@ +VLFILE="$HA_VARRUNHBRSCDIR/Delay-${OCF_RESOURCE_INSTANCE}" usage() { cat <<-! usage: $0 {start|stop|status|monitor|meta-data|validate-all} ! } meta_data() { cat < 1.0 This script is a test resource for introducing delay. Delay resource agent How long in seconds to delay on start operation. Start delay How long in seconds to delay on stop operation. Defaults to "startdelay" if unspecified. Stop delay How long in seconds to delay on monitor operation. Defaults to "startdelay" if unspecified. Monitor delay END } Delay_stat() { test -f "$VLFILE" } Delay_Status() { if Delay_stat then ocf_log info "Delay is running OK" return $OCF_SUCCESS else ocf_log info "Delay is stopped" return $OCF_NOT_RUNNING fi } Delay_Monitor() { Delay_Validate_All -q sleep $OCF_RESKEY_mondelay Delay_Status } Delay_Start() { if Delay_stat then ocf_log info "Delay already running." return $OCF_SUCCESS else Delay_Validate_All -q touch "$VLFILE" rc=$? sleep $OCF_RESKEY_startdelay if [ $rc -ne 0 ] then return $OCF_ERR_PERM fi return $OCF_SUCCESS fi } Delay_Stop() { if Delay_stat then Delay_Validate_All -q unlink "$VLFILE" rc=$? sleep $OCF_RESKEY_stopdelay if [ $rc -ne 0 ] then return $OCF_ERR_PERM fi return $OCF_SUCCESS else ocf_log info "Delay already stopped." return $OCF_SUCCESS fi } # Check if all the arguments are valid numbers, a string is considered valid if: # 1. It does not contain any character but digits and period "."; # 2. The period "." does not occur more than once Are_Valid_Numbers() { for i in "$@"; do echo $i |grep -v [^0-9.] |grep -q -v [.].*[.] if test $? -ne 0; then return $OCF_ERR_ARGS fi done return $OCF_SUCCESS } Delay_Validate_All() { # Be quiet when specified -q option _and_ validation succeded getopts "q" option if test $option = "q"; then quiet=yes else quiet=no fi shift $(($OPTIND -1)) if Are_Valid_Numbers $OCF_RESKEY_startdelay $OCF_RESKEY_stopdelay \ $OCF_RESKEY_mondelay; then if test $quiet = "no"; then echo "Validate OK" fi # _Return_ on validation success return $OCF_SUCCESS else echo "Some of the instance parameters are invalid" # _Exit_ on validation failure exit $OCF_ERR_ARGS fi } if [ $# -ne 1 ]; then usage exit $OCF_ERR_ARGS fi : ${OCF_RESKEY_startdelay=30} : ${OCF_RESKEY_stopdelay=$OCF_RESKEY_startdelay} : ${OCF_RESKEY_mondelay=$OCF_RESKEY_startdelay} case $1 in meta-data) meta_data exit $OCF_SUCCESS ;; start) Delay_Start ;; stop) Delay_Stop ;; monitor) Delay_Monitor ;; status) Delay_Status ;; validate-all) Delay_Validate_All ;; usage) usage exit $OCF_SUCCESS ;; *) usage exit $OCF_ERR_ARGS ;; esac exit $? diff --git a/heartbeat/Dummy.in b/heartbeat/Dummy.in index 0b31f8875..7ffef4b37 100644 --- a/heartbeat/Dummy.in +++ b/heartbeat/Dummy.in @@ -1,159 +1,159 @@ #!/bin/sh # # # Dummy OCF RA. Does nothing but wait a few seconds, can be # configured to fail occassionally. # # Copyright (c) 2004 SUSE LINUX AG, Lars Marowsky-Brée # 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. # ####################################################################### # Initialization: . @hb_libdir@/ocf-shellfuncs ####################################################################### meta_data() { cat < 1.0 This is a Dummy Resource Agent. It does absolutely nothing except wait for various amounts of time on execution. Dummy resource agent How long to delay before each action. Action delay Location to store the resource state in State file - + END } ####################################################################### dummy_usage() { cat < + + +1.0 + + +This is a Evmsd Resource Agent. + +Evmsd resource agent + + + + + + + + +END +} + +####################################################################### + +evmsd_usage() { + cat < 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 < 1.0 This script manages IP alias IP addresses It can add an IP alias, or remove one. Manages virtual IPv4 addresses The IPv4 address to be configured in dotted quad notation, for example "192.168.1.1". IPv4 address The base network interface on which the IP address will be brought online. If left empty, the script will try and determine this from the routing table. Do NOT specify an alias interface in the form eth0:1 or anything here; rather, specify the base interface only. Network interface The netmask for the interface in CIDR format. (ie, 24), or in dotted quad notation 255.255.255.0). If unspecified, the script will also try to determine this from the routing table. Netmask Broadcast address associated with the IP. If left empty, the script will determine this from the netmask. Broadcast address You can specify an additional label for your IP address here. Interface label Enable support for LVS Direct Routing configurations. In case a IP address is stopped, only move it to the loopback device to allow the local node to continue to service requests, but no longer advertise it on the network. Enable support for LVS DR Script called when the IP is released Script called when the IP is released Script called when the IP is added Script called when the IP is added milliseconds between ARPs milliseconds between gratuitous ARPs How many gratuitous ARPs to send out when bringing up a new address repeat count run in background (no longer any reason to do this) run in background netmask for ARP - in nonstandard hexadecimal format. netmask for ARP END exit $OCF_SUCCESS } # On Linux systems the (hidden) loopback interface may # conflict with the requested IP address. If so, this # unoriginal code will remove the offending loopback address # and save it in VLDIR so it can be added back in later # when the IPaddr is released. # lvs_remove_conflicting_loopback() { ipaddr="$1" ifname="$2" ocf_log info "Removing conflicting loopback $ifname." if echo $ifname > "$VLDIR/$ipaddr" then : Saved loopback information in $VLDIR/$ipaddr else ocf_log err "Could not save conflicting loopback $ifname." \ "it will not be restored." fi delete_interface "$ifname $ipaddr" # Forcibly remove the route (if it exists) to the loopback. delete_route "$ipaddr" } # # On Linux systems the (hidden) loopback interface may # need to be restored if it has been taken down previously # by lvs_remove_conflicting_loopback() # lvs_restore_loopback() { ipaddr="$1" if [ ! -s "$VLDIR/$ipaddr" ]; then return fi ifname=`cat "$VLDIR/$ipaddr"` ocf_log info "Restoring loopback IP Address $ipaddr on $ifname." CMD="OCF_RESKEY_cidr_netmask=32 OCF_RESKEY_ip=$1 OCF_RESKEY_nic=$ifname $FINDIF" if NICINFO=`eval $CMD` then netmask_text=`echo "$NICINFO" | cut -f2` broadcast=`echo "$NICINFO" | cut -f3` else echo "ERROR: $CMD failed (rc=$rc)" exit $OCF_ERR_GENERIC fi add_interface "$ipaddr" "$ifname" "$ifname" $netmask_text $broadcast rm -f "$VLDIR/$ipaddr" } # # Find out which alias serves the given IP address # The argument is an IP address, and its output # is an aliased interface name (e.g., "eth0:0"). # find_interface_solaris() { ipaddr="$1" $IFCONFIG $IFCONFIG_A_OPT | $AWK '{if ($0 ~ /.*: / && NR > 1) {print "\n"$0} else {print}}' | while read ifname linkstuff do : ifname = $ifname read inet addr junk : inet = $inet addr = $addr while read line && [ "X$line" != "X" ] do : Nothing done case $ifname in *:*) ;; *) continue;; esac # This doesn't look right for a box with multiple NICs. # It looks like it always selects the first interface on # a machine. Yet, we appear to use the results for this case too... ifname=`echo "$ifname" | sed s'%:$%%'` case $addr in addr:$ipaddr) echo $ifname; return $OCF_SUCCESS;; $ipaddr) echo $ifname; return $OCF_SUCCESS;; esac done return $OCF_ERR_GENERIC } find_interface_bsd() { #$IFCONFIG $IFCONFIG_A_OPT | grep "inet.*[: ]$OCF_RESKEY_ip " $IFCONFIG | grep "$ipaddr" -B20 | grep "UP," | tail -n 1 | cut -d ":" -f 1 } # # Find out which alias serves the given IP address # The argument is an IP address, and its output # is an aliased interface name (e.g., "eth0:0"). # find_interface_generic() { ipaddr="$1" $IFCONFIG $IFCONFIG_A_OPT | while read ifname linkstuff do : Read gave us ifname = $ifname read inet addr junk : Read gave us inet = $inet addr = $addr while read line && [ "X$line" != "X" ] do : Nothing done case $ifname in *:*) ;; *) continue;; esac : "comparing $ipaddr to $addr (from ifconfig)" case $addr in addr:$ipaddr) echo $ifname; return $OCF_SUCCESS;; $ipaddr) echo $ifname; return $OCF_SUCCESS;; esac done return $OCF_ERR_GENERIC } # # Find out which alias serves the given IP address # The argument is an IP address, and its output # is an aliased interface name (e.g., "eth0:0"). # find_interface() { ipaddr="$1" case "$SYSTYPE" in SunOS) NIC=`find_interface_solaris $ipaddr`;; *BSD) NIC=`find_interface_bsd $ipaddr`;; *) NIC=`find_interface_generic $ipaddr`;; esac echo $NIC return $OCF_SUCCESS; } # # Find an unused interface/alias name for us to use for new IP alias # The argument is an IP address, and the output # is an aliased interface name (e.g., "eth0:0", "dc0", "le0:0"). # find_free_interface() { NIC="$1" if [ "X$NIC" = "X" ]; then ocf_log err "No free interface found for $OCF_RESKEY_ip" return $OCF_ERR_GENERIC; fi NICBASE="$VLDIR/$NIC" touch "$NICBASE" case "$SYSTYPE" in *BSD) echo $NIC; return $OCF_SUCCESS;; SunOS) j=1 IFLIST=`$IFCONFIG $IFCONFIG_A_OPT | \ grep "^$NIC:[0-9]" | sed 's%: .*%%'`;; *) j=0 IFLIST=`$IFCONFIG $IFCONFIG_A_OPT | \ grep "^$NIC:[0-9]" | sed 's% .*%%'` TRYADRCNT=`ls "${NICBASE}:"* 2>/dev/null | wc -w | tr -d ' '` if [ -f "${NICBASE}:${TRYADRCNT}" ]; then : OK else j="${TRYADRCNT}" fi ;; esac IFLIST=" `echo $IFLIST` " while [ $j -lt 512 ] do case $IFLIST in *" "$NIC:$j" "*) ;; *) NICLINK="$NICBASE:$j" if ln "$NICBASE" "$NICLINK" 2>/dev/null then echo "$NIC:$j" return $OCF_SUCCESS fi ;; esac j=`expr $j + 1` done return $OCF_ERR_GENERIC } delete_route () { ipaddr="$1" case "$SYSTYPE" in SunOS) return 0;; *BSD) CMD="$ROUTE -n delete -host $ipaddr";; *) CMD="$ROUTE -n del -host $ipaddr";; esac $CMD return $? } delete_interface () { ifname="$1" ipaddr="$2" case "$SYSTYPE" in SunOS) if [ "$SYSVERSION" -ge 8 ] ; then CMD="$IFCONFIG $ifname unplumb" else CMD="$IFCONFIG $ifname 0 down" fi;; Darwin*) CMD="$IFCONFIG $ifname $ipaddr delete";; *BSD) CMD="$IFCONFIG $ifname inet $ipaddr delete";; *) CMD="$IFCONFIG $ifname down";; esac ocf_log info "$CMD" $CMD return $? } add_interface () { ipaddr="$1" iface_base="$2" iface="$3" netmask="$4" broadcast="$5" if [ $# != 5 ]; then ocf_log err "Insufficient arguments to add_interface: $*" exit $OCF_ERR_ARGS fi case "$SYSTYPE" in SunOS) if [ "$SYSVERSION" -ge 8 ] ; then $IFCONFIG $iface plumb rc=$? if [ $rc -ne 0 ] ; then echo "ERROR: '$IFCONFIG $iface plumb' failed." return $rc fi fi # At Solaris 10, this single-command version sometimes broke. # Almost certainly an S10 bug. # CMD="$IFCONFIG $iface inet $ipaddr $text up" # So hack the following workaround: CMD="$IFCONFIG $iface inet $ipaddr" CMD="$CMD && $IFCONFIG $iface $netmask" CMD="$CMD && $IFCONFIG $iface up" ;; *BSD) # netmask is always set to 255.255.255.255 for an alias CMD="$IFCONFIG $iface inet $ipaddr netmask 255.255.255.255 alias";; *) CMD="$IFCONFIG $iface $ipaddr netmask $netmask broadcast $broadcast";; esac # Use "eval $CMD" (not "$CMD"): it might be a chain of two or more commands. ocf_log info "eval $CMD" eval $CMD rc=$? if [ $rc != 0 ]; then echo "ERROR: eval $CMD failed (rc=$rc)" fi return $rc } # # Remove the IP alias for the requested IP address... # ip_stop() { SENDARPPIDFILE="$SENDARPPIDDIR/send_arp-$OCF_RESKEY_ip" NIC=`find_interface $OCF_RESKEY_ip` if [ -f "$SENDARPPIDFILE" ]; then cat "$SENDARPPIDFILE" | xargs kill rm -f "$SENDARPPIDFILE" fi if [ -z "$NIC" ]; then : Requested interface not in use return $OCF_SUCCESS fi if [ ${OCF_RESKEY_lvs_support} = 1 ]; then case $NIC in lo*) : Requested interface is on loopback return $OCF_SUCCESS;; esac fi delete_route "$OCF_RESKEY_ip" delete_interface "$NIC $OCF_RESKEY_ip" rc=$? if [ ${OCF_RESKEY_lvs_support} = 1 ]; then lvs_restore_loopback "$OCF_RESKEY_ip" fi # remove lock file... rm -f "$VLDIR/$NIC" if [ $rc != 0 ]; then ocf_log warn "IP Address $OCF_RESKEY_ip NOT released" fi return $rc } # # Add an IP alias for the requested IP address... # # It could be that we already have taken it, in which case it should # do nothing. # ip_start() { # # Do we already service this IP address? # ip_status_internal if [ $? = $OCF_SUCCESS ]; then # Nothing to do, the IP is already active return $OCF_SUCCESS; fi NIC_unique=`find_free_interface $OCF_RESKEY_nic` if [ -n "$NIC_unique" ]; then : OK got interface [$NIC_unique] for $OCF_RESKEY_ip else return $OCF_ERR_GENERIC fi # This logic is mostly to support LVS (If I understand it correctly) if [ ${OCF_RESKEY_lvs_support} = 1 ]; then NIC_current=`find_interface $OCF_RESKEY_ip` case $NIC_unique in lo*) if [ x"$NIC_unique" = x"$NIC_current" ]; then # Its already "running" and not moving, nothing to do. ocf_log err "Could not find a non-loopback device to move $OCF_RESKEY_ip to" return $OCF_ERR_GENERIC fi;; *) lvs_remove_conflicting_loopback "$OCF_RESKEY_ip" "$NIC_current";; esac fi add_interface "$OCF_RESKEY_ip" "$OCF_RESKEY_nic" "$NIC_unique" \ "$OCF_RESKEY_cidr_netmask" "$OCF_RESKEY_broadcast" rc=$? if [ $rc != 0 ]; then ocf_log err "Could not add $OCF_RESKEY_ip to $OCF_RESKEY_nic: $rc" return $rc fi # The address is active, now notify others about it using sendarp if [ "$SYSTYPE" = "DarwinBSD" -a "$NIC_unique" = "lo0" ]; then # Darwin can't send ARPs on loopback devices SENDARP="" fi if [ x$SENDARP != x ]; then TARGET_INTERFACE=`echo $NIC_unique | sed 's%:.*%%'` SENDARPPIDFILE="$SENDARPPIDDIR/send_arp-$OCF_RESKEY_ip" ARGS="-i $OCF_RESKEY_ARP_INTERVAL_MS -r $OCF_RESKEY_ARP_REPEAT" ARGS="$ARGS -p $SENDARPPIDFILE $TARGET_INTERFACE $OCF_RESKEY_ip" ARGS="$ARGS auto $OCF_RESKEY_ip $OCF_RESKEY_ARP_NETMASK" ocf_log debug "Sending Gratuitous Arp for $OCF_RESKEY_ip on $NIC_unique [$TARGET_INTERFACE]" case $OCF_RESKEY_ARP_BACKGROUND in yes) ($SENDARP $ARGS || ocf_log err "Could not send gratuitous arps. rc=$?" & ) >&2 ;; *) $SENDARP $ARGS || ocf_log err "Could not send gratuitous arps. rc=$?";; esac fi ip_status_internal return $? } ip_status_internal() { NIC=`find_interface "$OCF_RESKEY_ip"` if [ "x$NIC" = x ]; then return $OCF_NOT_RUNNING elif [ "${OCF_RESKEY_lvs_support}" = "1" ]; then case $NIC in lo*) return $OCF_NOT_RUNNING;; *) return $OCF_SUCCESS;; esac else if [ x$OCF_RESKEY_nic != x ]; then simple_OCF_NIC=`echo $OCF_RESKEY_nic | awk -F: '{print $1}'` simple_NIC=`echo $NIC | awk -F: '{print $1}'` if [ $simple_OCF_NIC != $simple_NIC ]; then ocf_log err "$OCF_RESKEY_ip is running an interface ($simple_NIC) instead of the configured one ($simple_OCF_NIC)" return $OCF_ERR_GENERIC fi fi return $OCF_SUCCESS fi } ip_status() { ip_status_internal rc=$? if [ $rc = $OCF_SUCCESS ]; then echo "running" elif [ $rc = $OCF_NOT_RUNNING ]; then echo "stopped" else echo "unknown" fi return $rc; } # # Determine if this IP address is really being served, or not. # Note that we must distinguish if *we're* serving it locally... # ip_monitor() { ip_status_internal rc=$? if [ $OCF_CHECK_LEVEL = 0 -o $rc != 0 ]; then return $rc fi ocf_log info "Checking IP stack" case "$SYSTYPE" in Linux) # -c count -t timetolive -q(uiet) -n(umeric) -W timeout PINGARGS="-c 1 -q -n $OCF_RESKEY_ip" ;; SunOS) PINGARGS="$OCF_RESKEY_ip $TIMEOUT" ;; *) PINGARGS="-c 1 -q $OCF_RESKEY_ip" ;; esac for j in 1 2 3 4 5 6 7 8 9 10; do if @PING@ $PINGARGS >/dev/null 2>&1 ; then return $OCF_SUCCESS fi done return $OCF_ERR_GENERIC } is_positive_integer() { ocf_is_decimal $1 && [ $1 -ge 1 ] if [ $? = 0 ]; then return 1 fi return 0 } ip_validate_all() { : ${OCF_RESKEY_ARP_BACKGROUND=yes} : ${OCF_RESKEY_ARP_NETMASK=ffffffffffff} : ${OCF_RESKEY_ARP_INTERVAL_MS=500} : ${OCF_RESKEY_ARP_REPEAT=10} if [ -d "$VLDIR/" ] || mkdir -p "$VLDIR/" then : Directory $VLDIR now exists else ocf_log err "Could not create \"$VLDIR/\"." return $OCF_ERR_GENERIC fi if is_positive_integer $OCF_RESKEY_ARP_INTERVAL_MS then ocf_log err "Invalid parameter value: ARP_INTERVAL_MS [$OCF_RESKEY_ARP_INTERVAL_MS]" return $OCF_ERR_ARGS fi if is_positive_integer $OCF_RESKEY_ARP_REPEAT then ocf_log err "Invalid parameter value: ARP_REPEAT [$OCF_RESKEY_ARP_REPEAT]" return $OCF_ERR_ARGS fi : ${OCF_RESKEY_lvs_support=0} if [ "$SYSTYPE" = "Linux" -o "$SYSTYPE" = "SunOS" ]; then : else if [ "${OCF_RESKEY_lvs_support}" = "1" ]; then ocf_log err "$SYSTYPE does not support LVS" return $OCF_ERR_GENERIC fi fi case $OCF_RESKEY_ip in "") ocf_log err "Required parameter OCF_RESKEY_ip is missing" return $OCF_ERR_CONFIGURED;; [0-9]*.[0-9]*.[0-9]*.*[0-9]) : OK;; *) ocf_log err "Parameter OCF_RESKEY_ip [$OCF_RESKEY_ip] not an IP address" return $OCF_ERR_CONFIGURED;; esac # Unconditionally do this? case $OCF_RESKEY_nic in *:*) OCF_RESKEY_nic=`echo $OCF_RESKEY_nic | sed 's/:.*//'` ;; esac NICINFO=`$FINDIF` rc=$? if [ $rc != 0 ]; then ocf_log err "$FINDIF failed [rc=$rc]." return $OCF_ERR_GENERIC fi tmp=`echo "$NICINFO" | cut -f1` if [ "x$OCF_RESKEY_nic" = "x" ]; then ocf_log info "Using calculated nic for ${OCF_RESKEY_ip}: $tmp" OCF_RESKEY_nic=$tmp elif [ x$tmp != x${OCF_RESKEY_nic} ]; then ocf_log err "Invalid parameter value: nic [$OCF_RESKEY_nic [Calculated nic: $tmp]" return $OCF_ERR_ARGS fi tmp=`echo "$NICINFO" | cut -f2 | cut -d ' ' -f2` if [ -z "$OCF_RESKEY_cidr_netmask" ] then ocf_log debug "Using calculated netmask for ${OCF_RESKEY_ip}: $tmp" OCF_RESKEY_cidr_netmask=$tmp; export OCF_RESKEY_cidr_netmask elif [ "x$OCF_RESKEY_netmask" != "x$tmp" ]; then ocf_log info "Using calculated netmask for ${OCF_RESKEY_ip}: $tmp" fi # Always use the calculated version becuase it might have been specified # using CIDR notation which not every system accepts OCF_RESKEY_netmask=$tmp tmp=`echo "$NICINFO" | cut -f3 | cut -d ' ' -f2` if [ "x$OCF_RESKEY_broadcast" = "x" ]; then ocf_log debug "Using calculated broadcast for ${OCF_RESKEY_ip}: $tmp" OCF_RESKEY_broadcast=$tmp elif [ x$tmp != x${OCF_RESKEY_broadcast} ]; then ocf_log err "Invalid parameter value: broadcast [$OCF_RESKEY_broadcast [Calculated broadcast: $tmp]" return $OCF_ERR_ARGS fi return $OCF_SUCCESS } usage() { echo $USAGE >&2 return $1 } if [ $# -ne 1 ]; then usage $OCF_ERR_ARGS fi : ${OCF_RESKEY_lvs_support=0} # Normalize the value of lvs_support if [ "${OCF_RESKEY_lvs_support}" = "true" \ -o "${OCF_RESKEY_lvs_support}" = "on" ]; then OCF_RESKEY_lvs_support=1 else OCF_RESKEY_lvs_support=0 fi # Note: We had a version out there for a while which used # netmask instead of cidr_netmask. So, don't remove this aliasing code! if [ ! -z "$OCF_RESKEY_netmask" -a -z "$OCF_RESKEY_cidr_netmask" ] then OCF_RESKEY_cidr_netmask=$OCF_RESKEY_netmask export OCF_RESKEY_cidr_netmask fi case $1 in meta-data) meta_data;; start) ip_validate_all && ip_start;; stop) ip_stop;; status) ip_status;; monitor) ip_monitor;; validate-all) ip_validate_all;; usage) usage $OCF_SUCCESS;; *) usage $OCF_ERR_UNIMPLEMENTED;; esac exit $? diff --git a/heartbeat/IPaddr2.in b/heartbeat/IPaddr2.in index 3f4686762..5f05fabb6 100644 --- a/heartbeat/IPaddr2.in +++ b/heartbeat/IPaddr2.in @@ -1,843 +1,843 @@ #!/bin/sh # # $Id: IPaddr2.in,v 1.24 2006/08/09 13:01:54 lars Exp $ # # OCF Resource Agent compliant IPaddr2 script. # # Based on work by Tuomo Soini, ported to the OCF RA API by Lars # Marowsky-Brée. Implements Cluster Alias IP functionality too. # # Copyright (c) 2003 Tuomo Soini # Copyright (c) 2004-2006 SUSE LINUX AG, Lars Marowsky-Brée # 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. # # # TODO: # - Fix up Cluster IP functionality # - There ought to be an ocf_run_cmd function which does all logging, # timeout handling etc for us # - Make this the standard IP address agent on Linux; the other # platforms simply should ignore the additional parameters OR can use # the legacy heartbeat resource script... # # OCF parameters are as below # OCF_RESKEY_ip # OCF_RESKEY_broadcast # OCF_RESKEY_nic # OCF_RESKEY_cidr_netmask # OCF_RESKEY_iflabel # OCF_RESKEY_mac # OCF_RESKEY_incarnations_max_global # OCF_RESKEY_incarnation_no (not user-configurable) # OCF_RESKEY_clusterip_hash # OCF_RESKEY_clusterip_mark # OCF_RESKEY_arp_interval # OCF_RESKEY_arp_count # OCF_RESKEY_arp_bg # OCF_RESKEY_arp_mac ####################################################################### # Initialization: . @hb_libdir@/ocf-shellfuncs -HA_VARRUNDIR=@localstatedir@/run/@HB_PKG@ +HA_VARRUNHBRSCDIR=@HA_VARRUNHBRSCDIR@ IP2UTIL="@IP2UTIL@" IPTABLES="@IPTABLES@" MODPROBE="@MODPROBE@" SENDARP=$HA_BIN/send_arp FINDIF=$HA_BIN/findif -VLDIR=$HA_VARRUNDIR/rsctmp/IPaddr -SENDARPPIDDIR=$HA_VARRUNDIR/rsctmp/send_arp +VLDIR=$HA_VARRUNHBRSCDIR/IPaddr +SENDARPPIDDIR=$HA_VARRUNHBRSCDIR/send_arp ####################################################################### meta_data() { cat < 1.0 This Linux-specific resource manages IP alias IP addresses. It can add an IP alias, or remove one. In addition, it can implement Cluster Alias IP functionality if invoked as a clone resource. Manages virtual IPv4 addresses The IPv4 address to be configured in dotted quad notation, for example "192.168.1.1". IPv4 address The base network interface on which the IP address will be brought online. If left empty, the script will try and determine this from the routing table. Do NOT specify an alias interface in the form eth0:1 or anything here; rather, specify the base interface only. Network interface The netmask for the interface in CIDR format (e.g., 24 and not 255.255.255.0) If unspecified, the script will also try to determine this from the routing table. CIDR netmask Broadcast address associated with the IP. If left empty, the script will determine this from the netmask. Broadcast address You can specify an additional label for your IP address here. This label is appended to your interface name. If a label is specified in nic name, this parameter has no effect. Interface label Enable support for LVS Direct Routing configurations. In case a IP address is stopped, only move it to the loopback device to allow the local node to continue to service requests, but no longer advertise it on the network. Enable support for LVS DR If you wish the IP address to be active on more than one node, set this to the number of hash buckets you wish to use. Global number of hash buckets Set the interface MAC address explicitly. Currently only used in case of the Cluster IP Alias. Leave empty to chose automatically. Cluster IP MAC address Specify the hashing algorithm used for the Cluster IP functionality. Cluster IP hashing function Specify the mark value used to mark the connection by CONNMARK target. Mark value Specify the interval between unsolicited ARP packets in milliseconds. ARP packet interval in ms Number of unsolicited ARP packets to send. ARP packet count Whether or not to send the arp packets in the background. ARP from background MAC address to send the ARP packets too. You really shouldn't be touching this. ARP MAC END exit $OCF_SUCCESS } ip_init() { if [ X`uname -s` != "XLinux" ]; then ocf_log err "IPaddr2 only supported Linux." exit $OCF_ERR_INSTALLED fi if case $__OCF_ACTION in start|stop) ocf_is_root;; *) true;; esac then : YAY! else ocf_log err "You must be root for $__OCF_ACTION operation." exit $OCF_ERR_PERM fi if [ ! -x "$IP2UTIL" ]; then ocf_log err "$IP2UTIL not found." exit $OCF_ERR_INSTALLED fi BASEIP="$OCF_RESKEY_ip" BRDCAST="$OCF_RESKEY_broadcast" NIC="$OCF_RESKEY_nic" # Note: We had a version out there for a while which used # netmask instead of cidr_netmask. Don't remove this aliasing code! if [ ! -z "$OCF_RESKEY_netmask" -a -z "$OCF_RESKEY_cidr_netmask" ] then OCF_RESKEY_cidr_netmask=$OCF_RESKEY_netmask export OCF_RESKEY_cidr_netmask fi NETMASK="$OCF_RESKEY_cidr_netmask" IFLABEL="$OCF_RESKEY_iflabel" IF_MAC="$OCF_RESKEY_mac" LVS_SUPPORT=0 if [ x"${OCF_RESKEY_lvs_support}" = x"true" \ -o x"${OCF_RESKEY_lvs_support}" = x"on" \ -o x"${OCF_RESKEY_lvs_support}" = x"1" ]; then LVS_SUPPORT=1 fi IP_INC_GLOBAL=${OCF_RESKEY_incarnations_max_global:-1} IP_INC_NO=${OCF_RESKEY_incarnation_no:-0} IP_CIP_HASH="$OCF_RESKEY_clusterip_hash" IP_CIP_MARK=${OCF_RESKEY_clusterip_mark:-1} ARP_INTERVAL_MS=${OCF_RESKEY_arp_interval:-200} ARP_REPEAT=${OCF_RESKEY_arp_count:-5} ARP_BACKGROUND=${OCF_RESKEY_arp_bg:-yes} ARP_NETMASK=${OCF_RESKEY_arp_mac:-ffffffffffff} if ocf_is_decimal "$IP_INC_GLOBAL" && [ $IP_INC_GLOBAL -gt 0 ]; then : else ocf_log err "Invalid OCF_RESKEY_incarnations_max_global [$IP_INC_GLOBAL], should be positive integer" exit $OCF_ERR_ARGS fi # Validation is performed in ip_validate()... # # $FINDIF now takes its parameters from the environment # if NICINFO=`$FINDIF -C` then NICINFO=`echo $NICINFO | sed -e 's/netmask\ //;s/broadcast\ //'` NIC=`echo "$NICINFO" | cut -d" " -f1` NETMASK=`echo "$NICINFO" | cut -d" " -f2` BRDCAST=`echo "$NICINFO" | cut -d" " -f3` else ocf_log err "[$FINDIF -C] failed" exit $OCF_ERR_ARGS fi SENDARPPIDFILE="$SENDARPPIDDIR/send_arp-$BASEIP" case $NIC in *:*) IFLABEL=$NIC NIC=`echo $NIC | sed 's/:.*//'` ;; *) if [ -n "$IFLABEL" ]; then IFLABEL=${NIC}:${IFLABEL} fi ;; esac IP_CIP= if [ "$IP_INC_GLOBAL" -gt 1 ]; then if [ ! -x "$IPTABLES" ]; then ocf_log err "Cluster Alias IP mode selected, but iptables not configured" exit $OCF_ERR_INSTALLED fi IP_CIP="yes" if [ -z "$IF_MAC" ]; then # Choose a hash. IF_MAC=`echo $BASEIP $NETMASK $BRDCAST | md5sum | cut -c 1-12` # Make it properly delimited, anything non-numeric will do, ":" and "-" are preferred. IF_MAC=${IF_MAC:0:2}:${IF_MAC:2:2}:${IF_MAC:4:2}:${IF_MAC:6:2}:${IF_MAC:8:2}:${IF_MAC:10:2} # For $IF_MAC to be a multicast Ethernet address, the first octet must be an odd number. case ${IF_MAC:1:1} in 0|2|4|6|8|a|A|c|C|e|E) IF_MAC=${IF_MAC:0:1}1${IF_MAC:2} ;; esac fi IP_CIP_FILE="/proc/net/ipt_CLUSTERIP/$BASEIP" fi } # # Find out which interface serves the given IP address # The argument is an IP address, and its output # is an interface name (e.g., "eth0"). # find_interface() { # # List interfaces but exclude FreeS/WAN ipsecN virtual interfaces # local iface=`$IP2UTIL -o -f inet addr show | grep "\ $BASEIP/" \ | cut -d ' ' -f2 | grep -v '^ipsec[0-9][0-9]*$'` echo $iface return 0 } # # Delete an interface # delete_interface () { ipaddr="$1" iface="$2" netmask="$3" CMD="$IP2UTIL -f inet addr delete $ipaddr/$netmask dev $iface" ocf_log info "$CMD" $CMD if [ $? -ne 0 ]; then return $OCF_ERR_GENERIC fi CMD="$IP2UTIL -o -f inet addr show $iface" ocf_log info "$CMD" ADDR=`$CMD` if [ $? -ne 0 -o ! -z "$ADDR" ]; then return $? fi CMD="$IP2UTIL link set $iface down" ocf_log info "$CMD" $CMD return $? } # # Add an interface # add_interface () { ipaddr="$1" netmask="$2" broadcast="$3" iface="$4" label="$5" CMD="$IP2UTIL -f inet addr add $ipaddr/$netmask brd $broadcast dev $iface" if [ ! -z "$label" ]; then CMD="$CMD label $label" fi ocf_log info "$CMD" $CMD if [ $? -ne 0 ]; then return $OCF_ERR_GENERIC fi CMD="$IP2UTIL link set $iface up" ocf_log info "$CMD" $CMD return $? } # # Delete a route # delete_route () { prefix="$1" iface="$2" CMD="$IP2UTIL route delete $prefix dev $iface" ocf_log info "$CMD" $CMD return $? } # On Linux systems the (hidden) loopback interface may # conflict with the requested IP address. If so, this # unoriginal code will remove the offending loopback address # and save it in VLDIR so it can be added back in later # when the IPaddr is released. # # TODO: This is very ugly and should be controlled by an additional # instance parameter. Or even: multi-state, with the IP only being # "active" on the master!? # remove_conflicting_loopback() { ipaddr="$1" netmask="$2" broadcast="$3" ifname="$4" ocf_log info "Removing conflicting loopback $ifname." if [ -d "$VLDIR/" ] || mkdir -p "$VLDIR/"; then : Directory $VLDIR now exists else ocf_log err "Could not create \"$VLDIR/\" conflicting" \ " loopback $ifname cannot be restored." fi if echo "$ipaddr $netmask $broadcast $ifname" > "$VLDIR/$ipaddr" then : Saved loopback information in $VLDIR/$ipaddr else ocf_log err "Could not save conflicting loopback $ifname." \ "it will not be restored." fi delete_interface "$ipaddr" "$ifname" "$netmask" # Forcibly remove the route (if it exists) to the loopback. delete_route "$ipaddr" "$ifname" } # # On Linux systems the (hidden) loopback interface may # need to be restored if it has been taken down previously # by remove_conflicting_loopback() # restore_loopback() { ipaddr="$1" if [ -s "$VLDIR/$ipaddr" ]; then ifinfo=`cat "$VLDIR/$ipaddr"` ocf_log info "Restoring loopback IP Address " \ "$ifinfo." add_interface $ifinfo rm -f "$VLDIR/$ipaddr" fi } # # Run send_arp to note peers about new mac address # run_send_arp() { ARGS="-i $ARP_INTERVAL_MS -r $ARP_REPEAT -p $SENDARPPIDFILE $NIC $BASEIP auto $BASEIP $ARP_NETMASK" ocf_log info "$SENDARP $ARGS" case $ARP_BACKGROUND in yes) ($SENDARP $ARGS || ocf_log err "Could not send gratuitous arps" &) >&2 ;; *) $SENDARP $ARGS || ocf_log err "Could not send gratuitous arps" ;; esac } # Do we already serve this IP address? # # returns: # ok = served (for CIP: + hash bucket) # partial = served and no hash bucket (CIP only) # no = nothing # ip_served() { cur_nic="`find_interface $BASEIP`" if [ -z "$cur_nic" ]; then echo "no" return 0 fi if [ -z "$IP_CIP" ]; then case $cur_nic in lo*) if [ "$LVS_SUPPORT" = "1" ]; then echo "no" return 0 fi ;; esac echo "ok" return 0 fi # Special handling for the CIP: if grep -q "\<${IP_INC_NO}\>" $IP_CIP_FILE ; then echo "ok" return 0 else return "partial" fi exit $OCF_ERR_GENERIC } ####################################################################### ip_usage() { cat <$IP_CIP_FILE fi if [ "$ip_status" = "no" ]; then if [ "$LVS_SUPPORT" = "1" ]; then case `find_interface $BASEIP` in lo*) remove_conflicting_loopback $BASEIP 32 255.255.255.255 lo ;; esac fi add_interface $BASEIP $NETMASK $BRDCAST $NIC $IFLABEL if [ $? -ne 0 ]; then ocf_log err "$CMD failed." exit $OCF_ERR_GENERIC fi fi case $NIC in lo*) : no need to run send_arp on loopback ;; *) run_send_arp ;; esac exit $OCF_SUCCESS } ip_stop() { ip_init local ip_del_if="yes" if [ -f "$SENDARPPIDFILE" ] ; then kill `cat "$SENDARPPIDFILE"` if [ $? -ne 0 ]; then ocf_log warn "Could not kill previously running send_arp for $BASEIP" else ocf_log info "killed previously running send_arp for $BASEIP" rm -f "$SENDARPPIDFILE" fi fi local ip_status=`ip_served` if [ $ip_status = "no" ]; then : Requested interface not in use exit $OCF_SUCCESS fi if [ -n "$IP_CIP" ]; then if [ $ip_status = "partial" ]; then exit $OCF_SUCCESS fi echo "-$IP_INC_NO" >$IP_CIP_FILE if [ "x$(cat $IP_CIP_FILE)" = "x" ]; then # This was the last incarnation $IPTABLES -D OUTPUT -s $CLUSTERIP -o $NIC \ -m state --state NEW \ -j CONNMARK --set-mark $IP_CIP_MARK $IPTABLES -D INPUT -d $BASEIP -i $NIC -j CLUSTERIP \ --new \ --clustermac $IF_MAC \ --total-nodes $IP_INC_GLOBAL \ --local-node $IP_INC_NO \ --hashmode $IP_CIP_HASH else ip_del_if="no" fi fi if [ "$ip_del_if" = "yes" ]; then delete_interface $BASEIP $NIC $NETMASK if [ $? -ne 0 ]; then exit $OCF_ERR_GENERIC fi if [ "$LVS_SUPPORT" = 1 ]; then restore_loopback "$BASEIP" fi fi exit $OCF_SUCCESS } ip_monitor() { ip_init # TODO: Implement more elaborate monitoring like checking for # interface health maybe via a daemon like FailSafe etc... case `ip_served $BASEIP` in ok) return $OCF_SUCCESS ;; partial|no) exit $OCF_NOT_RUNNING ;; *) # Errors on this interface? return $OCF_ERR_GENERIC ;; esac } ip_validate() { ip_init # $BASEIP, $NETMASK, $NIC , $IP_INC_GLOBAL, and $BRDCAST have been checked within ip_init, # do not bother here. if ocf_is_decimal "$ARP_INTERVAL_MS" && [ $ARP_INTERVAL_MS -gt 0 ]; then : else ocf_log err "Invalid OCF_RESKEY_arp_interval [$ARP_INTERVAL_MS]" exit $OCF_ERR_ARGS fi if ocf_is_decimal "$ARP_REPEAT" && [ $ARP_REPEAT -gt 0 ]; then : else ocf_log err "Invalid OCF_RESKEY_arp_count [$ARP_REPEAT]" exit $OCF_ERR_ARGS fi if [ -n "$IP_CIP" ]; then local valid=1 case $IP_CIP_HASH in sourceip|sourceip-sourceport|sourceip-sourceport-destport) ;; *) ocf_log err "Invalid OCF_RESKEY_clusterip_hash [$IP_CIP_HASH]" exit $OCF_ERR_ARGS ;; esac mark=$IP_CIP_MARK case $mark in +*|-*) mark=$(echo $mark | cut -c 2-) ;; esac case $mark in 0x*) # hexidecimal mark=$(echo $mark | cut -c 3-) if [ -n "$mark" ] && ocf_is_hex "$mark"; then : else valid=0 fi ;; 0*) # octal mark=$(echo $mark | cut -c 2-) if [ -n "$mark" ] && ocf_is_octal "$mark"; then : else valid=0 fi ;; *) # decimal if [ -n "$mark" ] && ocf_is_decimal "$mark"; then : else valid=0 fi ;; esac if [ $valid -eq 0 ]; then ocf_log err "Invalid OCF_RESKEY_clusterip_mark [$IP_CIP_MARK]" exit $OCF_ERR_ARGS fi case $IF_MAC in ??[^0-9]??[^0-9]??[^0-9]??[^0-9]??[^0-9]??) mac=${IF_MAC:0:2}${IF_MAC:3:2}${IF_MAC:6:2}${IF_MAC:9:2}${IF_MAC:12:2}${IF_MAC:15:2} if ocf_is_hex "$mac"; then case ${mac:1:1} in 0|2|4|6|8|a|A|c|C|e|E) valid=0 ;; esac else valid=0 fi ;; *) valid=0 ;; esac if [ $valid -eq 0 ]; then ocf_log err "Invalid IF_MAC [$IF_MAC]" exit $OCF_ERR_ARGS fi fi exit $OCF_SUCCESS } case $__OCF_ACTION in meta-data) meta_data ;; start) ip_start ;; stop) ip_stop ;; status) ip_init ip_status=`ip_served` if [ $ip_status = "ok" ]; then echo "running" exit $OCF_SUCCESS else echo "stopped" exit $OCF_NOT_RUNNING fi ;; monitor) ip_monitor ;; validate-all) ip_validate ;; usage|help) ip_usage exit $OCF_SUCCESS ;; *) ip_usage exit $OCF_ERR_UNIMPLEMENTED ;; esac diff --git a/heartbeat/MailTo.in b/heartbeat/MailTo.in index 5ca3f48ed..0d317f032 100644 --- a/heartbeat/MailTo.in +++ b/heartbeat/MailTo.in @@ -1,215 +1,214 @@ #!/bin/sh # # Resource script for MailTo # # Author: Alan Robertson # # Description: sends email to a sysadmin whenever a takeover occurs. # # Note: This command requires an argument, unlike normal init scripts. # # This can be given in the haresources file as: # # You can also give a mail subject line or even multiple addresses # MailTo::alanr@unix.sh::BigImportantWebServer # MailTo::alanr@unix.sh,spoppi@gmx.de::BigImportantWebServer # # This will then be put into the message subject and body. # # OCF parameters are as below: # OCF_RESKEY_email # OCF_RESKEY_subject # # License: GNU General Public License (GPL) # # Copyright: (C) 2005 International Business Machines -VARRUN=@localstatedir@/run -MAILTOFILE=$VARRUN/MailTo +MAILTOFILE=@HA_VARRUNDIR@/MailTo ####################################################################### # Initialization: . @hb_libdir@/ocf-shellfuncs ####################################################################### ARGS="$0 $*" us=`uname -n` usage() { echo "Usage: $0 {start|stop|status|monitor|meta-data|validate-all}" } meta_data() { cat < 1.0 This is a resource agent for MailTo. It sends email to a sysadmin whenever a takeover occurs. MailTo resource agent The email address of sysadmin. Email address The subject of the email. Subject END } MailProgram() { mail -s "$1" "$email" </dev/null if [ $? -eq 0 ]; then : OK, mail to $item@localhost.localdomain else ocf_log err "Invalid email address [$email]" exit $OCF_ERR_ARGS fi ;; esac done # Any subject is OK return $OCF_SUCCESS } # # See how we were called. # # The order in which heartbeat provides arguments to resource # scripts is broken. It should be fixed. # if ( [ $# -ne 1 ] ) then usage exit $OCF_ERR_GENERIC fi case $1 in meta-data) meta_data exit $OCF_SUCCESS ;; # Not quite sure what to do with this one... # We aren't a continuously running service - so it's not clear # status|monitor) MailToStatus exit $? ;; usage) usage exit $OCF_SUCCESS ;; *) ;; esac if [ -z "$OCF_RESKEY_email" ] then ocf_log err "At least 1 Email address has to be given!" # usage exit $OCF_ERR_GENERIC fi email=$OCF_RESKEY_email subject=$OCF_RESKEY_subject case $1 in start) MailToStart ;; stop) MailToStop ;; validate-all) MailToValidateAll ;; *) usage exit $OCF_ERR_UNIMPLEMENTED ;; esac exit $? diff --git a/heartbeat/Makefile.am b/heartbeat/Makefile.am index 5cdabdeb7..e8e5f1d19 100644 --- a/heartbeat/Makefile.am +++ b/heartbeat/Makefile.am @@ -1,85 +1,86 @@ # Makefile.am for OCF RAs # # Author: Sun Jing Dong # Copyright (C) 2004 IBM # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # MAINTAINERCLEANFILES = Makefile.in EXTRA_DIST = ocf-returncodes INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/linux-ha ocfdir = @OCF_RA_DIR@/heartbeat gliblib = @GLIBLIB@ if USE_IPV6ADDR ocf_PROGRAMS = IPv6addr else ocf_PROGRAMS = endif IPv6addr_SOURCES = IPv6addr.c IPv6addr_LDADD = $(top_builddir)/lib/clplumbing/libplumb.la \ $(gliblib) @LIBNETLIBS@ \ $(top_builddir)/lib/pils/libpils.la ocf_SCRIPTS = ClusterMon \ Dummy \ IPaddr \ IPaddr2 \ drbd \ apache \ AudibleAlarm \ db2 \ Delay \ drbd \ EvmsSCC \ + Evmsd \ Filesystem \ ICP \ IPsrcaddr \ LinuxSCSI \ LVM \ MailTo \ ManageRAID \ ManageVE \ mysql \ oracle \ oralsnr \ pingd \ portblock \ pgsql \ Pure-FTPd \ Raid1 \ rsyncd \ SAPDatabase \ SAPInstance \ SendArp \ ServeRAID \ Stateful \ SysInfo \ VIPArip \ WAS \ WAS6 \ WinPopup \ Xen \ Xinetd commondir = @hb_libdir@ common_SCRIPTS = ocf-shellfuncs ocf-returncodes diff --git a/heartbeat/Pure-FTPd.in b/heartbeat/Pure-FTPd.in index 639b67c52..de71e040c 100755 --- a/heartbeat/Pure-FTPd.in +++ b/heartbeat/Pure-FTPd.in @@ -1,207 +1,206 @@ #!/bin/sh # # Resource script for Pure-FTPd # # Description: Manages Pure-FTPd as an OCF resource in # an Active-Passive High Availability setup. # # Author: Rajat Upadhyaya # License: GNU General Public License (GPL) # # # usage: $0 {start|stop|status|monitor|validate-all|meta-data} # # The "start" arg starts Pure-FTPd. # # The "stop" arg stops it. # # OCF parameters: # OCF_RESKEY_script # OCF_RESKEY_conffile # ########################################################################## # Initialization: . @hb_libdir@/ocf-shellfuncs -HA_VARRUNDIR=@localstatedir@/run/@HB_PKG@ -PIDFILE=$HA_VARRUNDIR/rsctmp/pure-ftpd-${OCF_RESOURCE_INSTANCE}.pid +PIDFILE=@HA_VARRUNHBRSCDIR@/pure-ftpd-${OCF_RESOURCE_INSTANCE}.pid USAGE="Usage: $0 {start|stop|status|monitor|validate-all|meta-data}"; ########################################################################## usage() { echo $USAGE >&2 } meta_data() { cat < 1.0 This script manages Pure-FTPd in an Active-Passive setup OCF Resource Agent compliant FTP script. The full path to the Pure-FTPd startup script. For example, "/sbin/pure-config.pl" Script name with full path The Pure-FTPd configuration file name with full path. For example, "/etc/pure-ftpd/pure-ftpd.conf" Configuration file name with full path END exit $OCF_SUCCESS } isRunning() { kill -0 "$1" > /dev/null } PureFTPd_status() { if [ -f $PIDFILE ] then # Pure-FTPd is probably running PID=`head -n 1 $PIDFILE` if [ ! -z $PID ] ; then isRunning "$PID" && [ `ps -p $PID | grep pure-ftpd | wc -l` -eq 1 ] return $? fi fi # Pure-FTPd is not running false } 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 if PureFTPd_status ; then exit $OCF_SUCCESS fi if [ -n "$OCF_RESKEY_script" -a -n "$OCF_RESKEY_conffile" ] then $OCF_RESKEY_script $OCF_RESKEY_conffile -g $PIDFILE 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() { if PureFTPd_status ; then PID=`head -n 1 $PIDFILE` if [ ! -z $PID ] ; then kill $PID fi fi exit $OCF_SUCCESS } PureFTPd_monitor() { if PureFTPd_status ; then return $OCF_SUCCESS fi return $OCF_NOT_RUNNING } PureFTPd_validate_all() { return $OCF_SUCCESS } # # Main # if [ $# -ne 1 ] then usage exit $OCF_ERR_ARGS fi case $1 in start) PureFTPd_start ;; stop) PureFTPd_stop ;; status) if PureFTPd_status then ocf_log info "Pure-FTPd is running" exit $OCF_SUCCESS else ocf_log info "Pure-FTPd is stopped" exit $OCF_NOT_RUNNING fi ;; monitor) PureFTPd_monitor exit $? ;; validate-all) PureFTPd_validate_all exit $? ;; meta-data) meta_data ;; usage) usage exit $OCF_SUCCESS ;; *) usage exit $OCF_ERR_UNIMPLEMENTED ;; esac diff --git a/heartbeat/SendArp.in b/heartbeat/SendArp.in index a63264261..0a310bf9d 100644 --- a/heartbeat/SendArp.in +++ b/heartbeat/SendArp.in @@ -1,253 +1,252 @@ #!/bin/sh # # # Copyright (c) 2006, Huang Zhen # Converting original heartbeat RA to OCF RA. # # Copyright (C) 2004 Horms # # Based on IPaddr2: Copyright (C) 2003 Tuomo Soini # # License: GNU General Public License (GPL) # Support: linux-ha@lists.linux-ha.org # # This script send out gratuitous Arp for an IP address # # It can be used _instead_ of the IPaddr2 or IPaddr resource # to send gratuitous arp for an IP address on a given interface, # without adding the address to that interface. I.e. if for # some reason you want to send gratuitous arp for addresses # managed by IPaddr2 or IPaddr on an additional interface. # # OCF parameters are as below: # OCF_RESKEY_ip # OCF_RESKEY_nic # # # 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. # ####################################################################### # Initialization: . @hb_libdir@/ocf-shellfuncs SENDARP=$HA_BIN/send_arp -HA_VARRUNDIR=@localstatedir@/run/@HB_PKG@ -VLDIR=$HA_VARRUNDIR/rsctmp/IPaddr -SENDARPPIDDIR=$HA_VARRUNDIR/rsctmp/send_arp +VLDIR=@HA_VARRUNHBRSC@/IPaddr +SENDARPPIDDIR=@HA_VARRUNHBRSCDIR@/send_arp BASEIP="$OCF_RESKEY_ip" INTERFACE="$OCF_RESKEY_nic" RESIDUAL="" SENDARPPIDFILE="$SENDARPPIDDIR/send_arp-$BASEIP" # Set default values : ${ARP_INTERVAL_MS=200} # milliseconds between ARPs : ${ARP_REPEAT=5} # repeat count : ${ARP_BACKGROUND=yes} # no to run in foreground : ${ARP_NETMASK=ffffffffffff} # netmask for ARP ####################################################################### sendarp_meta_data() { cat < 1.0 This script send out gratuitous Arp for an IP address SendArp resource agent The IP address for sending arp package. IP address The nic for sending arp package. NIC END } ####################################################################### sendarp_usage() { cat < 1.0 This is an example resource agent that impliments two states Example stateful resource agent Location to store the resource state in State file - + END exit $OCF_SUCCESS } ####################################################################### stateful_usage() { cat < ${OCF_RESKEY_state} } stateful_check_state() { target=$1 if [ -f ${OCF_RESKEY_state} ]; then state=`cat ${OCF_RESKEY_state}` if [ "x$target" = "x$state" ]; then return 0 fi else if [ "x$target" = "x" ]; then return 0 fi fi return 1 } stateful_start() { stateful_check_state master if [ $? = 0 ]; then # CRM Error - Should never happen return $OCF_RUNNING_MASTER fi stateful_update slave return 0 } stateful_demote() { stateful_check_state if [ $? = 0 ]; then # CRM Error - Should never happen return $OCF_NOT_RUNNING fi stateful_update slave return 0 } stateful_promote() { stateful_check_state if [ $? = 0 ]; then return $OCF_NOT_RUNNING fi stateful_update master return 0 } stateful_stop() { stateful_check_state master if [ $? = 0 ]; then # CRM Error - Should never happen return $OCF_RUNNING_MASTER fi if [ -f ${OCF_RESKEY_state} ]; then rm ${OCF_RESKEY_state} fi return 0 } stateful_monitor() { stateful_check_state "master" if [ $? = 0 ]; then return $OCF_RUNNING_MASTER fi stateful_check_state "slave" if [ $? = 0 ]; then return $OCF_SUCCESS fi if [ -f ${OCF_RESKEY_state} ]; then echo "File '${OCF_RESKEY_state}' exists but contains unexpected contents" cat ${OCF_RESKEY_state} return $OCF_ERR_GENERIC fi return 7 } stateful_validate() { exit $OCF_SUCCESS } -: ${OCF_RESKEY_state=@localstatedir@/run/@HB_PKG@/rsctmp/Stateful-${OCF_RESOURCE_INSTANCE}.state} +: ${OCF_RESKEY_state=@HA_VARRUNHBRSCDIR@/Stateful-${OCF_RESOURCE_INSTANCE}.state} case $__OCF_ACTION in meta-data) meta_data;; start) stateful_start;; promote) stateful_promote;; demote) stateful_demote;; stop) stateful_stop;; monitor) stateful_monitor;; validate-all) stateful_validate;; usage|help) stateful_usage $OCF_SUCCESS;; *) stateful_usage $OCF_ERR_UNIMPLEMENTED;; esac exit $? diff --git a/heartbeat/SysInfo.in b/heartbeat/SysInfo.in index 575261c5b..227eb2cce 100644 --- a/heartbeat/SysInfo.in +++ b/heartbeat/SysInfo.in @@ -1,364 +1,364 @@ #!/bin/bash # # # SysInfo OCF Resource Agent # It records (in the CIB) various attributes of a node # # Copyright (c) 2004 SUSE LINUX AG, Lars Marowsky-Brée # 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. # ####################################################################### # Initialization: . @hb_libdir@/ocf-shellfuncs ####################################################################### -HA_VARRUNHBDIR=@HA_VARRUNHBDIR@ +HA_VARRUNHBRSCDIR=@HA_VARRUNHBRSCDIR@ meta_data() { cat < 1.0 This is a SysInfo Resource Agent. It records (in the CIB) various attributes of a node Sample Linux output: arch: i686 os: Linux-2.4.26-gentoo-r14 free_swap: 1999 cpu_info: Intel(R) Celeron(R) CPU 2.40GHz cpu_speed: 4771.02 cpu_cores: 1 cpu_load: 0.00 ram_total: 513 ram_free: 117 root_free: 2.4 Sample Darwin output: arch: i386 os: Darwin-8.6.2 cpu_info: Intel Core Duo cpu_speed: 2.16 cpu_cores: 2 cpu_load: 0.18 ram_total: 2016 ram_free: 787 root_free: 13 Units: free_swap: Mb ram_*: Mb root_free: Gb cpu_speed (Linux): bogomips cpu_speed (Darwin): Ghz SysInfo resource agent PID file PID file Interval to allow values to stabilize Dampening Delay END } ####################################################################### UpdateStat() { name=$1; shift value="$*" echo -e "$name:\t$value" @sbindir@/attrd_updater ${OCF_RESKEY_delay} -S status -n $name -v "$value" } SysInfoStats() { UpdateStat arch "`uname -m`" UpdateStat os "`uname -s`-`uname -r`" case `uname -s` in "Darwin") mem=`top -l 1 | grep Mem: | awk '{print $10}'` mem_used=`top -l 1 | grep Mem: | awk '{print $8}'` mem=`SysInfo_mem_units $mem` mem_used=`SysInfo_mem_units $mem_used` mem_total=`expr $mem_used + $mem` cpu_type=`system_profiler SPHardwareDataType | grep "CPU Type:"` cpu_type=${cpu_type/*: /} cpu_speed=`system_profiler SPHardwareDataType | grep "CPU Speed:" | awk '{print $3}'` cpu_cores=`system_profiler SPHardwareDataType | grep "Number Of"` cpu_cores=${cpu_cores/*: /} ;; "Linux") if [ -f /proc/cpuinfo ]; then cpu_type=`grep "model name" /proc/cpuinfo | head -n 1` cpu_type=${cpu_type/*: /} cpu_speed=`grep "bogomips" /proc/cpuinfo | head -n 1` cpu_speed=${cpu_speed/*: /} cpu_cores=`grep "processor" /proc/cpuinfo | wc -l` fi if [ -f /proc/meminfo ]; then # meminfo results are in kB mem=`grep "SwapFree" /proc/meminfo | awk '{print $2"k"}'` if [ ! -z $mem ]; then UpdateStat free_swap `SysInfo_mem_units $mem` fi mem=`grep "Inactive" /proc/meminfo | awk '{print $2"k"}'` mem_total=`grep "MemTotal" /proc/meminfo | awk '{print $2"k"}'` else mem=`top -n 1 | grep Mem: | awk '{print $7}'` fi ;; *) esac if [ x != x"$cpu_type" ]; then UpdateStat cpu_info "$cpu_type" fi if [ x != x"$cpu_speed" ]; then UpdateStat cpu_speed "$cpu_speed" fi if [ x != x"$cpu_cores" ]; then UpdateStat cpu_cores "$cpu_cores" fi loads=`uptime` load15=`echo ${loads/*average/} | awk '{print $4}'` load15=${load15/.*/} UpdateStat cpu_load $load15 if [ ! -z "$mem" ]; then # Massage the memory values UpdateStat ram_total `SysInfo_mem_units $mem_total` UpdateStat ram_free `SysInfo_mem_units $mem` fi # Portability notes: # o df: -h flag not available on Solaris 8. (OK on 9, 10, ...) #FIXME# # o tail: explicit "-n" not available in Solaris; instead simplify # 'tail -n ' to the equivalent 'tail -'. disk=`df -h / | tail -1 | awk '{print $4}'` if [ x != x"$disk" ]; then UpdateStat root_free `SysInfo_hdd_units $disk` fi } SysInfo_mem_units() { mem=$1 if [ -z $1 ]; then return fi memlen=`expr ${#mem} - 1` memlen_alt=`expr ${#mem} - 2` if [ ${mem:$memlen:1} = "G" ]; then mem="${mem:0:$memlen}" if [ $mem != ${mem/./} ]; then mem_before=${mem/.*/} mem_after=${mem/*./} mem=$[mem_before*1024] if [ ${#mem_after} = 0 ]; then : elif [ ${#mem_after} = 1 ]; then mem=$[mem+100*$mem_after] elif [ ${#mem_after} = 2 ]; then mem=$[mem+10*$mem_after] elif [ ${#mem_after} = 3 ]; then mem=$[mem+$mem_after] else mem_after=${mem_after:0:3} mem=$[mem+$mem_after] fi fi elif [ ${mem:$memlen:1} = "M" ]; then mem=${mem/.*/} mem="${mem:0:$memlen}" elif [ ${mem:$memlen:1} = "k" ]; then mem="${mem:0:$memlen}" mem=${mem/.*/} mem=`expr $mem / 1024` elif [ ${mem:$memlen_alt:2} = "kB" ]; then mem="${mem:0:$memlen_alt}" mem=${mem/.*/} mem=`expr $mem / 1024` elif [ ${mem:$memlen_alt:2} = "Mb" ]; then mem="${mem:0:$memlen_alt}" mem=${mem/.*/} elif [ ${mem:$memlen_alt:2} = "MB" ]; then mem="${mem:0:$memlen_alt}" mem=${mem/.*/} fi # Round to the next multiple of 50 memlen=`expr ${#mem} - 2` mem_round="${mem:$memlen:2}" if [ x$mem_round = x ]; then : elif [ $mem_round = "00" ]; then : elif [ $mem_round -lt "50" ]; then mem=$[mem+50] mem=$[mem-$mem_round] else mem=$[mem+100] mem=$[mem-$mem_round] fi echo $mem } SysInfo_hdd_units() { disk=$1 disklen=`expr ${#disk} - 1` disklen_alt=`expr ${#disk} - 2` if [ ${disk:$disklen:1} = "G" ]; then disk="${disk:0:$disklen}" elif [ ${disk:$disklen:1} = "M" ]; then disk="${disk:0:$disklen}" disk=${disk/.*/} disk=`expr $disk / 1024` elif [ ${disk:$disklen:1} = "k" ]; then disk="${disk:0:$disklen}" disk=${disk/.*/} disk=`expr $disk / 1048576` elif [ ${disk:$disklen_alt:2} = "kB" ]; then disk="${disk:0:$disklen_alt}" disk=${disk/.*/} disk=`expr $disk / 1048576` elif [ ${disk:$disklen_alt:2} = "Mb" ]; then disk="${disk:0:$disklen_alt}" disk=${disk/.*/} disk=`expr $disk / 1024` elif [ ${disk:$disklen_alt:2} = "MB" ]; then disk="${disk:0:$disklen_alt}" disk=${disk/.*/} disk=`expr $disk / 1024` fi echo $disk } SysInfo_usage() { cat < $OCF_RESKEY_pidfile SysInfoStats exit $OCF_SUCCESS } SysInfo_stop() { rm $OCF_RESKEY_pidfile exit $OCF_SUCCESS } SysInfo_monitor() { if [ -f $OCF_RESKEY_pidfile ]; then clone=`cat $OCF_RESKEY_pidfile` fi if [ x$clone = x ]; then rm $OCF_RESKEY_pidfile exit $OCF_NOT_RUNNING elif [ $clone = $OCF_RESKEY_clone ]; then SysInfoStats exit $OCF_SUCCESS elif [ x$OCF_RESKEY_CRM_meta_globally_unique = xtrue -o x$OCF_RESKEY_CRM_meta_globally_unique = xTrue -o x$OCF_RESKEY_CRM_meta_globally_unique = xyes -o x$OCF_RESKEY_CRM_meta_globally_unique = xYes ]; then SysInfoStats exit $OCF_SUCCESS fi exit $OCF_NOT_RUNNING } SysInfo_validate() { return $OCF_SUCCESS } if [ $# -ne 1 ]; then SysInfo_usage exit $OCF_ERR_ARGS fi -: ${OCF_RESKEY_pidfile:="$HA_VARRUNHBDIR/rsctmp/SysInfo-${OCF_RESOURCE_INSTANCE}"} +: ${OCF_RESKEY_pidfile:="$HA_VARRUNHBRSCDIR/SysInfo-${OCF_RESOURCE_INSTANCE}"} : ${OCF_RESKEY_clone:="0"} if [ x != x${OCF_RESKEY_delay} ]; then OCF_RESKEY_delay="-d ${OCF_RESKEY_delay}" fi case $__OCF_ACTION in meta-data) meta_data exit $OCF_SUCCESS ;; start) SysInfo_start ;; stop) SysInfo_stop ;; monitor) SysInfo_monitor ;; validate-all) SysInfo_validate ;; usage|help) SysInfo_usage exit $OCF_SUCCESS ;; *) SysInfo_usage exit $OCF_ERR_UNIMPLEMENTED ;; esac exit $? diff --git a/heartbeat/VIPArip.in b/heartbeat/VIPArip.in index b77093208..0122d6fba 100644 --- a/heartbeat/VIPArip.in +++ b/heartbeat/VIPArip.in @@ -1,285 +1,287 @@ #!/bin/sh # # License: GNU General Public License (GPL) # Support: linux-ha@lists.linux-ha.org # Author: Huang Zhen # Copyright (c) 2006 International Business Machines # # Virtual IP Address by RIP2 protocol. # This script manages IP alias in different subnet with quagga/ripd. # It can add an IP alias, or remove one. # # The quagga package should be installed to run this RA # # usage: $0 {start|stop|status|monitor|validate-all|meta-data} # # The "start" arg adds an IP alias. # Surprisingly, the "stop" arg removes one. :-) # # OCF parameters are as below # OCF_RESKEY_ip The IP address in different subnet # OCF_RESKEY_nic The nic for broadcast the route information # ####################################################################### # Initialization: . @hb_libdir@/ocf-shellfuncs + +HA_VARRUNHBRSCDIR=@HA_VARRUNHBRSCDIR@ +HA_HBCONF_DIR=@HA_HBCONF_DIR@ + GREP=@EGREP@ -HA_VARRUNDIR=@localstatedir@/run/@HB_PKG@ -VLDIR=$HA_VARRUNDIR/rsctmp/VIPArip +VLDIR=$HA_VARRUNHBRSCDIR/VIPArip RIPDCONF=$VLDIR/ripd.conf IP=@IP2UTIL@ USAGE="usage: $0 {start|stop|status|monitor|validate-all|meta-data}"; ####################################################################### LC_ALL=C export LC_ALL -HA_D=@sysconfdir@/ha.d -. ${HA_D}/shellfuncs +. $HA_HBCONF_DIR/shellfuncs meta_data() { cat < 1.0 Virtual IP Address by RIP2 protocol. This script manages IP alias in different subnet with quagga/ripd. It can add an IP alias, or remove one. Virtual IP Address by RIP2 protocol The IPv4 address in different subnet, for example "192.168.1.1". The IP address in different subnet The nic for broadcast the route information. The ripd uses this nic to broadcast the route informaton to others The nic for broadcast the route information END exit $OCF_SUCCESS } usage() { echo $USAGE >&2 } new_config_file() { echo new_config_file $1 $2 $3 cat >$RIPDCONF < $RIPDCONF.tmp cp $RIPDCONF.tmp $RIPDCONF } add_ip() { echo add_ip $1 sed "s/ip_tag/ip_tag\naccess-list private permit $1\/32/g" $RIPDCONF > $RIPDCONF.tmp cp $RIPDCONF.tmp $RIPDCONF } del_ip() { echo del_ip $1 sed "/$1/d" $RIPDCONF > $RIPDCONF.tmp cp $RIPDCONF.tmp $RIPDCONF if $GREP "access-list private permit" $RIPDCONF>/dev/null then echo some other IP is running reload_config else stop_quagga echo remove $RIPDCONF rm $RIPDCONF fi } add_nic() { echo add_nic $1 if $GREP "network $1" $RIPDCONF >/dev/null then echo the nic is already in the config file else sed "s/nic_tag/nic_tag\n no passive-interface $1\n network $1\n distribute-list private out $1\n distribute-list private in $1/g" $RIPDCONF > $RIPDCONF.tmp cp $RIPDCONF.tmp $RIPDCONF fi } reload_config() { echo reload_config echo $RIPDCONF: cat $RIPDCONF echo killall -SIGHUP ripd killall -SIGHUP ripd } start_quagga() { echo start_quagga echo $RIPDCONF: cat $RIPDCONF echo /usr/sbin/zebra -d /usr/sbin/zebra -d echo /usr/sbin/ripd -d -f $RIPDCONF /usr/sbin/ripd -d -f $RIPDCONF } stop_quagga() { echo stop_quagga echo $RIPDCONF: cat $RIPDCONF echo killall -SIGTERM ripd killall -SIGTERM ripd echo killall -SIGTERM zebra killall -SIGTERM zebra } start_rip_ip() { echo start_rip_ip check_params if [ -d "$VLDIR/" ] || mkdir -p "$VLDIR/" then : Directory $VLDIR now exists else ocf_log err "Could not create \"$VLDIR/\"." exit $OCF_ERR_GENERIC fi if [ x"$OCF_RESKEY_nic" = x ] then echo OCF_RESKEY_nic is null, set to eth0 OCF_RESKEY_nic="eth0" fi if $IP addr | $GREP $OCF_RESKEY_ip >/dev/null then ocf_log err "Invalid OCF_RESKEY_ip [$OCF_RESKEY_ip]" exit $OCF_ERR_ARGS fi $IP addr add $OCF_RESKEY_ip/32 dev lo if [ -f "$RIPDCONF" ] then # there is a config file, add new data(IP,nic,metric) # to the existing config file. add_ip $OCF_RESKEY_ip add_nic $OCF_RESKEY_nic set_metric 1 reload_config echo sleep 3 sleep 3 set_metric 3 reload_config else new_config_file $OCF_RESKEY_ip $OCF_RESKEY_nic 1 start_quagga echo sleep 3 sleep 3 set_metric 3 reload_config fi return $OCF_SUCCESS } stop_rip_ip() { echo stop_rip_ip check_params status_rip_ip if [ $? = $OCF_NOT_RUNNING ] then ocf_log err "Invalid OCF_RESKEY_ip [$OCF_RESKEY_ip]" exit $OCF_ERR_ARGS fi $IP addr del $OCF_RESKEY_ip dev lo echo sleep 2 sleep 2 del_ip $OCF_RESKEY_ip return $OCF_SUCCESS } status_rip_ip() { check_params if $IP addr | $GREP $OCF_RESKEY_ip >/dev/null then if $GREP $OCF_RESKEY_ip $RIPDCONF >/dev/null then if pidof ripd >/dev/null then return $OCF_SUCCESS fi fi fi return $OCF_NOT_RUNNING } if [ $# -ne 1 ] then usage exit $OCF_ERR_ARGS fi case $1 in start) start_rip_ip;; stop) stop_rip_ip;; status) status_rip_ip;; monitor) status_rip_ip;; validate-all) exit $OCF_SUCCESS;; meta-data) meta_data;; usage) usage; exit $OCF_SUCCESS;; *) usage exit $OCF_ERR_ARGS ;; esac diff --git a/heartbeat/WinPopup.in b/heartbeat/WinPopup.in index 6408d1772..f7f010922 100644 --- a/heartbeat/WinPopup.in +++ b/heartbeat/WinPopup.in @@ -1,231 +1,230 @@ #!/bin/sh # # Resource script for sending WinPopups using smbclient # derived from Alan Robertson's MailTo script # # Author: Sandro Poppi # # Description: sends WinPopups to a sysadmin's workstation # whenever a takeover occurs. # # OCF parameters are as below: # OCF_RESKEY_hostfile # # where "hostfile" is a file containing the IPs/Workstation names # one by line to be sent WinPopups # # License: GNU General Public License (GPL) -VARRUN=@localstatedir@/run -WINPOPUPFILE=$VARRUN/WinPopup +WINPOPUPFILE=@HA_VARRUNDIR@/WinPopup ####################################################################### # Initialization: # Source function library. . @hb_libdir@/ocf-shellfuncs ####################################################################### us=`uname -n` usage() { echo "Usage: $0 {start|stop|status|monitor|validate-all|meta-data}" } meta_data() { cat < 1.0 Resource script for WinPopup. It sends WinPopups message to a sysadmin's workstation whenever a takeover occurs. WinPopup resource agent The file containing the hosts to send WinPopup messages to. Host file END } sendWinPopup() { # if workstation file exists and is not zero if [ -s "$hostfile" ] ; then subject=$1 shift for i in `cat $hostfile` ; do echo "$subject $*" | smbclient -M $i >/dev/null 2>&1 done else ocf_log err "Workstation file $hostfile missing or corrupt!" return $OCF_ERR_ARGS fi return $? } SubjectLine() { case $1 in ??*) echo $1;; *) echo "Resource Group";; esac } WinPopupStart() { Subject="`SubjectLine $2` Takeover in progress on $us" if sendWinPopup "$Subject" $1; then touch $WINPOPUPFILE return $? else return $? fi } WinPopupStop () { Subject="`SubjectLine $2` Reestablishing original master connection in progress on $us" if sendWinPopup "$Subject" $1; then rm -f $WINPOPUPFILE return $? else return $? fi } WinPopupStatus () { ocf_log warn "Don't stat/monitor me! WinPopup is a pseudo resource agent, so the status reported may be incorrect" if [ -f $WINPOPUPFILE ]; then echo "running" return $OCF_SUCCESS else echo "stopped" return $OCF_NOT_RUNNING fi } # A not reliable IP address checking function, which only picks up those _obvious_ violations... # # It accepts IPv4 address in dotted quad notation, for example "192.168.1.1" # # 100% confidence whenever it reports "negative", # but may get false "positive" answer. # CheckIP() { ip="$1" case $ip in *[^0-9.]*) #got invalid char false;; .*|*.) #begin or end by ".", which is invalid false;; *..*) #consecutive ".", which is invalid false;; *.*.*.*.*) #four decimal dots, which is too many false;; *.*.*.*) #exactly three decimal dots, candidate, evaluate each field local IFS=. set -- $ip if ( [ $1 -le 254 ] && [ $2 -le 254 ] && [ $3 -le 254 ] && [ $4 -le 254 ] ) then true fi ;; *) #less than three decimal dots false;; esac return $? # This return is unnecessary, this comment too :) } WinPopupValidateAll () { if [ ! -s "$hostfile" ] ; then ocf_log err "Workstation file $hostfile missing or corrupt!" return $OCF_ERR_ARGS fi # What kind of hostfiles are valid? # We stick to the definition that, a hostfile is valid if and only if it # contains at least one valid host to send WinPopup message to. # have_valid_host=no for host in `cat $hostfile`; do nmblookup $host 2>&1 | grep -q "failed to find name $host\>" if [ $? -ne 0 ]; then # have_valid_host=yes return $OCF_SUCCESS fi # $host is not a netbios name, an IP address maybe? if CheckIP "$host"; then # have_valid_host=yes return $OCF_SUCCESS fi done ocf_log err "Workstation file $hostfile contains no valid host!" return $OCF_ERR_CONFIGURED } if ( [ $# -ne 1 ] ) then usage exit $OCF_ERR_ARGS fi # See how the environment virables were set. hostfile=${OCF_RESKEY_hostfile:-hosts} case "$1" in meta-data) meta_data exit $OCF_SUCCESS ;; start) WinPopupStart ;; stop) WinPopupStop ;; # Not quite sure what to do with this one... status|monitor) WinPopupStatus ;; validate-all) WinPopupValidateAll ;; usage) usage exit $OCF_SUCCESS ;; *) usage exit $OCF_ERR_UNIMPLEMENTED ;; esac exit $? diff --git a/heartbeat/Xinetd.in b/heartbeat/Xinetd.in index ec250d507..fabcab1d9 100644 --- a/heartbeat/Xinetd.in +++ b/heartbeat/Xinetd.in @@ -1,461 +1,460 @@ #!/bin/sh # # Startup/shutdown script for services managed by xinetd. # # Copyright (C) 2003 Charlie Brooks # # WARNING: Tested ONLY on Red Hat 7.3 and Fedora Core 2/4 at this time. # # Author: Charlie Brooks # Description: given parameters of a service name and start|stop|status, # will enable, disable or report on a specified xinetd service # Config: all services must have a descriptor file in /etc/xinetd.d # Support: linux-ha@lists.linux-ha.org # License: GNU General Public License (GPL) # # OCF parameters are as below: # OCF_RESKEY_service -VARRUN=@localstatedir@/run -ETC=@sysconfdir@ -XPIDFILE=$VARRUN/xinetd.pid +HA_VARRUNDIR=@HA_VARRUNDIR@ +XPIDFILE=$HA_VARRUNDIR/xinetd.pid ####################################################################### # Initialization: . @hb_libdir@/ocf-shellfuncs ####################################################################### AWK=@AWK@ meta_data() { cat < 1.0 Resource script for Xinetd. It startup/shutdown the services mananged by xinetd. Xinetd resource agent The service name managed by xinetd. service name END } # It's important to note that the absence of a xinetd PID file causes # this script to assume that xinetd is not yet running, and therefore # that we are in the initial boot process. If you port this script to # a distro that keeps the pid files in some other place, be sure to # make an appropriate revision. hup_inetd () { if [ -s $XPIDFILE ]; then if kill -HUP `cat $XPIDFILE`; then : else ocf_log err "Could not SigHUP xinetd superdaemon!" ocf_log err "perhaps we are booting after a system crash" exit $OCF_ERR_GENERIC fi else ocf_log info "xinetd superdaemon PID file $XPIDFILE not found!" ocf_log info "perhaps we are currently booting the system." fi } xup_start () { if [ "running" = "`xup_status`" ]; then ocf_log info "Service $service already started" exit $OCF_SUCCESS fi ocf_log "info" "$0: enabling in $RCFILE" if $AWK '!/disable/' $RCFILE > $RCFILE.xup then if mv $RCFILE.xup $RCFILE then ocf_log "info" "$0: Starting" hup_inetd touch $PIDFILE else ocf_log "err" "Could not replace $RCFILE" fi else ocf_log "err" "Could not rewrite $RCFILE!" fi } xup_stop () { if [ "stopped" = "`xup_status`" ]; then ocf_log info "Service $service already stopped" exit $OCF_SUCCESS fi ocf_log "info" "$0: disabling in $RCFILE" if $AWK '!/disable/;/{/{printf "\tdisable\t\t\t= yes\n"}' $RCFILE >$RCFILE.xup then if mv $RCFILE.xup $RCFILE then ocf_log "info" "$0: Shutting down" hup_inetd rm -f $PIDFILE else ocf_log "err" "Could not replace $RCFILE" fi else ocf_log "err" "Could not rewrite $RCFILE!" fi } xup_usage () { echo "Usage: $0 {start|stop|restart|status|monitor|validate-all|meta-data}" return 0 } xup_status () { if [ -f $PIDFILE ]; then echo running return $OCF_SUCCESS else echo stopped return $OCF_NOT_RUNNING fi } # # Check if the arg is a valid integer # CheckInteger() { # Examples of valid integer: "1080", "1", "0080", "0", "0000" # Examples of invalid integer: "1080bad", "" case "$1" in "") #empty string false;; *[^0-9]*) #got invalid char false;; *) #no invalid char, and has at least one digit, so is a good integer true;; esac } # # Check if the arg is a valid umask # CheckUmask() { # Examples of valid umask: "100", "1", "000", "0" # Examples of invalid umask: "108", "bad", "1111" "" case "$1" in [0-7]) true;; [0-7][0-7]) true;; [0-7][0-7][0-7]) true;; *) false;; esac } # Check (part of) the attributes based on xinetd.conf(5) and xinetd source code # confparse.c # parsers.c # attr.h check_attributes () { # Empty these attributes before validating them unset socket_type wait server user protocol port group instances \ type flags disable nice umask export $* if [ $? -ne 0 ]; then return $OCF_ERR_GENERIC fi case $disable in "") disable=no # Default to no. ;; yes|no) ;; *) ocf_log err "Invalid value for disable [$disable] in $RCFILE, yes|no please" exit $OCF_ERR_CONFIGURED ;; esac case $socket_type in "") socket_type=dgram # Default value for socket_type is dgram. ;; stream|dgram|raw|seqpacket) ;; *) ocf_log err "Invalid socket type $socket_type in $RCFILE" exit $OCF_ERR_CONFIGURED ;; esac case $wait in # Wait has no default value. yes|no) ;; *) ocf_log err "Invalid waid [$wait] in $RCFILE, yes|no please" exit $OCF_ERR_CONFIGURED ;; esac case $type in # Default value for type is RPC or INTERNAL, determined at compile time. # It may be a list in $RCFILE, however we only capture the first one. ""|RPC|INTERNAL|UNLISTED|SPECIAL|TCPMUX|TCPMUXPLUS) ;; *) ocf_log err "Invalid service type [$type] in $RCFILE" exit $OCF_ERR_CONFIGURED ;; esac if [ ! -z $type -a "INTERNAL" != "$type" ]; then # Type is explicitly set to EXTERNAL, hence server and user are necessary. case $server in "") ocf_log err "Please specify server in $RCFILE" exit $OCF_ERR_CONFIGURED ;; /*) if [ -x $server ]; then : OK else ocf_log err "Server $server is not executable" exit $OCF_ERR_CONFIGURED fi ;; *) ocf_log err "Server $server is not of obsolute path" exit $OCF_ERR_CONFIGURED ;; esac case $user in "") ocf_log err "Please specify user in $RCFILE" exit $OCF_ERR_CONFIGURED ;; *) getent passwd $user >/dev/null 2>&1 if [ $? -ne 0 ]; then ocf_log err "User $user does not exist!" exit $OCF_ERR_CONFIGURED fi ;; esac # Protocol is necessary when type is MUX if [ $type = "TCPMUX" -o $type ="TCPMUXPLUS" ]; then case $protocol in "") ocf_log err "Please specify protocol in $RCFILE" exit $OCF_ERR_CONFIGURED ;; *) get protocols $protocol >/dev/null 2>&1 if [ $? -ne 0 ]; then ocf_log err "Invalid protocol [$protocol] in $RCFILE" exit $OCF_ERR_CONFIGURED fi ;; esac fi fi case $group in "") ;; # OK to be empty, the group for $user is used *) getent group $group >/dev/null 2>&1 if [ $? -ne 0 ]; then ocf_log err "Group $group does not exist!" exit $OCF_ERR_CONFIGURED fi ;; esac case $flags in # Default value for flags is REUSE. # It may be a list in $RCFILE, however we only capture the first one. "") flags=RESUME ;; REUSE|INTERCEPT|NORETRY|IDONLY|NAMEINARGS|NODELAY|KEEPALIVE|NOLIBWRAP|SENSOR|IPv4|IPv6) ;; *) ocf_log err "Invalid flags [$flags] in $RCFILE" exit $OCF_ERR_CONFIGURED ;; esac case $instances in ""|[Uu][Nn][Ll][Ii][Mm][Ii][Ti][Ee][Dd]) ;; *) if CheckInteger $instances; then : OK else ocf_log err "Invalid instances [$instances] in $RCFILE, non-negative integer expected" exit $OCF_ERR_CONFIGURED fi ;; esac case $nice in "") ;; *) local foo=`echo $nice | sed s/^-//` if CheckInteger $foo; then : OK else ocf_log err "Invalid nice [$nice] in $RCFILE, integer expected" exit $OCF_ERR_CONFIGURED fi ;; esac if [ ! -z $umask ]; then if CheckUmask $umask; then : OK else ocf_log err "Invalid umask [$umask] in $RCFILE" exit $OCF_ERR_CONFIGURED fi fi } xup_validate_all () { # Parse the $RCFILE for necessary attributes, assume $RCFILE does not # contain "include" or "includedir" directives. space="[ \t]*" leading_space="^$space" trailing_space="$space$" comment="$space\#" # Strip comments, delete blank lines. stripped=`sed -e "/^$comment/d" -e "/=$trailing_space/d" -e "/$leading_space$/d" $RCFILE` stripped=`echo $stripped` # At this stage, stripped="service { attribute-list }". case $stripped in *#*) ocf_log err "Descriptor file $RCFILE contains extra \"#\", which is forbidden" exit $OCF_ERR_CONFIGURED ;; service*) case $stripped in *[^\ \ +-]=*) ocf_log err "Attribute needs a space before operator =" exit $OCF_ERR_CONFIGURED ;; *[^\ \ ][+-]=*) ocf_log err "Attribute needs a space before operator [+-]=" exit $OCF_ERR_CONFIGURED ;; *) ;; esac # Strip leading "service" keyword, remove spaces surrounding "=". stripped=`echo $stripped | sed -e "s/^service//" -e "s/-=/ /g" \ -e "s/+=/=/g" -e "s/$space=$space/=/g"` # At this stage, stripped=" { attribute-list }", # note that the leading space before is significant. case $stripped in " "*) stripped=`echo $stripped | sed -e "s/$leading_space[^ \t]\+$space//"` # At this stage, stripped="{ attribute-list }" case $stripped in {*}) stripped=`echo $stripped | sed -e "s/^{//" -e "s/}$//"` # At this stage, stripped= # echo $stripped check_attributes "$stripped" ;; *) ocf_log err "Attrbute list should be contained in {}" exit $OCF_ERR_CONFIGURED ;; esac ;; *) ocf_log err "Service name should follow the service key word" exit $OCF_ERR_CONFIGURED ;; esac ;; *) ocf_log err "Service key word is necessary in $RCFILE" exit $OCF_ERR_CONFIGURED ;; esac } if ( [ $# -ne 1 ] ) then xup_usage exit $OCF_ERR_ARGS fi # These operations do not require OCF instance parameters to be set case "$1" in meta-data) meta_data exit $OCF_SUCCESS ;; usage) xup_usage exit $OCF_SUCCESS ;; *) ;; esac if [ -z "$OCF_RESKEY_service" ] then ocf_log err "Please set OCF_RESKEY_service to the service managed by Xinetd" exit $OCF_ERR_ARGS fi service=$OCF_RESKEY_service -RCFILE=$ETC/xinetd.d/$service -PIDFILE=$VARRUN/xup$service +RCFILE=@sysconfdir@/xinetd.d/$service +PIDFILE=$HA_VARRUNDIR/xup$service # Make sure the OCF_RESKEY_service is a valid xinetd service name if [ ! -f $RCFILE ]; then ocf_log err "Service descriptor $RCFILE not found!" exit $OCF_ERR_ARGS fi # See how we were called. case "$1" in start) xup_start ;; stop) xup_stop ;; restart) $0 stop $0 start ;; status|monitor) xup_status ;; validate-all) xup_validate_all ;; *) xup_usage exit $OCF_ERR_UNIMPLEMENTED esac exit $? diff --git a/heartbeat/apache.in b/heartbeat/apache.in index 03ddbfbbb..dab83aac3 100644 --- a/heartbeat/apache.in +++ b/heartbeat/apache.in @@ -1,603 +1,603 @@ #!/bin/sh # # High-Availability Apache/IBMhttp control script # # apache (aka IBMhttpd) # # Description: starts/stops apache web servers. # # Author: Alan Robertson # Sun Jiang Dong # # Support: linux-ha@lists.linux-ha.org # # License: GNU General Public License (GPL) # # Copyright: (C) 2002-2005 International Business Machines # # # An example usage in /etc/ha.d/haresources: # node1 10.0.0.170 apache::/opt/IBMHTTPServer/conf/httpd.conf # node1 10.0.0.170 IBMhttpd # # Our parsing of the Apache config files is very rudimentary. # It'll work with lots of different configurations - but not every # possible configuration. # # Patches are being accepted ;-) # # OCF parameters: # OCF_RESKEY_configfile # OCF_RESKEY_httpd # OCF_RESKEY_port # OCF_RESKEY_statusurl # OCF_RESKEY_options -VARRUN=@localstatedir@/run +HA_VARRUNDIR=@HA_VARRUNDIR@ . @hb_libdir@/ocf-shellfuncs ####################################################################### # # Configuration options - usually you don't need to change these # ####################################################################### # IBMHTTPD=/opt/IBMHTTPServer/bin/httpd HTTPDLIST="/sbin/httpd2 /usr/sbin/httpd2 /sbin/httpd /usr/sbin/httpd $IBMHTTPD" MPM=/usr/share/apache2/find_mpm if [ -x $MPM ] then HTTPDLIST="$HTTPDLIST `$MPM 2>/dev/null`" fi WGETNAME=wget WGETOPTS="-O- -nv" LOCALHOST="http://localhost" HTTPDOPTS="-DSTATUS" DEFAULT_IBMCONFIG=/opt/IBMHTTPServer/conf/httpd.conf DEFAULT_NORMCONFIG="/etc/apache2/httpd.conf" # # You can also set # HTTPD # PORT # STATUSURL # CONFIGFILE # in this section if what we're doing doesn't work for you... # # End of Configuration options ####################################################################### CMD=`basename $0` # The config-file-pathname is the pathname to the configuration # file for this web server. Various appropriate defaults are # assumed if no config file is specified. If this command is # invoked as *IBM*, then the default config file name is # $DEFAULT_IBMCONFIG, otherwise the default config file # will be $DEFAULT_NORMCONFIG. usage() { cat <<-! usage: $0 action action: start start the web server stop stop the web server status return the status of web server, run or down monitor return TRUE if the web server appears to be working. For this to be supported you must configure mod_status and give it a server-status URL. You have to have installed $WGETNAME for this to work. meta-data show meta data message validate-all validate the instance parameters ! exit $OCF_ERR_ARGS } IncludeLine() { file=`echo "$1" | sed -e 's%Include *%%' -e 's%[ ]*$%%'` ExpandMe $file } ExpandMe() { out=/tmp/$$.out for file in "$@" do if [ ! -f $file ] then continue fi while read line do case $line in "Include "*) IncludeLine "$line";; *) echo "$line";; esac done < "$file" done } # # Strip comments, and initial blanks. Compress other blanks. Delete lines of blanks only. # apachecat() { ExpandMe "$@" | sed -e 's%#.*%%' -e '/^[ ]*$/d' -e 's%^[ ]*%%' -e 's%[ ]+% %g' } # # Return the value of a parameter in our apache config file # apache_param() { configfile=$1 varname=$2 if apachecat $1 | grep -i "^$varname " | \ sed -e 's%^[^ ]* %%' -e 's%^"%%' -e 's%"$%%' -e 's%^[[:blank:]]*%%' -e 's%[[:blank:]]*$%%' then : OK else false fi } # # Return TRUE if the config file supports the given handler somewhere # SupportsHandler() { apache_param "$1" SetHandler | grep "^ *$2 *" >/dev/null } # # return true if the given module is loaded... # Module_loaded() { apache_param "$1" AddModule | grep -i "^mod_$2\." >/dev/null if [ $? = 0 ] then true else apache_param "$1" LoadModule | grep -i "mod_$2\." >/dev/null fi } # # Return the location(s) that are handled by the given handler # FindLocationForHandler() { PerlScript='while (<>) { /"]+)/i && ($loc=$1); '"/SetHandler +$2"'/i && print "$loc\n"; }' apachecat $1 | perl -e "$PerlScript" } # # Check if the port is valid # CheckPort() { ocf_is_decimal "$1" && [ $1 -gt 0 ] } # # Get all the parameters we need from the Apache config file # GetParams() { ConfigFile=$1 ServerRoot=`apache_param "$ConfigFile" ServerRoot` PidFile=`apache_param "$ConfigFile" PidFile` case $PidFile in /*) ;; [[:alnum:]]*) PidFile=$ServerRoot/$PidFile;; - *) PidFile=$VARRUN/${httpd_basename}.pid;; + *) PidFile=$HA_VARRUNDIR/${httpd_basename}.pid;; esac # case "$PORT" in # [0-9]*) ;; # *) PORT=`apache_param "$ConfigFile" Port` # case "$PORT" in # [0-9]*) ;; # *) PORT=80;; # esac;; # *) # esac if CheckPort "$PORT"; then : else PORT=`apache_param "$ConfigFile" Port` if CheckPort "$PORT"; then : else # Final resort PORT=80 fi fi if WGET=`which $WGETNAME 2>/dev/null` then : OK else WGET="" fi # # Just because they have mod_status loaded and have a server-status # declared doesn't mean they support the status operation. # # It's actually pretty hard to tell because of run-time defines which # could be turned on elsewhere... # # (we start our server with -DSTATUS - just in case :-)) # # Typically (but not necessarily) the status URL is /server-status # # For us to think status will work, we have to have the following things: # # - $WGET has to exist and be executable # - The mod_status module must be loaded # - The server-status handler has to be mapped to some URL somewhere # # We assume that: # # - the "main" web server at $PORT will also support it if we can find it # somewhere in the file # - it will be supported at the same URL as the one we find in the file # # If this doesn't work for you, then set STATUSURL at the top of the file # HasStatus=no if # && Module_loaded $ConfigFile status [ ! -z "$WGET" -a -x "$WGET" ] \ && SupportsHandler $ConfigFile server-status then StatusURL=`FindLocationForHandler $1 server-status | tail -1` case "$StatusURL" in /*) HasStatus=yes;; esac if [ "X$STATUSURL" = "X" ] then DoIHaveIP=`apache_param "$ConfigFile" Listen|head -1` if [ "x$DoIHaveIP" != "x" ] then STATUSURL="http://${DoIHaveIP}$StatusURL" case $WGET in *wget*) WGETOPTS="$WGETOPTS --bind-address=127.0.0.1";; esac else STATUSURL="${LOCALHOST}:${PORT}$StatusURL" fi fi fi if [ -z "$PidFile" -o ! -f $ConfigFile ] then false else true fi } # # return TRUE if a process with given PID is running # ProcessRunning() { ApachePID=$1 # Use /proc if it looks like it's here... if [ -d /proc -a -d /proc/1 ] then [ -d /proc/$ApachePID ] else # This assumes we're running as root... kill -0 "$ApachePID" >/dev/null 2>&1 fi } silent_status() { if [ -f $PidFile ] then ProcessRunning `cat $PidFile` else : No pid file false fi } start_apache() { if silent_status then ocf_log info "$CMD already running (pid $ApachePID)" return $OCF_SUCCESS fi ocf_run $HTTPD $HTTPDOPTS $OPTIONS -f $CONFIGFILE } stop_apache() { if silent_status then if kill $ApachePID then tries=0 while ProcessRunning $ApachePID && [ $tries -lt 10 ] do sleep 1 kill $ApachePID >/dev/null 2>&1 ocf_log info "Killing apache PID $ApachePID" tries=`expr $tries + 1` done else ocf_log warn "Killing apache PID $ApachePID FAILED." fi if ProcessRunning $ApachePID then ocf_log info "$CMD still running ($ApachePID)." false else ocf_log info "$CMD stopped." fi else ocf_log info "$CMD is not running." fi } status_apache() { silent_status rc=$? if [ $rc -eq 0 ] then ocf_log info "$CMD is running (pid $ApachePID)." return $OCF_SUCCESS else ocf_log info "$CMD is stopped." return $OCF_NOT_RUNNING fi } monitor_apache() { case $HasStatus in no) ocf_log err "Monitoring not supported by $CONFIGFILE" return $OCF_ERR_CONFIGURED;; esac if silent_status then ocf_run sh -c "$WGET $WGETOPTS $STATUSURL | grep -i '' >/dev/null" else ocf_log info "$CMD not running" return $OCF_NOT_RUNNING fi } metadata_apache(){ cat < 1.0 This is the resource agent for the Apache web server. Thie resource agent operates both version 1.x and version 2.x Apache servers. See also http://httpd.apache.org/ Apache web server The full pathname of the Apache configuration file. This file is parsed to provide defaults for various other resource agent parameters. configuration file path The full pathname of the httpd binary (optional). httpd binary path A port number that we can probe for status information using the statusurl. This will default to the port number found in the configuration file, or 80, if none can be found in the configuration file. httpd port The URL of the apache status module. If left unspecified, it will be inferred from the apache configuration file. url name Extra options to apply when starting apache. See man httpd(8). command line options END exit $OCF_SUCCESS } validate_all_apache() { if CheckPort $PORT; then # We are sure to succeed here, since we forced $PORT to be valid in GetParams() : OK else ocf_log err "Port number $PORT is invalid!" exit $OCF_ERR_ARGS fi if [ -z $STATUSURL ]; then : OK to be empty else case $STATUSURL in http://*/*) ;; *) ocf_log err "Invalid STATUSURL $STATUSURL" exit $OCF_ERR_ARGS ;; esac fi if [ ! -x $HTTPD ]; then ocf_log err "HTTPD $HTTPD not found or is not an executable!" exit $OCF_ERR_ARGS fi if [ ! -f $CONFIGFILE ]; then # We are sure to succeed here, since we have parsed $CONFIGFILE before getting here ocf_log err "Configuration file $CONFIGFILE not found!" exit $OCF_ERR_CONFIGURED fi return $OCF_SUCCESS } if [ $# -eq 1 ] then COMMAND=$1 HTTPD="$OCF_RESKEY_httpd" PORT="$OCF_RESKEY_port" STATUSURL="$OCF_RESKEY_statusurl" CONFIGFILE="$OCF_RESKEY_configfile" OPTIONS="$OCF_RESKEY_options" else usage fi LSB_STATUS_STOPPED=3 if [ "X$HTTPD" = X -o ! -f "$HTTPD" -o ! -x "$HTTPD" ] then case $0 in *IBM*) HTTPD=$IBMHTTPD DefaultConfig=$DEFAULT_IBMCONFIG;; *) HTTPD= for h in $HTTPDLIST do if [ -f $h -a -x $h ] then HTTPD=$h break fi done # It is possible that we still do not have a valid httpd at this stage if [ -z "$HTTPD" ] then case $COMMAND in stop) return $OCF_SUCCESS;; monitor) return $OCF_NOT_RUNNING;; status) return $LSB_STATUS_STOPPED;; meta-data) metadata_apache;; esac ocf_log err "No valid httpd found! Please revise your item" exit $OCF_ERR_CONFIGURED fi # Let the user know that the $HTTPD used is not the one (s)he specified via $OCF_RESKEY_httpd if [ "X$OCF_RESKEY_httpd" != X ] then ocf_log info "Using $HTTPD as HTTPD" fi DefaultConfig=$DEFAULT_NORMCONFIG;; esac fi httpd_basename=`basename $HTTPD` case $httpd_basename in *-*) httpd_basename=`echo "$httpd_basename" | sed -e 's%\-.*%%'`;; esac case "$CONFIGFILE" in "") CONFIGFILE=$DefaultConfig;; *) ;; esac if [ ! -f "$CONFIGFILE" ] then case $COMMAND in stop) ocf_log warn "$CONFIGFILE not found - apache considered stopped" exit $OCF_SUCCESS;; monitor) exit $OCF_NOT_RUNNING;; status) exit $LSB_STATUS_STOPPED;; esac fi if [ "X$COMMAND" = Xmeta-data ] || GetParams $CONFIGFILE then : OK else ocf_log err "Cannot parse config file [$CONFIGFILE]" exit $OCF_ERR_CONFIGURED fi case $COMMAND in start) start_apache;; stop) stop_apache;; status) status_apache;; monitor) monitor_apache;; meta-data) metadata_apache;; validate-all) validate_all_apache;; *) usage;; esac diff --git a/heartbeat/ocf-shellfuncs.in b/heartbeat/ocf-shellfuncs.in index 1defed160..caba92119 100644 --- a/heartbeat/ocf-shellfuncs.in +++ b/heartbeat/ocf-shellfuncs.in @@ -1,207 +1,206 @@ # # # Common helper functions for the OCF Resource Agents supplied by # heartbeat. # # Copyright (c) 2004 SUSE LINUX AG, Lars Marowsky-Brée # All Rights Reserved. # # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # TODO: Some of this should probably split out into a generic OCF # library for shell scripts, but for the time being, we'll just use it # ourselves... # # TODO wish-list: # - Generic function for evaluating version numbers # - Generic function(s) to extract stuff from our own meta-data # - Logging function which automatically adds resource identifier etc # prefixes # TODO: Move more common functionality for OCF RAs here. # # This was common throughout all legacy Heartbeat agents unset LC_ALL; export LC_ALL unset LANGUAGE; export LANGUAGE -HA_D=@sysconfdir@/ha.d __SCRIPT_NAME=`basename $0` -. ${HA_D}/shellfuncs +. @HA_HBCONF_DIR@/shellfuncs . @hb_libdir@/ocf-returncodes ocf_is_root() { case `id` in *'uid=0(root)'*) true;; *) false;; esac } # Portability comments: # o The following rely on Bourne "sh" pattern-matching, which is usually # that for filename generation (note: not regexp). # o The "*) true ;;" clause is probably unnecessary, but is included # here for completeness. # o The negation in the pattern uses "!". This seems to be common # across many OSes (whereas the alternative "^" fails on some). # o If an OS is encountered where this negation fails, then a possible # alternative would be to replace the function contents by (e.g.): # [ -z "`echo $1 | tr -d '[0-9]'`" ] # ocf_is_decimal() { case "$1" in ""|*[!0-9]*) # empty, or at least one non-decimal false ;; *) true ;; esac } ocf_is_hex() { case "$1" in ""|*[!0-9a-fA-F]*) # empty, or at least one non-hex false ;; *) true ;; esac } ocf_is_octal() { case "$1" in ""|*[!0-7]*) # empty, or at least one non-octal false ;; *) true ;; esac } __ocf_set_defaults() { __OCF_ACTION="$1" # Return to sanity for the agents... unset LANG LC_ALL=C export LC_ALL # TODO: Review whether we really should source this. Or rewrite # to match some emerging helper function syntax...? This imports # things which no OCF RA should be using... # Strip the OCF_RESKEY_ prefix from this particular parameter if [ -z "$OCF_RESKEY_OCF_CHECK_LEVEL" ]; then : ${OCF_CHECK_LEVEL:=0} else : ${OCF_CHECK_LEVEL:=$OCF_RESKEY_OCF_CHECK_LEVEL} fi if [ -z "$OCF_ROOT" ]; then : ${OCF_ROOT=@OCF_ROOT_DIR@} fi if [ ! -d "$OCF_ROOT" ]; then ha_log "ERROR: OCF_ROOT points to non-directory $OCF_ROOT." exit $OCF_ERR_GENERIC fi if [ -z "$OCF_RESOURCE_TYPE" ]; then : ${OCF_RESOURCE_TYPE:=$__SCRIPT_NAME} fi if [ -z "$OCF_RA_VERSION_MAJOR" ]; then : We are being invoked as an init script. : Fill in some things with reasonable values. : ${OCF_RESOURCE_INSTANCE:="default"} return 0 fi # TODO: Anything else we should be setting and thus checking? # There is nothing in this script which depends on the version # of the API. TESTING THIS HERE IS A BUG. THIS SHOULD BE # tested by the script that's invoked us. FIXME!! if [ "x$OCF_RA_VERSION_MAJOR" != "x1" ]; then ha_log "ERROR: This script is OCF RA API 1.x compliant only!" exit $OCF_ERR_UNIMPLEMENTED fi # TODO: Should the minor level really be a number and not rather # a list of flags...? # AlanR says -- absolutely not -- a list of flags is good for a list # of implemented features, not a version compiliance # perhaps some future version might have such a list of # flags, but that would be _in addition to_ the minor version number if [ -z "$OCF_RA_VERSION_MINOR" ]; then ha_log "ERROR: No OCF RA minor version set." exit $OCF_ERR_UNIMPLEMENTED fi if [ "x$__OCF_ACTION" = "xmeta-data" ]; then OCF_RESOURCE_INSTANCE="undef" fi if [ -z "$OCF_RESOURCE_INSTANCE" ]; then ha_log "ERROR: Need to tell us our resource instance name." exit $OCF_ERR_ARGS fi } ocf_log() { # TODO: Revisit and implement internally. if [ $# -lt 2 ] then ocf_log err "Not enough arguments [$#] to ocf_log." fi __OCF_PRIO="$1" shift __OCF_MSG="$*" case "${__OCF_PRIO}" in crit) __OCF_PRIO="CRIT";; err) __OCF_PRIO="ERROR";; warn) __OCF_PRIO="WARNING";; info) __OCF_PRIO="INFO";; debug)__OCF_PRIO="DEBUG";; *) __OCF_PRIO=`echo ${__OCF_PRIO}| tr '[a-z]' '[A-Z]'`;; esac ha_log "${__OCF_PRIO}: $__OCF_MSG" } # # Ocf_run: Run a script, and log its output. # Usage: ocf_run # ocf_run() { output=`"$@" 2>&1` rc=$? output=`echo $output` if [ $rc -eq 0 ]; then if [ ! -z "$output" ]; then ocf_log info "$output" fi return $OCF_SUCCESS else if [ ! -z "$output" ]; then ocf_log err "$output" else ocf_log err "command failed: $*" fi return $OCF_ERR_GENERIC fi } __ocf_set_defaults "$@" diff --git a/heartbeat/pingd.in b/heartbeat/pingd.in index f41332630..17bedae90 100644 --- a/heartbeat/pingd.in +++ b/heartbeat/pingd.in @@ -1,262 +1,262 @@ #!/bin/sh # # # pingd OCF Resource Agent # Records (in the CIB) the current number of ping nodes a # cluster node can connect to. # # Copyright (c) 2006 Andrew Beekhof # 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. # ####################################################################### # Initialization: . @hb_libdir@/ocf-shellfuncs ####################################################################### -HA_VARRUNDIR=@localstatedir@/run/@HB_PKG@ +HA_VARRUNHBRSCDIR=@HA_VARRUNHBRSCDIR@ meta_data() { cat < 1.0 This is a pingd Resource Agent. It records (in the CIB) the current number of ping nodes a node can connect to. pingd resource agent PID file PID file - + The user we want to run pingd as The user we want to run pingd as The time to wait (dampening) further changes occur Dampening interval The name of the instance_attributes set to place the value in. Rarely needs to be specified. Set name The name of the attributes to set. This is the name to be used in the constraints. Attribute name The section place the value in. Rarely needs to be specified. Section name The number by which to multiply the number of connected ping nodes by Value multiplier The list of ping nodes to count. Defaults to all configured ping nodes. Rarely needs to be specified. Host list END } ####################################################################### pingd_usage() { cat </dev/null if [ $? -eq 0 ]; then : Yes, user exists. We can further check his permission on crm_mon if necessary else ocf_log err "The user $OCF_RESKEY_user does not exist!" exit $OCF_ERR_ARGS fi fi # Pidfile better be an absolute path case $OCF_RESKEY_pidfile in /*) ;; *) ocf_log warn "You should have pidfile($OCF_RESKEY_pidfile) of absolute path!" ;; esac # Check the update interval if ocf_is_decimal "$OCF_RESKEY_update" && [ $OCF_RESKEY_update -gt 0 ]; then : else ocf_log err "Invalid update interval $OCF_RESKEY_update. It should be positive integer!" exit $OCF_ERR_ARGS fi echo "Validate OK" return $OCF_SUCCESS } if [ $# -ne 1 ]; then pingd_usage exit $OCF_ERR_ARGS fi -: ${OCF_RESKEY_pidfile:="$HA_VARRUNDIR/rsctmp/pingd-${OCF_RESOURCE_INSTANCE}"} +: ${OCF_RESKEY_pidfile:="$HA_VARRUNHBRSCDIR/pingd-${OCF_RESOURCE_INSTANCE}"} : ${OCF_RESKEY_name:="pingd"} : ${OCF_RESKEY_dampen:="1s"} case $__OCF_ACTION in meta-data) meta_data exit $OCF_SUCCESS ;; start) pingd_start ;; stop) pingd_stop ;; monitor) pingd_monitor ;; validate-all) pingd_validate ;; usage|help) pingd_usage exit $OCF_SUCCESS ;; *) pingd_usage exit $OCF_ERR_UNIMPLEMENTED ;; esac exit $? diff --git a/heartbeat/portblock.in b/heartbeat/portblock.in index 5241a3bce..adb69c1d0 100644 --- a/heartbeat/portblock.in +++ b/heartbeat/portblock.in @@ -1,362 +1,361 @@ #!/bin/sh # # portblock: iptables temporary portblocking control # # Author: Sun Jiang Dong # # License: GNU General Public License (GPL) # # Copyright: (C) 2005 International Business Machines # # OCF parameters are as below: # OCF_RESKEY_protocol # OCF_RESKEY_portno # OCF_RESKEY_action ####################################################################### # Initialization: . @hb_libdir@/ocf-shellfuncs -. @sysconfdir@/ha.d/shellfuncs +. @HA_HBCONF_DIR@/shellfuncs ####################################################################### -HA_VARRUNDIR=@localstatedir@/run/@HB_PKG@ CMD=`basename $0` iptables=@IPTABLES@ usage() { cat <<-!USAGE >&2 usage: $CMD {start|stop|status|monitor|meta-data|validate-all} $CMD is used to temporarily block ports using iptables. It can be used to turn off a port before bringing up an IP address, and enable it after a service is started. To do that for samba, the following resource line can be used: $CMD::tcp::137,138::block \\ 10.10.10.20 \\ nmbd smbd \\ $CMD::tcp::137,138::unblock This will do the follwing things: - DROP all incoming packets for TCP ports 137 and 138 - Bring up the IP alias 10.10.10.20 - start the nmbd and smbd services - Re-enable TCP ports 137 and 138 (enable normal firewall rules on those ports) This prevents clients from getting ICMP port unreachable if they try to reconnect to the service after the alias is enabled but before nmbd and smbd are running. These packets will cause some clients to give up attempting to reconnect to the server. NOTE: iptables is linux-specific... !USAGE } meta_data() { cat < 1.0 Resource script for portblock. It is used to temporarily block ports using iptables. portblock resource agent The protocol used to be blocked/unblocked. protocol The port number used to be blocked/unblocked. portno The action (block/unblock) to be done on the protocol::portno. action END } # # Because this is the normal usage, we consider "block" # resources to be pseudo-resources -- that is, their status can't # be reliably determined through external means. # This is because we expect an "unblock" resource to come along # and disable us -- but we're still in some sense active... # # So, we track the state here using the pseudo_resource() function. # # The psuedo_resource function should be moved into the functions # available to resources so other resource scripts could use it... # # # pseudo_resource filename operation pseudo_resource() { ha_pseudo_resource $* } #iptables_spec {udp|tcp} portno,portno iptables_spec() { echo -D INPUT -p $1 -m multiport --dports $2 -j DROP } #active_grep_pat {udp|tcp} portno,portno active_grep_pat() { w="[ ][ ]*" any="0\\.0\\.0\\.0/0" echo "^DROP${w}${1}${w}--${w}${any}${w}${any}${w}multiport${w}dports${w}${2} " } #chain_isactive {udp|tcp} portno,portno chain_isactive() { PAT=`active_grep_pat "$1" "$2"` $iptables -n -L INPUT | grep "$PAT" >/dev/null } SayActive() { echo "$CMD DROP rule for INPUT chain [$*] is running (OK)" return 0 } SayConsideredActive() { echo "$CMD DROP rule for INPUT chain [$*] considered to be running (OK)" return 0 } SayInactive() { echo "$CMD DROP rule for INPUT chain [$*] is inactive" return 1 } #IptablesStatus {udp|tcp} portno,portno {block|unblock} IptablesStatus() { activewords="$CMD $1 $2 is running (OK)" if chain_isactive "$1" "$2" then case $3 in block) SayActive $*;; *) SayInactive $*;; esac else case $3 in block) if pseudo_resource "$RSCNAME" status then SayConsideredActive $* else SayInactive $* fi;; *) SayActive $*;; esac fi return $? } #IptablesBLOCK {udp|tcp} portno,portno IptablesBLOCK() { if chain_isactive "$1" "$2" then : OK -- chain already active else $iptables -I INPUT -p "$1" -m multiport --dports "$2" -j DROP fi return $? } #IptablesUNBLOCK {udp|tcp} portno,portno IptablesUNBLOCK() { if chain_isactive "$1" "$2" then $iptables -D INPUT -p "$1" -m multiport --dports "$2" -j DROP else : Chain Not active fi return $? } #IptablesStart {udp|tcp} portno,portno {block|unblock} IptablesStart() { pseudo_resource "$RSCNAME" start case $3 in block) IptablesBLOCK "$@";; unblock) IptablesUNBLOCK "$@";; *) usage; return 1; esac return $? } #IptablesStop {udp|tcp} portno,portno {block|unblock} IptablesStop() { pseudo_resource "$RSCNAME" stop case $3 in block) IptablesUNBLOCK "$@";; unblock) IptablesBLOCK "$@";; *) usage; return 1;; esac return $? } # # Check if the port is valid, this function code is not decent, but works # CheckPort() { # Examples of valid port: "1080", "1", "0080" # Examples of invalid port: "1080bad", "0", "0000", "" case "$1" in *[^0-9]*) #got invalid char false;; *[1-9]*) #no invalid char, and has non-zero digit, so is a good port true;; *) #empty string, or string of 0's false;; esac } IptablesValidateAll() { case $protocol in tcp|udp) ;; *) ocf_log err "Invalid protocol $protocol!" exit $OCF_ERR_ARGS ;; esac if CheckPort "$portno"; then : else ocf_log err "Invalid port number $portno!" exit $OCF_ERR_ARGS fi case $action in block|unblock) ;; *) ocf_log err "Invalid action $action!" exit $OCF_ERR_ARGS ;; esac return $OCF_SUCCESS } if ( [ $# -ne 1 ] ) then usage exit $OCF_ERR_ARGS fi case $1 in meta-data) meta_data exit $OCF_SUCCESS ;; usage) usage exit $OCF_SUCCESS ;; *) ;; esac if [ -z "$OCF_RESKEY_protocol" ]; then ocf_log err "Please set OCF_RESKEY_protocol" exit $OCF_ERR_ARGS fi if [ -z "$OCF_RESKEY_portno" ]; then ocf_log err "Please set OCF_RESKEY_portno" exit $OCF_ERR_ARGS fi if [ -z "$OCF_RESKEY_action" ]; then ocf_log err "Please set OCF_RESKEY_action" exit $OCF_ERR_ARGS fi protocol=$OCF_RESKEY_protocol portno=$OCF_RESKEY_portno action=$OCF_RESKEY_action RSCNAME=${CMD}_${protocol}_${portno}_${action} case $1 in start) IptablesStart $protocol $portno $action ;; stop) IptablesStop $protocol $portno $action ;; status|monitor) IptablesStatus $protocol $portno $action ;; validate-all) IptablesValidateAll ;; *) usage exit $OCF_ERR_UNIMPLEMENTED ;; esac exit $? diff --git a/heartbeat/rsyncd.in b/heartbeat/rsyncd.in index 8e73b04c0..7bbb1244c 100644 --- a/heartbeat/rsyncd.in +++ b/heartbeat/rsyncd.in @@ -1,270 +1,269 @@ #!/bin/sh # # Resource script for rsync daemon # # Description: Manages rsync daemon as an OCF resource in # an High Availability setup. # # Author: Dhairesh Oza # License: GNU General Public License (GPL) # # # usage: $0 {start|stop|status|monitor|validate-all|meta-data} # # The "start" arg starts rsyncd. # # The "stop" arg stops it. # # OCF parameters: # OCF_RESKEY_binpath # OCF_RESKEY_conffile # OCF_RESKEY_bwlimit # # Note:This RA requires that the rsyncd config files has a "pid file" # entry so that it is able to act on the correct process ########################################################################## # Initialization: . @hb_libdir@/ocf-shellfuncs -HA_VARRUNDIR=@localstatedir@/run/@HB_PKG@ USAGE="Usage: $0 {start|stop|status|monitor|validate-all|meta-data}"; ########################################################################## usage() { echo $USAGE >&2 } meta_data() { cat < 1.0 This script manages rsync daemon OCF Resource Agent compliant rsync daemon script. The rsync binary path. For example, "/usr/bin/rsync" Full path to the rsync binary The rsync daemon configuration file name with full path. For example, "/etc/rsyncd.conf" Configuration file name with full path This option allows you to specify a maximum transfer rate in kilobytes per second. This option is most effective when using rsync with large files (several megabytes and up). Due to the nature of rsync transfers, blocks of data are sent, then if rsync determines the transfer was too fast, it will wait before sending the next data block. The result is an average transfer rate equaling the specified limit. A value of zero specifies no limit. limit I/O bandwidth, KBytes per second END exit $OCF_SUCCESS } get_pid_and_conf_file() { if [ -n "$OCF_RESKEY_conffile" ]; then CONF_FILE=$OCF_RESKEY_conffile else CONF_FILE="/etc/rsyncd.conf" fi grep -v "^#" "$CONF_FILE" | grep "pid file" > /dev/null if [ $? -eq 0 ]; then PIDFILE=`grep -v "^#" "$CONF_FILE" | grep "pid file" | awk -F "=" '{ print $2 }'` fi } rsyncd_status() { if [ -n "$PIDFILE" -a -f $PIDFILE ]; then # rsync is probably running PID=`cat $PIDFILE` if [ -n "$PID" ]; then if ps -p $PID | grep rsync >/dev/null ; then ocf_log info "rsync daemon running" return $OCF_SUCCESS else ocf_log info "rsync daemon is not running but pid file exists" return $OCF_ERR_GENERIC fi else ocf_log err "PID file empty!" return $OCF_ERR_GENERIC fi fi # rsyncd is not running ocf_log info "rsync daemon is not running" return $OCF_NOT_RUNNING } rsyncd_start() { # if rsyncd is running return success rsyncd_status retVal=$? if [ $retVal -eq $OCF_SUCCESS ]; then exit $OCF_SUCCESS elif [ $retVal -ne $OCF_NOT_RUNNING ]; then ocf_log err "Error. Unknown status." exit $OCF_ERR_GENERIC fi if [ -n "$OCF_RESKEY_binpath" ]; then COMMAND="$OCF_RESKEY_binpath --daemon" else COMMAND="rsync --daemon" fi if [ -n "$OCF_RESKEY_conffile" ]; then COMMAND="$COMMAND --config $OCF_RESKEY_conffile" fi if [ -n "$OCF_RESKEY_bwlimit" ]; then COMMAND="$COMMAND --bwlimit $OCF_RESKEY_bwlimit" fi if grep -v "^#" "$CONF_FILE" | grep "pid file" > /dev/null ; then $COMMAND; if [ $? -ne 0 ]; then ocf_log err "Error. rsycn daemon returned error $?." exit $OCF_ERR_GENERIC fi else ocf_log err "Error. \"pid file\" entry required in the rsyncd config file by rsyncd OCF RA." return $OCF_ERR_GENERIC fi ocf_log info "Started rsync daemon." exit $OCF_SUCCESS } rsyncd_stop() { if rsyncd_status ; then PID=`cat $PIDFILE` if [ -n "$PID" ] ; then kill $PID if [ $? -ne 0 ]; then kill -SIGKILL $PID if [ $? -ne 0 ]; then ocf_log err "Error. Could not stop rsync daemon." return $OCF_ERR_GENERIC fi fi rm $PIDFILE 2>/dev/null fi fi ocf_log info "Stopped rsync daemon." exit $OCF_SUCCESS } rsyncd_monitor() { rsyncd_status } rsyncd_validate_all() { if [ -n "$OCF_RESKEY_binpath" -a ! -x "$OCF_RESKEY_binpath" ]; then ocf_log err "Binary path $OCF_RESKEY_binpath does not exist." exit $OCF_ERR_ARGS fi if [ -n "$OCF_RESKEY_conffile" -a ! -f "$OCF_RESKEY_conffile" ]; then ocf_log err "Config file $OCF_RESKEY_conffile does not exist." exit $OCF_ERR_ARGS fi if grep -v "^#" "$CONF_FILE" | grep "pid file" > /dev/null ; then : else ocf_log err "Error. \"pid file\" entry required in the rsyncd config file by rsyncd OCF RA." return $OCF_ERR_GENERIC fi #Not checking "$OCF_RESKEY_bwlimit" return $OCF_SUCCESS } # # Main # if [ $# -ne 1 ]; then usage exit $OCF_ERR_ARGS fi case $1 in start) get_pid_and_conf_file rsyncd_start ;; stop) get_pid_and_conf_file rsyncd_stop ;; status) get_pid_and_conf_file rsyncd_status ;; monitor)get_pid_and_conf_file rsyncd_monitor ;; validate-all) get_pid_and_conf_file rsyncd_validate_all ;; meta-data) meta_data ;; usage) usage exit $OCF_SUCCESS ;; *) usage exit $OCF_ERR_UNIMPLEMENTED ;; esac