From 06e17ad6cd305c8fd11305e5a1973bc6ba005b7d Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Fri, 8 Apr 2005 14:41:29 +0000 Subject: [PATCH] first shot at creating a simple tool, functionally similar to update_catalogs, but instead for managing centralized locating-rules files --- .../update_locatingrules/update_locatingrules | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100755 contrib/tools/update_locatingrules/update_locatingrules diff --git a/contrib/tools/update_locatingrules/update_locatingrules b/contrib/tools/update_locatingrules/update_locatingrules new file mode 100755 index 000000000..5bb63c754 --- /dev/null +++ b/contrib/tools/update_locatingrules/update_locatingrules @@ -0,0 +1,114 @@ +#!/bin/bash +# $Id $ + +# update_locatingrules - Update a central "locating rules" file + +XSLT=xsltproc +XSLTOPTS= +XMLPARSER=xmllint +XMLPARSER_OPTS=--format +DEFAULT_RULESFILE=/etc/xml/locatingrules.xml + +update_locatingrules() { + RULESFILE=$1 + ACTION=$2 + URI=$3 + # if no existing rulesfile in specified locaation, first create it + if [ ! -f "$RULESFILE" ]; then + echo "Creating $RULESFILE" + printf "`cat <<-EOF + + + +EOF +`" > $RULESFILE + fi + if [ "$ACTION" = "add" ]; then + echo "Adding URI $URI to file $RULESFILE" + else + echo "Deleting URI $URI from file $RULESFILE" + fi + printf "`cat <<-EOF + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +EOF +`" |\ + $XSLT --stringparam $ACTION $URI - $RULESFILE | $XMLPARSER $XMLPARSER_OPTS - + exit 0 +} + +# if 3 args and 2nd arg is "add" or "delete", pass all three to +# update_locatingrules() +if [ -n "$1" ] && [ "$2" = "add" -o "$2" = "delete" ] && [ -n "$3" ]; then + update_locatingrules $1 $2 $3 +else + # if only two args and 2nd arg is "add" or "delete", call + # update_locatingrules() with first arg being value of + # DEFAULT_RULESFILE + if [ "$1" = "add" -o "$1" = "delete" ] && [ -n "$2" ]; then + update_locatingrules $DEFAULT_RULESFILE $1 $2 + else + echo "usage: `basename $0` [] add|delete " + exit 1 + fi +fi + +# Copyright +# --------- +# Copyright 2005 Michael Smith +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation +# files (the "Software"), to deal in the Software without +# restriction, including without limitation the rights to use, copy, +# modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. -- 2.40.0