Author: rmeggins
Update of /cvs/dirsec/dsmlgw/misc
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv3561/dsmlgw/misc
Added Files:
dsmlgw.env.in setup-ds-dsmlgw.in start-ds-dsmlgw.in
Log Message:
initial commit for packaging - allow fhs, fhsopt, and straight prefix packaging - added
setup and start scripts
--- 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@.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 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@"
basecfgdir=`dirname $dsmlgwconfigdir`
# default security dir
securitydir="@securitydir@"
defaultsecdir=1
# 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"`
port=`getValFromLdif configuration.nsServerPort "$admservdir/local.conf"`
sec=`getValFromLdif configuration.nsServerSecurity
"$admservdir/local.conf"`
if [ "$sec" = "on" ] ; then
httpurl="https://$host:$port"
if [ -n "$defaultsecdir" ] ; then
securitydir="$admservdir"
defaultsecdir=
fi
else
httpurl="http://$host:$port"
fi
dsmlgwuser=`ls -l $admservdir/local.conf | awk '{print $3}'`
dsmlgwgroup=`ls -l $admservdir/local.conf | awk '{print $4}'`
echo Using Administration Server URL $httpurl . . .
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 [ -n "$defaultsecdir" ] ; then
securitydir="$dir"
defaultsecdir=
fi
else
port=`getValFromLdif nsslapd-port "$dir/dse.ldif"`
ldapurl="ldap://$host:$port"
fi
# get suffix - first non-netscaperoot suffix
savesuffix="$suffix"
suffix=`grep ^nsslapd-suffix: $dir/dse.ldif | sed -e 's/^nsslapd-suffix:[
]*//' | grep -v -i o=netscaperoot | head -1`
if [ -z "$suffix" ] ; then
suffix="$savesuffix"
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/$suffix . . .
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
if [ -f "$inffile" ] ; then
hostname=`getValFromInf FullMachineName $inffile`
port=`getValFromInf ServerPort $inffile`
suffix=`getValFromInf Suffix $inffile`
dirmgr=`getValFromInf RootDN $inffile`
httpport=`getValFromInf Port $inffile`
httpurl="http://$host:$httpport"
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 Administration Server URL $httpurl . . .
echo Using Directory Server URL $ldapurl/$suffix . . .
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.conf
sed -e "s#@host@#$hostname#g" \
-e "s#@port@#$port#g" \
-e "s#@httpport@#$httpport#g" \
-e "s#@suffix@#$suffix#g" \
-e "s#@dirmgr@#$dirmgr#g" \
-e "s#^securitypath.*\$#securitypath $securitydir#g" \
-e "s#@ldapurl@#$ldapurl#g" \
-e "s#@httpurl@#$httpurl#g" \
@configdir(a)/dsmlgw.tmpl > $dsmlgwconfigdir/dsmlgw.conf
chown $dsmlgwuser:$dsmlgwgroup $dsmlgwconfigdir/dsmlgw.conf
chmod 0400 $dsmlgwconfigdir/dsmlgw.conf
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(a)/dsmlgw.env ] && . @dsmlgwconfigdir(a)/dsmlgw.env
# if root, use su to execute the startup script - user is set in
@initconfigdir@/@package_name@
if [ "$USER" = "root" ] ; then
su - $CATALINA_USER -c "@tomcat_cmd@ $@"
else
@tomcat_cmd@ $@
fi
Show replies by thread