From: Alexander Barton Date: Mon, 21 Sep 2009 10:35:55 +0000 (+0200) Subject: Initial commit X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ocf-ra.git;a=commitdiff_plain;h=6b784cd756da2e1ac6fb923aace3e9759298b2b9 Initial commit --- 6b784cd756da2e1ac6fb923aace3e9759298b2b9 diff --git a/Apache2 b/Apache2 new file mode 100755 index 0000000..2fb923f --- /dev/null +++ b/Apache2 @@ -0,0 +1,130 @@ +#!/bin/sh +# +# OCF RA for Apache2 +# +# Copyright (c) 2009 Barton IT-Consulting +# 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: +. ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +meta_data() { + cat < + + +1.1 + + +This Resource Agent starts and stops the Apache2 web server. + +Apache2 resource agent + + + + + + + + + +END +} + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +if [ -r `dirname "$OCF_RESKEY_configfile"`/envvars ]; then + # source Apache2 environment variables + . `dirname "$OCF_RESKEY_configfile"`/envvars +fi + +Apache2_usage() { + echo "usage: $0 {start|stop|monitor|validate-all|meta-data}" +} + +Apache2_start() { + apache2ctl configtest + if [ $? = $OCF_SUCCESS ]; then + /usr/sbin/apache2ctl start + if [ $? = $OCF_SUCCESS ]; then + return $OCF_SUCCESS + fi + fi + return $OCF_ERR_GENERIC +} + +Apache2_stop() { + /usr/sbin/apache2ctl stop + if [ $? = $OCF_SUCCESS ]; then + return $OCF_SUCCESS + fi + return $OCF_ERR_GENERIC +} + +Apache2_monitor() { + /usr/sbin/apache2ctl status | grep "Server Version" + if [ $? = $OCF_SUCCESS ]; then + return $OCF_SUCCESS + fi + return $OCF_NOT_RUNNING +} + +Apache2_validate() { + return $OCF_SUCCESS +} + +case $__OCF_ACTION in + meta-data) + meta_data + exit $OCF_SUCCESS + ;; + start) + Apache2_start + ;; + stop) + Apache2_stop + ;; + monitor) + Apache2_monitor + ;; + validate-all) + Apache2_validate + ;; + usage|help) + Apache2_usage + exit $OCF_SUCCESS + ;; + *) + Apache2_usage + exit $OCF_ERR_UNIMPLEMENTED + ;; +esac + +rc=$? +ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc" +exit $rc + +# -eof- diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..375be33 --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +RA = Apache2 OCFS2_DRBD TunCtl UML +RA_D = /usr/lib/ocf/resource.d/barton-it + +all: + chmod 755 $(RA) + +install: all + mkdir -p $(RA_D) + cp -p $(RA) $(RA_D)/ diff --git a/OCFS2_DRBD b/OCFS2_DRBD new file mode 100755 index 0000000..60297f2 --- /dev/null +++ b/OCFS2_DRBD @@ -0,0 +1,178 @@ +#!/bin/sh +# +# OCF RA for OCFS2 on DRBD +# +# Copyright (c) 2008,2009 Barton IT-Consulting +# 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: +. ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +meta_data() { + cat < + + +1.3 + + +This Resource Agent starts and stops OCFS2 file systems located on DRBD devices. + +OCFS2 on DRBD resource agent + + + +ID of the DRBD resource +ID of the DRBD resource + + + +DRBD device +DRBD device + + + +Mountpoint for OCFS2 filesystem +Mountpoint for OCFS2 filesystem + + + + + + + + + + + + +END +} + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +ClusterFS_usage() { + echo "usage: $0 {start|stop|monitor|validate-all|meta-data}" +} + +ClusterFS_start() { + mkdir -p "$OCF_RESKEY_mountpoint" + drbdadm primary "$OCF_RESKEY_drbd" + if [ $? -ne 0 ]; then + return $OCF_ERR_GENERIC + fi + mount -t ocfs2 "$OCF_RESKEY_drbd_dev" "$OCF_RESKEY_mountpoint" + if [ $? -ne 0 ]; then + return $OCF_ERR_GENERIC + fi + return $OCF_SUCCESS +} + +ClusterFS_stop() { + mount | grep "$OCF_RESKEY_drbd_dev on " >/dev/null + if [ $? -eq 0 ]; then + umount "$OCF_RESKEY_mountpoint" + if [ $? -ne 0 ]; then + # try harder, kill processes on this filesystem + pids=$(ps ax|awk "{print \$1}"|grep -v PID) + for p in $pids; do + lsof -p $p -n | grep " $OCF_RESKEY_mountpoint" \ + >/dev/null 2>&1 + [ $? -eq 0 ] || continue + kill $p + done + sleep 3 + pids=$(ps ax|awk "{print \$1}"|grep -v PID) + for p in $pids; do + lsof -p $p -n | grep " $OCF_RESKEY_mountpoint" \ + >/dev/null 2>&1 + [ $? -eq 0 ] || continue + kill -9 $p + done + sleep 1 + umount "$OCF_RESKEY_mountpoint" + if [ $? -ne 0 ]; then + return $OCF_ERR_GENERIC + fi + fi + fi + drbdadm secondary "$OCF_RESKEY_drbd" + return $OCF_SUCCESS +} + +ClusterFS_monitor() { + mount | grep "$OCF_RESKEY_drbd_dev on " >/dev/null + if [ $? -eq 0 ]; then + return $OCF_SUCCESS + fi + return $OCF_NOT_RUNNING +} + +ClusterFS_validate() { + if [ -z "$OCF_RESKEY_drbd" ]; then + return $OCF_ERR_ARGS + fi + if [ -z "$OCF_RESKEY_drbd_dev" ]; then + return $OCF_ERR_ARGS + fi + if [ -z "$OCF_RESKEY_mountpoint" ]; then + return $OCF_ERR_ARGS + fi + return $OCF_SUCCESS +} + +case $__OCF_ACTION in + meta-data) + meta_data + exit $OCF_SUCCESS + ;; + start) + ClusterFS_start + ;; + stop) + ClusterFS_stop + ;; + monitor) + ClusterFS_monitor + ;; + validate-all) + ClusterFS_validate + ;; + usage|help) + ClusterFS_usage + exit $OCF_SUCCESS + ;; + *) + ClusterFS_usage + exit $OCF_ERR_UNIMPLEMENTED + ;; +esac + +rc=$? +ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc" +exit $rc + +# -eof- diff --git a/TunCtl b/TunCtl new file mode 100755 index 0000000..9204e5c --- /dev/null +++ b/TunCtl @@ -0,0 +1,184 @@ +#!/bin/sh +# +# OCF RA for tunctl(1) TUN/TAP device initialization +# +# Copyright (c) 2008,2009 Barton IT-Consulting +# 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: +. ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +meta_data() { + cat < + + +1.1 + + +OCF RA for tunctl(1) TUN/TAP device initialization. + +TUN/TAP device initialization + + + +Name of TUN/TAP interface + + + +TUN/TAP interface owner + + + +Host-side IP address + + + +Host-side netmask + + + +Client-side IP address + + + +Interface for Proxy-ARP + + + + + + + + + + + + +END +} + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +TunCtl_usage() { + echo "usage: $0 {start|stop|monitor|validate-all|meta-data}" +} + +TunCtl_start() { + tunctl -u "${OCF_RESKEY_if_owner:-root}" -t "$OCF_RESKEY_if_name" + if [ $? -ne 0 ]; then + return $OCF_ERR_GENERIC + fi + ifconfig "$OCF_RESKEY_if_name" "$OCF_RESKEY_host_ip" \ + netmask "${OCF_RESKEY_host_netmask:-255.255.255.0}" up + if [ $? -ne 0 ]; then + return $OCF_ERR_GENERIC + fi + echo 1 >/proc/sys/net/ipv4/ip_forward + route add -host "$OCF_RESKEY_client_ip" dev "$OCF_RESKEY_if_name" + if [ $? -ne 0 ]; then + return $OCF_ERR_GENERIC + fi + if [ -n "$OCF_RESKEY_if_proxyarp" ]; then + # Proxy ARP + echo 1 >/proc/sys/net/ipv4/conf/"$OCF_RESKEY_if_name"/proxy_arp + if [ $? -ne 0 ]; then + return $OCF_ERR_GENERIC + fi + arp -Ds "$OCF_RESKEY_client_ip" "$OCF_RESKEY_if_proxyarp" pub + if [ $? -ne 0 ]; then + return $OCF_ERR_GENERIC + fi + fi + return $OCF_SUCCESS +} + +TunCtl_stop() { + if [ -n "$OCF_RESKEY_if_proxyarp" ]; then + # Proxy ARP + arp -d "$OCF_RESKEY_client_ip" -i "$OCF_RESKEY_if_proxyarp" pub + fi + ifconfig "$OCF_RESKEY_if_name" down >/dev/null 2>&1 + tunctl -d "$OCF_RESKEY_if_name" + if [ $? -eq 0 ]; then + return $OCF_SUCCESS + fi + return $OCF_ERR_GENERIC +} + +TunCtl_monitor() { + ip link show "$OCF_RESKEY_if_name" | grep "UP" >/dev/null 2>&1 + if [ $? -eq 0 ]; then + return $OCF_SUCCESS + fi + return $OCF_NOT_RUNNING +} + +TunCtl_validate() { + if [ -z "$OCF_RESKEY_if_name" ]; then + return $OCF_ERR_ARGS + fi + if [ -z "$OCF_RESKEY_host_ip" ]; then + return $OCF_ERR_ARGS + fi + if [ -z "$OCF_RESKEY_client_ip" ]; then + return $OCF_ERR_ARGS + fi + return $OCF_SUCCESS +} + +case $__OCF_ACTION in + meta-data) + meta_data + exit $OCF_SUCCESS + ;; + start) + TunCtl_start + ;; + stop) + TunCtl_stop + ;; + monitor) + TunCtl_monitor + ;; + validate-all) + TunCtl_validate + ;; + usage|help) + TunCtl_usage + exit $OCF_SUCCESS + ;; + *) + TunCtl_usage + exit $OCF_ERR_UNIMPLEMENTED + ;; +esac + +rc=$? +ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc" +exit $rc + +# -eof- diff --git a/UML b/UML new file mode 100755 index 0000000..54b98e6 --- /dev/null +++ b/UML @@ -0,0 +1,135 @@ +#!/bin/sh +# +# OCF RA for User Mode Linux (UML) guests +# +# Copyright (c) 2007-2009 Barton IT-Consulting +# 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: +. ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs + +export PATH="$PATH:/opt/uml/bin" + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +meta_data() { + cat < + + +1.1 + + +This Resource Agent starts and stops User Mode Linux (UML) guests. + +User Mode Linux (UML) resource agent + + + +ID of the UML guest +ID of the UML guest + + + + + + + + + + + + +END +} + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +UML_usage() { + echo "usage: $0 {start|stop|monitor|validate-all|meta-data}" +} + +UML_start() { + uml-start "$OCF_RESKEY_umlid" + if [ $? = $OCF_SUCCESS ]; then + return $OCF_SUCCESS + fi + return $OCF_ERR_GENERIC +} + +UML_stop() { + uml-stop "$OCF_RESKEY_umlid" + if [ $? = $OCF_SUCCESS ]; then + return $OCF_SUCCESS + fi + return $OCF_ERR_GENERIC +} + +UML_monitor() { + uml-list "$OCF_RESKEY_umlid" + if [ $? = $OCF_SUCCESS ]; then + return $OCF_SUCCESS + fi + return $OCF_NOT_RUNNING +} + +UML_validate() { + if [ -z "$OCF_RESKEY_umid" ]; then + return $OCF_ERR_ARGS + fi + return $OCF_SUCCESS +} + +case $__OCF_ACTION in + meta-data) + meta_data + exit $OCF_SUCCESS + ;; + start) + UML_start + ;; + stop) + UML_stop + ;; + monitor) + UML_monitor + ;; + validate-all) + UML_validate + ;; + usage|help) + UML_usage + exit $OCF_SUCCESS + ;; + *) + UML_usage + exit $OCF_ERR_UNIMPLEMENTED + ;; +esac + +rc=$? +ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc" +exit $rc + +# -eof-