diff --git a/GNUmakefile b/GNUmakefile index 5c80118..b486e56 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,47 +1,47 @@ # # Copyright (C) 2008 Andrew Beekhof # # 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. +# 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # -include Makefile PACKAGE ?= booth TARFILE = $(PACKAGE).tar.bz2 RPM_ROOT = $(shell pwd) RPM_OPTS = --define "_sourcedir $(RPM_ROOT)" \ --define "_specdir $(RPM_ROOT)" \ --define "_srcrpmdir $(RPM_ROOT)" TAG ?= HEAD gitarchive: rm -f $(TARFILE) git archive --format=tar --prefix $(PACKAGE)/ $(TAG) | tar xf - git describe --tags --always > $(PACKAGE)/.git_info tar -cjf $(TARFILE) $(PACKAGE) rm -r $(PACKAGE) echo `date`: Rebuilt $(TARFILE) srpm: gitarchive rm -f *.src.rpm @echo To create custom builds, edit the flags and options in $(PACKAGE).spec first rpmbuild -bs $(RPM_OPTS) $(PACKAGE).spec rpm: srpm rpmbuild $(RPM_OPTS) --rebuild $(RPM_ROOT)/*.src.rpm diff --git a/script/booth-keygen b/script/booth-keygen index 5215826..51a577d 100644 --- a/script/booth-keygen +++ b/script/booth-keygen @@ -1,64 +1,64 @@ #!/bin/sh # # Generate authentication key for booth # # 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. +# 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # DFLT_AUTHFILE=/etc/booth/authkey KEYSIZE=64 # /dev/urandom should be good enough RND_SRC=/dev/urandom usage() { cat<&2 } fatal() { error $* exit 1 } case "$1" in "-h"|"--help"|"-?") usage;; /*|"") : ;; *) fatal "please use absolute path for the key file" ;; esac keyf=${1:-$DFLT_AUTHFILE} if test -f $keyf; then fatal "file $keyf already exists" fi umask 077 errout=`dd if=$RND_SRC of=$keyf bs=$KEYSIZE count=1 2>&1` rc=$? if [ $rc -ne 0 ]; then echo "$errout" >&2 exit $rc fi chown root:root $keyf diff --git a/script/ocf/booth-site b/script/ocf/booth-site index ab1e619..809928c 100755 --- a/script/ocf/booth-site +++ b/script/ocf/booth-site @@ -1,203 +1,203 @@ #!/bin/bash # vim: set sw=4 : # # Resource Agent for BOOTH site daemon. # # 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. +# 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # ####################################################################### # Initialization: DEFAULT_BIN="boothd" DEFAULT_CONF="/etc/booth/booth.conf" : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs ####################################################################### booth_site_meta_data() { cat < 1.0 This Resource Agent can control the BOOTH site daemon. It assumes that the binary boothd is in your default PATH. In most cases, it should be run as a primitive resource. BOOTH site daemon The configuration name (or configuration filename) to use. BOOTH Options Any additional options to start the BOOTH daemon with BOOTH Options The daemon to start The daemon to start END } ####################################################################### booth_site_usage() { cat < /dev/null } booth_site_start() { local rc booth_site_status rc=$? case $rc in 0) ocf_log info "boothd already running" return $OCF_SUCCESS ;; $OCF_NOT_RUNNING) ;; esac $OCF_RESKEY_daemon daemon -c $OCF_RESKEY_config $OCF_RESKEY_args || return $OCF_ERR_GENERIC sleep 1 while ! booth_monitor_basic; do sleep 1 done return $OCF_SUCCESS } booth_site_stop() { local pid pid=`get_booth_pid` if [ -z "$pid" ]; then ocf_log info "boothd already stopped" return $OCF_SUCCESS fi ocf_stop_processes TERM 5 $pid while is_booth_running; do sleep 1 done return $OCF_SUCCESS } booth_site_restart() { booth_site_stop booth_site_start } booth_site_reload() { booth_site_restart } booth_site_monitor() { booth_site_status case $? in 0) return $OCF_SUCCESS ;; $OCF_NOT_RUNNING) return $OCF_NOT_RUNNING ;; esac } booth_site_validate_all() { if ! test -f $OCF_RESKEY_config; then ocf_log err "$OCF_RESKEY_config does not exist" return $OCF_ERR_INSTALLED fi if ocf_is_true $OCF_RESKEY_CRM_meta_globally_unique; then ocf_log err "$OCF_RESOURCE_INSTANCE must be configured with the globally_unique=false meta attribute" return $OCF_ERR_CONFIGURED fi return $OCF_SUCCESS } : ${OCF_RESKEY_daemon:=$DEFAULT_BIN} : ${OCF_RESKEY_config:=$DEFAULT_CONF} OCF_REQUIRED_BINARIES=${OCF_RESKEY_daemon} ocf_rarun $* diff --git a/script/ocf/geo_attr.sh b/script/ocf/geo_attr.sh index d116c9e..d6e8b81 100644 --- a/script/ocf/geo_attr.sh +++ b/script/ocf/geo_attr.sh @@ -1,203 +1,203 @@ # # 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. +# 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # This file is part of the booth project and contains /bin/sh # code to support GEO attributes # USAGE # # To use this for updating GEO attributes just follow the # instructions below. # Source this file in your OCF RA script: # ## . ${OCF_ROOT}/lib/booth/geo_attr.sh # 1) meta-data # # geo_attr_meta_data prints descriptions of three parameters. # Best to invoke it just before printing "". For # instance: # ## cat < ## ... ## ## ... ## `geo_attr_meta_data` ## ## ... ## EOF # 2) validation (validate-all) # # Invoke geo_attr_validate_all to test the environment: # ## if ! geo_attr_validate_all; then ## return $OCF_ERR_INSTALL ## fi # 3) Attribute updating # # Put something like the following code after the RA updated the # remote site state (e.g. data replication): # ## if [ -n "$OCF_RESKEY_booth_ticket" ]; then ## if geo_attr_geo_attr $outcome; then ## # success! ## else ## # failed to set the attribute ## # appropriate error was already logged ## # normally, more cannot be done at this point ## # because updating GEO attributes is ## # essentially a best effort operation ## fi ## fi # # The outcome variable is a boolean. # It should reflect the outcome of the operation to update # data at the site (set to "0" for failure, anything else for # success). # 4) Site name (optional) # # We use the special value 'other' to specify the site where the # attribute is to be updated. That should cover the majority of # GEO clusters. In case your setup has more than two sites, then # provide a function named get_site_name which should print the # appropriate site name (as specified in booth.conf too) to # stdout. # DEFAULT_BOOTH_CONF="/etc/booth/booth.conf" : ${OCF_RESKEY_booth_config:=$DEFAULT_BOOTH_CONF} geo_attr_meta_data() { cat < Booth ticket. Need to define this to activate GEO attribute updating. See also the booth_config and geo_attribute parameters. Booth ticket Booth configuration name (or configuration filename) to use. BOOTH configuration file Attribute name. If not specified, we'll get the name from the first "attr-prereq" definition for the given ticket. This normally needs to be used only in case there are multiple "attr-prereq" directives for the ticket. GEO attribute END } geo_attr_get_attr() { local tkt cnf attr tkt=$OCF_RESKEY_booth_ticket cnf=$OCF_RESKEY_booth_config attr=$OCF_RESKEY_geo_attribute awk -v attr="$attr" ' n && /^[[:space:]]*attr-prereq = auto .* eq / { if (attr == "" || attr == $4) { print $4,$6; exit } } n && (/^$/ || /^ticket.*/) {exit} /^ticket.*'$tkt'/ {n=1} ' $cnf } # arguments: # $1: 0 reset the attribute # != 0 set the attribute # geo_attr_geo_attr() { local val site val=$1 set -- `geo_attr_get_attr` if test z"`command -v get_site_name`" = z"get_site_name"; then site=`get_site_name` else site="other" fi if [ "$val" = "0" ]; then geostore delete -s $site $1 >/dev/null 2>&1 else geostore set -s $site $1 $2 fi } geo_attr_read_attr() { local site set -- `geo_attr_get_attr` if test z"`command -v get_site_name`" = z"get_site_name"; then site=`get_site_name` else site="other" fi geostore get -s $site $1 } # test the environment for geo_attr # geo_attr_validate_all() { if [ -z "$OCF_RESKEY_booth_ticket" ]; then return 0 fi if ! test -f "$OCF_RESKEY_booth_config"; then ocf_log err "booth configuration $OCF_RESKEY_booth_config doesn't exist" return 1 fi if ! grep -qs "^ticket[[:space:]]*=[[:space:]]*\"$OCF_RESKEY_booth_ticket\"" $OCF_RESKEY_booth_config; then ocf_log err "ticket $OCF_RESKEY_booth_ticket not found in $OCF_RESKEY_booth_config" return 1 fi set -- `geo_attr_get_attr` if [ $# -eq 0 ]; then ocf_log err "no attr-prereq defined in $OCF_RESKEY_booth_ticket" return 1 fi return 0 } diff --git a/script/ocf/geostore b/script/ocf/geostore index 4b31127..85842a8 100755 --- a/script/ocf/geostore +++ b/script/ocf/geostore @@ -1,112 +1,112 @@ #!/bin/sh # # # geostore OCF RA. Just an example on how to use # geo-attr.sh # # Copyright (c) 2015 Dejan Muhamedagic # 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. +# 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # ####################################################################### # Initialization: : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs . ${OCF_ROOT}/lib/booth/geo_attr.sh ####################################################################### geostore_meta_data() { cat < 1.0 This is the geostore Resource Agent. It's a sample for how to use geo_attr.sh. Sample GEO attribute RA `geo_attr_meta_data` END } ####################################################################### geostore_usage() { cat < 1.0 This is sharedrsc Resource Agent. It just keeps some resource while running and releases it when stopped. The resource is a directory on a shared filesystem or on a filesystem which is remotely accessible over ssh. Used for booth testing, i.e. to make sure that no two sites keep the same ticket. shared resource (booth testing) Location of the shared directory. If it's of the form "[user@]host:path" then it is assumed that the directory is to be accessed over ssh on that host. Otherwise, it must be a directory on a shared filesystem (such as nfs or ocfs2). shared directory location END } ####################################################################### sharedrsc_usage() { cat < $1/owner" } removecmd() { echo "test -d $1 && test \"\`cat $1/owner\`\" = `uname -n` && rm $1/owner && rmdir $1" } testdir() { runcmd testcmd $1 } makedir() { runcmd makecmd $1 } removedir() { runcmd removecmd $1 } sharedrsc_monitor() { if testdir $DIR; then return $OCF_SUCCESS else return $OCF_NOT_RUNNING fi } sharedrsc_start() { if sharedrsc_monitor; then return $OCF_SUCCESS fi makedir $DIR && return $OCF_SUCCESS local owner if ! owner=`runcmd getowner $DIR`; then owner="... nobody, it's only half-claimed" fi ocf_log err "eek, $OCF_RESKEY_dir already owned by $owner" return $OCF_ERR_GENERIC } sharedrsc_stop() { sharedrsc_monitor if [ $? -eq $OCF_NOT_RUNNING ]; then return $OCF_SUCCESS fi removedir $DIR } sharedrsc_getconfig() { local colon_pos colon_pos=`expr index "$OCF_RESKEY_dir" ":"` if [ $colon_pos -gt 0 ]; then SSH_HOST=`echo $OCF_RESKEY_dir | cut -d: -f 1` DIR=`echo $OCF_RESKEY_dir | cut -d: -f 2` else SSH_HOST= DIR=$OCF_RESKEY_dir fi } sharedrsc_validate_all() { if [ `expr index $DIR /` -ne 1 ]; then ocf_log err "dir must be an absolute path" return $OCF_ERR_INSTALLED fi return $OCF_SUCCESS } OCF_REQUIRED_PARAMS="dir" ocf_rarun $* # # vim:tabstop=4:shiftwidth=4:textwidth=0:wrapmargin=0