[Fedora-directory-commits] dsmlgw/scripts dsmlgw-search.in, NONE, 1.1 dsmlgw.env.in, NONE, 1.1 restart-ds-dsmlgw.in, NONE, 1.1 setup-ds-dsmlgw.in, NONE, 1.1 start-ds-dsmlgw.in, NONE, 1.1 stop-ds-dsmlgw.in, NONE, 1.1

Richard Allen Megginson (rmeggins) fedora-directory-commits at redhat.com
Thu Apr 24 21:39:12 UTC 2008


Author: rmeggins

Update of /cvs/dirsec/dsmlgw/scripts
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv18285/dsmlgw/scripts

Added Files:
	dsmlgw-search.in dsmlgw.env.in restart-ds-dsmlgw.in 
	setup-ds-dsmlgw.in start-ds-dsmlgw.in stop-ds-dsmlgw.in 
Log Message:
move scripts to new scripts directory - add very simple dsmlgw-search script to test dsmlgw - remove some error messages


--- NEW FILE dsmlgw-search.in ---
#!/bin/sh
#
# BEGIN COPYRIGHT BLOCK
# 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; version 2 of the License.
# 
# 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.
# 
# Copyright (C) 2006 Red Hat, Inc.
# All rights reserved.
# END COPYRIGHT BLOCK
#

usage()
{
    echo $1
    echo Usage: $0 [-h host] [-p port] [-s scope] [-b base] [filter] [attributes . . .]
    exit 1
}

hostname=localhost
port=8081
scope=sub
base=no_suffix_supplied
filter='(objectclass=*)'

while [ "$1" ] ; do
        case "$1" in
        -h) shift; hostname="$1" ;;
        -p) shift; port="$1" ;;
        -s) shift; scope="$1" ;;
        -b) shift; base="$1" ;;
        *) filter="$1"; shift; break;;
        esac
        shift
done

#echo $0 -h $hostname -p $port -s $scope -b $base \"$filter\" "$@"

dsmlscope=wholeSubtree
case "$scope" in
    base) dsmlscope=baseObject ;;
    one) dsmlscope=singleLevel ;;
    sub) dsmlscope=wholeSubtree ;;
esac

tmpdsml=/tmp/dsml.$$

cat > $tmpdsml <<EOF
<?xml version='1.0' encoding='UTF-8'?> 
<soap-env:Envelope
  xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap-env:Body>

<batchRequest xmlns="urn:oasis:names:tc:DSML:2:0:core">
<searchRequest dn="$base" scope="$scope" derefAliases="neverDerefAliases"> 

<filter><present name="objectclass"/></filter>
EOF

if [ "$1" ] ; then
    echo "<attributes>" >> $tmpdsml
    while [ "$1" ] ; do
        echo "<attribute name="\"$1\""/>" >> $tmpdsml
        shift
    done
    echo "</attributes>" >> $tmpdsml
fi

cat >> $tmpdsml <<EOF
</searchRequest>
</batchRequest>
</soap-env:Body>
</soap-env:Envelope>
EOF

dsmlgwlibdir=@dsmlgwdatadir@/webapps/axis/WEB-INF/lib
for file in $dsmlgwlibdir/*.jar ; do
    if [ "$AXISCP" ] ; then
        AXISCP=${AXISCP}:$file
    else
        AXISCP=$file
    fi
done

@runtime_javahome@/bin/java -cp "$AXISCP" com.netscape.dsml.test.dsmlSearch http://$hostname:$port/axis/services/dsmlgw $tmpdsml

rm -f $tmpdsml


--- NEW FILE dsmlgw.env.in ---
# This file sets up the environment which the dsmlgw will use

if [ -z "$DSMLGW_CONFIG_DIR" ] ; then
    DSMLGW_CONFIG_DIR=@dsmlgwconfigdir@
    export DSMLGW_CONFIG_DIR
fi

if [ -z "$CATALINA_HOME" ] ; then
    CATALINA_HOME=@dsmlgwdatadir@
    export CATALINA_HOME
fi

if [ -z "$CATALINA_PID" ] ; then
    CATALINA_PID=@dsmlgwrundir@/@package_name at .pid
    export CATALINA_PID
fi

if [ -z "$TOMCAT_USER" ] ; then
    TOMCAT_USER=@dsmlgwuser@
    export TOMCAT_USER
fi

if [ -z "$CATALINA_TEMP" ] ; then
    CATALINA_TEMP=@dsmlgwrundir@/temp
    export CATALINA_TEMP
fi

if [ -z "$JAVA_HOME" ] ; then
    JAVA_HOME=@runtime_javahome@
    export JAVA_HOME
    PATH=$JAVA_HOME/bin:$PATH
    export PATH
fi


--- NEW FILE restart-ds-dsmlgw.in ---
#!/bin/sh
#
# BEGIN COPYRIGHT BLOCK
# 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; version 2 of the License.
# 
# 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.
# 
# Copyright (C) 2006 Red Hat, Inc.
# All rights reserved.
# END COPYRIGHT BLOCK
#

@dsmlgwsbindir@/stop-ds-dsmlgw
@dsmlgwsbindir@/start-ds-dsmlgw


--- NEW FILE setup-ds-dsmlgw.in ---
#!/bin/sh
#
# BEGIN COPYRIGHT BLOCK
# 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; version 2 of the License.
# 
# 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.
# 
# Copyright (C) 2006 Red Hat, Inc.
# All rights reserved.
# END COPYRIGHT BLOCK
#

###########################
#
# The general strategy is to create an "instance" of tomcat, so that we
# can use our own logs directory, pid directory, etc. and can run as a
# user of our choosing rather than the default tomcat user
#
##########################

echo '######################################################################'
echo This shell script will configure the DSML Gateway Axis service, as
echo a web application running under Tomcat.
echo

getValFromInf() {
	cattr=$1
	cfile=$2
	rval=`grep ^$cattr $cfile | head -1 | sed -e "s/^$cattr[ 	]*=[ 	]*//"`
	echo $rval
}

getValFromConf() {
	cattr=$1
	cfile=$2
	rval=`grep ^$cattr $cfile | head -1 | sed -e "s/^$cattr[ 	]*//"`
	echo $rval
}

getValFromLdif() {
	cattr=$1
	cfile=$2
	num=${3:-1}
	rval=`grep -i ^$cattr: $cfile | head -$num | sed -e "s/^..*:[ 	]*//"`
	echo $rval
}

# e.g. /etc/dirsrv/dsmlgw
dsmlgwconfigdir="@dsmlgwconfigdir@"
dsmlgwlogdir="@dsmlgwlogdir@"
dsmlgwrundir="@dsmlgwrundir@"
basecfgdir=`dirname $dsmlgwconfigdir`
securitydir="@dsmlgwconfigdir@"

# see if there is a $dsmlgwconfigdir/../admin-serv
admservdir=$basecfgdir/admin-serv
if [ -f "$admservdir/local.conf" ] ; then
    echo Reading parameters from Administration Server config . . .
    host=`getValFromLdif serverHostName "$admservdir/local.conf"`
    sec=`getValFromLdif configuration.nsServerSecurity "$admservdir/local.conf"`
    if [ "$sec" = "on" -a ! -f $securitydir/cert8.db ] ; then
        cp $admservdir/cert8.db $securitydir
    fi
    dsmlgwuser=`ls -l $admservdir/local.conf | awk '{print $3}'`
    dsmlgwgroup=`ls -l $admservdir/local.conf | awk '{print $4}'`
else
    echo
    echo '########################################################################'
    echo Error: It appears the Administration Server has not yet been configured.
    echo There are configuration files missing from $admservdir
    echo Please run setup-ds-admin.pl to create your Administration Server
    echo then run this script again.
    exit 1
fi

# see if there are any directory servers here
for dir in $basecfgdir/slapd-* ; do
    case "$dir" in
    *.deleted) continue ;;
    esac
    if [ -d "$dir" -a -f "$dir/dse.ldif" ] ; then
        echo Reading parameters from Directory Server $dir . . .
        dirmgr=`getValFromLdif nsslapd-rootdn "$dir/dse.ldif"`
        host=`getValFromLdif nsslapd-localhost "$dir/dse.ldif"`
        sec=`getValFromLdif nsslapd-security "$dir/dse.ldif"`
        if [ "$sec" = "on" ] ; then
            port=`getValFromLdif nsslapd-secureport "$dir/dse.ldif"`
            ldapurl="ldaps://$host:$port"
            if [ ! -f $securitydir/cert8.db ] ; then
                cp $dir/cert8.db $securitydir
            fi
        else
            port=`getValFromLdif nsslapd-port "$dir/dse.ldif"`
            ldapurl="ldap://$host:$port"
        fi
        if [ -z "$dsmlgwuser" ] ; then
            dsmlgwuser=`ls -l $dir/dse.ldif | awk '{print $3}'`
        fi
        if [ -z "$dsmlgwgroup" ] ; then
            dsmlgwgroup=`ls -l $dir/dse.ldif | awk '{print $4}'`
        fi
    fi
done

if [ -n "$ldapurl" ] ; then
    echo Using Directory Server URL $ldapurl
fi

# get command line arguments

inffile=
nextisinffile=
reconfig=
for arg in "$@" ; do
	if [ "$arg" = "-r" ]; then
		reconfig=1
	elif [ "$arg" = "-f" ]; then
		nextisinffile=1
	elif [ $nextisinffile ]; then
		inffile="$arg"
		nextisinffile=
	fi
done

tomcat_home=@tomcat_home@

if [ -z "$tomcat_home" -o ! -d "$tomcat_home" ] ; then
    echo ERROR: tomcat_home is not set to the tomcat directory
    exit 1
fi

# CATALINA_HOME points to @datadir@/dsmlgw
# these are the directories we need in order to run an instance of tomcat
# bin server common shared conf temp webapps logs work
# these directories will just be symlinks to the actual tomcat dir - they
# are mostly read-only: bin server common shared conf
# webapps will be a real directory and will contain axis + dsmlgw
# logs will point to the dirsrv/dsmlgw logs directory
# temp and work will point to the run/dsmlgw directory
dsmlgwdir=@dsmlgwdatadir@

for dir in bin server common shared conf ; do
    if [ -d $dsmlgwdir/$dir ] ; then
        echo $dsmlgwdir/$dir exists, skipping . . .
    else
        ln -s $tomcat_home/$dir $dsmlgwdir/$dir
    fi
done

if [ -d $dsmlgwdir/logs ] ; then
    echo $dsmlgwdir/logs exists, skipping . . .
else
    ln -s @dsmlgwlogdir@ $dsmlgwdir/logs
fi

for dir in temp work ; do
    if [ -d $dsmlgwdir/$dir ] ; then
        echo $dsmlgwdir/$dir exists, skipping . . .
    else
        ln -s @dsmlgwrundir@ $dsmlgwdir/$dir
    fi
done

# tomcat needs the webapps/ROOT directory too
if [ -d $dsmlgwdir/webapps/ROOT ] ; then
    echo $dsmlgwdir/webapps/ROOT exists, skipping . . .
else
    ln -s $tomcat_home/webapps/ROOT $dsmlgwdir/webapps/ROOT
fi

if [ -f "$inffile" ] ; then
    hostname=`getValFromInf FullMachineName $inffile`
    port=`getValFromInf ServerPort $inffile`
    dirmgr=`getValFromInf RootDN $inffile`
    ldapurl="ldap://$host:$port"
    infuser=`getValFromInf SysUser $inffile`
    infgroup=`getValFromInf SysGroup $inffile`
    if [ -z "$infuser" ] ; then
        infuser=`getValFromInf SuiteSpotUserID $inffile`
    fi
    if [ -z "$infgroup" ] ; then
        infgroup=`getValFromInf SuiteSpotGroup $inffile`
    fi
    if [ -n "$infuser" ] ; then
        dsmlgwuser="$infuser"
    fi
    if [ -n "$infgroup" ] ; then
        dsmlgwgroup="$infgroup"
    fi
    echo Using parameters from file $inffile . . .
    echo Using Directory Server URL $ldapurl . . .
fi

if [ -z "$reconfig" -a -f $dsmlgwconfigdir/dsmlgw.cfg ] ; then
    echo
    echo '######################################################################'
    echo The DSML Gateway has already been configured.  The
    echo file $dsmlgwconfigdir/dsmlgw.cfg
    echo exists already.  If you want to force a reconfiguration, removing
    echo your existing configuration and recreating it, run this script
    echo again with the \"-r\" argument.
    exit 1
fi

echo Generating config file $dsmlgwconfigdir/dsmlgw.cfg . . .
# generate dsmlgw.cfg in the $dsmlgwconfigdir directory
rm -f $dsmlgwconfigdir/dsmlgw.cfg
echo ServerHost=$host > $dsmlgwconfigdir/dsmlgw.cfg
echo ServerPort=$port >> $dsmlgwconfigdir/dsmlgw.cfg
echo BindDN=$rootdn >> $dsmlgwconfigdir/dsmlgw.cfg
echo BindPW= >> $dsmlgwconfigdir/dsmlgw.cfg

echo Updating the user information in $dsmlgwconfigdir/dsmlgw.env . . .
cp $dsmlgwconfigdir/dsmlgw.env $dsmlgwconfigdir/dsmlgw.env.orig
sed -e "s/TOMCAT_USER=.*/TOMCAT_USER=$dsmlgwuser/" $dsmlgwconfigdir/dsmlgw.env.orig > $dsmlgwconfigdir/dsmlgw.env

chown -R $dsmlgwuser:$dsmlgwgroup $dsmlgwconfigdir
chown -R $dsmlgwuser:$dsmlgwgroup $dsmlgwlogdir
chown -R $dsmlgwuser:$dsmlgwgroup $dsmlgwrundir

chmod 0400 $dsmlgwconfigdir/dsmlgw.cfg

echo
echo The DSML Gateway has been successfully configured.
echo '######################################################################'

exit 0


--- NEW FILE start-ds-dsmlgw.in ---
#!/bin/sh
#
# BEGIN COPYRIGHT BLOCK
# 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; version 2 of the License.
# 
# 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.
# 
# Copyright (C) 2006 Red Hat, Inc.
# All rights reserved.
# END COPYRIGHT BLOCK
#

# first, look for the shell script config file
# if not found, punt

# source env. for dsmlgw
[ -f @dsmlgwconfigdir@/dsmlgw.env ] && . @dsmlgwconfigdir@/dsmlgw.env

# if root, use su to execute the startup script - user is set in @initconfigdir@/@package_name@
myuid=`id | cut -f1 -d' '`
if [ "$myuid" = 'uid=0(root)' ] ; then
    su $TOMCAT_USER -c "@tomcat_cmd@ $@"
else
    @tomcat_cmd@ $@
fi


--- NEW FILE stop-ds-dsmlgw.in ---
#!/bin/sh
#
# BEGIN COPYRIGHT BLOCK
# 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; version 2 of the License.
# 
# 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.
# 
# Copyright (C) 2006 Red Hat, Inc.
# All rights reserved.
# END COPYRIGHT BLOCK
#

# source env. for dsmlgw
[ -f @dsmlgwconfigdir@/dsmlgw.env ] && . @dsmlgwconfigdir@/dsmlgw.env

kill `cat $CATALINA_PID`




More information about the Fedora-directory-commits mailing list