#!/bin/sh # # @(#)$Id: importDir.sh,v 1.5 2001/10/18 10:04:08 alex Exp $ # # Script to import a tree of components into the Contelligent System. # Requires environment variable 'CONTELLIGENT_BASEURL' to be set. # # Author: Robin Sander # scriptName=`basename $0` bindir=`dirname "$0"` test -r "$bindir/procs.sh" || { echo "? $scriptname"": internal error - cannot read \`$bindir/procs.sh'." >&2; exit 1; } . "$bindir/procs.sh" # read external funtions makeabs bindir # make 'bindir' contain an absolute path printUsage() { echo "usage: $scriptName " echo " - the directory containing the xml files to import (recursivly)" echo "" echo "Note that the environment variable 'CONTELLIGENT_BASEURL' must contain" echo "the URL of a (running) Contelligent server." } #------------------------------------------------------------------------------ # # defaults # wget_opts="-nv -T 0 --spider" # --spider: don't download anything. importURL="${CONTELLIGENT_BASEURL}/CM/system/import.jsp?FILENAME" if [ "$1" = "" -o "$2" = "" -o "$CONTELLIGENT_BASEURL" = "" ]; then printUsage>&2 exit 1 fi # # now add all .xml files from subdirs: # files="`find $2 -type f -name '*.xml' -print`" # # let's go ... # for file in $files; do makeabs file # make 'file' contain an absolute path echo "importing '$file' using URL '$CONTELLIGENT_BASEURL' ..." wget $wget_opts "${importURL}=$file" rc=$? if [ $rc -ne 0 ]; then echo "error while importing file '$file' !">&2 exit 3 fi done