#! /bin/sh # Inserted by configure. ################# BEGIN Inserted by configure ############# GLOBUS_DEPLOY_PATH=/opt/globus GLOBUS_DEPLOYED='TRUE' if [ -n "${GSI_INSTALL_PATH}" -a -z "${GLOBUS_INSTALL_PATH}" ]; then GLOBUS_INSTALL_PATH=${GSI_INSTALL_PATH} fi if [ -n "${GSI_DEPLOY_PATH}" -a -z "${GLOBUS_DEPLOY_PATH}" ]; then GLOBUS_DEPLOY_PATH=/opt/globus fi if [ "X${GLOBUS_DEPLOYED}" = "XTRUE" ]; then if [ -z "${GLOBUS_DEPLOY_PATH}" ]; then echo "ERROR: environment variable GLOBUS_DEPLOY_PATH not defined" 1>&2 exit 1 fi if [ -z "${GLOBUS_INSTALL_PATH}" ]; then if [ ! -r "${GLOBUS_DEPLOY_PATH}/etc/globus-install-path.sh" ]; then echo "ERROR: cannot read ${GLOBUS_DEPLOY_PATH}/etc/globus-install-path.sh" 1>&2 exit 1 fi . "${GLOBUS_DEPLOY_PATH}/etc/globus-install-path.sh" if [ -z "${GLOBUS_INSTALL_PATH}" ]; then echo "ERROR: environment variable GLOBUS_INSTALL_PATH not defined" 1>&2 echo "in ${GLOBUS_DEPLOY_PATH}/etc/globus-install-path.sh" 1>&2 exit 1 fi fi else if [ -z "${GLOBUS_INSTALL_PATH}" ]; then echo "ERROR: environment variable GLOBUS_INSTALL_PATH not defined" 1>&2 # for easier development testing, fall back on ${prefix} and don't exit # GLOBUS_INSTALL_PATH=/usr/local/globus exit 1 fi fi if [ "X${GLOBUS_DEPLOYED}" = "XTRUE" ]; then export GLOBUS_DEPLOY_PATH prefix=${GLOBUS_DEPLOY_PATH} exec_prefix=${GLOBUS_DEPLOY_PATH} arch="`${prefix}/sbin/config.guess`" arch_sysconfdir="${prefix}/etc/${arch}" else prefix="${GLOBUS_INSTALL_PATH}" exec_prefix=${GLOBUS_INSTALL_PATH}/services/i686-pc-linux-gnu if [ "X${GLOBUS_ARCHITECTURE_INDEPENDENT}" = "XTRUE" ]; then if [ '${GLOBUS_INSTALL_PATH}/services/i686-pc-linux-gnu' != '${prefix}' ] ; then arch="`${GLOBUS_INSTALL_PATH}/sbin/config.guess`" exec_prefix="${prefix}/services/${arch}" arch_sysconfdir="${prefix}/etc/${arch}" fi fi fi export GLOBUS_INSTALL_PATH sbindir=${exec_prefix}/sbin bindir=${exec_prefix}/bin libdir=${exec_prefix}/lib libexecdir=${exec_prefix}/libexec includedir=${exec_prefix}/include datadir=${prefix}/share sysconfdir=${prefix}/etc sharedstatedir=${prefix}/com localstatedir=${prefix}/var tmpdir=${prefix}/tmp local_tmpdir=/tmp secure_tmpdir=${local_tmpdir} [ -z "${arch_sysconfdir}" ] && arch_sysconfdir=/usr/local/globus/etc/i686-pc-linux-gnu if [ -z "${GLOBUS_SSL_PATH}" ]; then if [ -r "${arch_sysconfdir}/globus-ssl-path-32.sh" ] ; then globus_ssl_path_sh="${arch_sysconfdir}/globus-ssl-path-32.sh" elif [ -r "${arch_sysconfdir}/globus-ssl-path-64.sh" ] ; then globus_ssl_path_sh="${arch_sysconfdir}/globus-ssl-path-64.sh" else echo "ERROR: cannot resolve path to SSL installation -- excepted" 1>&2 echo "to find this information in ${arch_sysconfdir}" 1>&2 echo "Set environment variable GLOBUS_SSL_PATH and try again" 1>&2 exit 1 fi . "${globus_ssl_path_sh}" if [ -z "${GLOBUS_SSL_PATH}" ]; then echo "ERROR: value for GLOBUS_SSL_PATH not defined" 1>&2 echo "in ${globus_ssl_path_sh}" 1>&2 exit 1 fi fi if [ -z "$GLOBUS_SH_VARIABLES_SET" ]; then if [ ! -r ${arch_sysconfdir}/globus-sh-commands.sh ] ; then echo "ERROR: cannot read ${arch_sysconfdir}/globus-sh-commands.sh" 1>&2 exit 1 fi . ${arch_sysconfdir}/globus-sh-commands.sh for _var in `${GLOBUS_SH_SED} -n '/^GLOBUS_SH/s/=.*$//p' \ ${arch_sysconfdir}/globus-sh-commands.sh` do export ${_var} done GLOBUS_SH_VARIABLES_SET="Y" export GLOBUS_SH_VARIABLES_SET fi globus_source () { # Check if file exists and source it if [ ! -f "$1" ] ; then ${GLOBUS_SH_PRINTF-printf} "$1 not found.\n" >&2 exit 1 fi . "$1" } globus_get_ldap_path () { if [ -z "${GLOBUS_LDAP_PATH}" ]; then if [ -r "${arch_sysconfdir}/globus-ldap-path-32.sh" ] ; then globus_ldap_path_sh="${arch_sysconfdir}/globus-ldap-path-32.sh" elif [ -r "${arch_sysconfdir}/globus-ldap-path-64.sh" ] ; then globus_ldap_path_sh="${arch_sysconfdir}/globus-ldap-path-64.sh" else echo "ERROR: cannot resolve path to LDAP installation -- excepted" 1>&2 echo "to find this information in ${arch_sysconfdir}" 1>&2 echo "Set environment variable GLOBUS_LDAP_PATH and try again" 1>&2 exit 1 fi . "${globus_ldap_path_sh}" if [ -z "${GLOBUS_LDAP_PATH}" ]; then echo "ERROR: value for GLOBUS_LDAP_PATH not defined" 1>&2 echo "in ${globus_ldap_path_sh}" 1>&2 exit 1 fi fi } ################# END Inserted by configure ############# . ${sysconfdir}/grid-info.conf GRID_INFO_SYSTEM_LOGFILE=${localstatedir}/grid-info-system.log GRID_INFO_SYSTEM_ERRORFILE=${localstatedir}/grid-info-system.log . ${libexecdir}/grid-info-ldap-shell # conf file format # TTL command args... # # run command to generate LDIF on stdout, cache for TTL seconds # search_conf=${sysconfdir}/grid-info-resource.conf # cache_dir format: # # cache_dir/cldif.${entryno} # complete data only # cache_dir/command.${entryno} # command used to generate cldif.${entryno} # cache_dir/tmp.cldif.$$ # temp file for data in progress cache_dir=${localstatedir}/grid-info-resource-cache-`hostname` tmp_cldif_file=${cache_dir}/tmp.cldif.$$ # awkfile # temp file for request in progress awkfile=${localstatedir}/grid-info-resource.patt.awk.$$ if test ! -d ${cache_dir} then mkdir ${cache_dir} 2> /dev/null fi cleanup () { rm -f ${tmp_cldif_file} ${awkfile} } bailout () { cleanup exit 1 } trap cleanup 0 trap bailout 1 2 3 13 14 15 TIME_PERIOD=30 cache_entry_update () { # $1 = entryno # $2 = TTL # $3 = command string TTL="$2" if test "$TTL" -ge 0 2> /dev/null then # use TTL : else # non-numeric TTL means no caching TTL=0 rm -f ${cache_dir}/cldif.${1} fi if test -r ${cache_dir}/cldif.${1} then MOD=`${bindir}/globus-file-time -modify-time -utc-seconds \ "${cache_dir}/cldif.${1}"` NOW=`${bindir}/globus-date -utc-seconds` # how old the entry is in seconds AGE=`${GLOBUS_SH_EXPR} "$NOW" - "$MOD"` # remove stale registration if test "$AGE" -gt "$TTL" then rm -f "${cache_dir}/cldif.${1}" fi # make sure entry is up to date w/ conf file cache_cmd=`cat ${cache_dir}/command.${1} 2> /dev/null` if test ! "X${3}" = "X${cache_cmd}" then rm -f "${cache_dir}/cldif.${1}" fi fi if test ! -r ${cache_dir}/cldif.${1} then eval "${3}" | ldap_shell_ldif_line_collate \ | sed -e "/^ *#/d" >> ${tmp_cldif_file} && \ { mv -f ${tmp_cldif_file} ${cache_dir}/cldif.${1} ; \ rm -f ${cache_dir}/command.${1} ; \ echo "${3}" > ${cache_dir}/command.${1} ; } || \ ldap_shell_log_event "command failed: \"${3}\"" fi } awk=${GLOBUS_SH_AWK-awk} expr=${GLOBUS_SH_EXPR-expr} ############################################################### # Put stdin through ldif_line_collate # and pipe that into body of script ldap_shell_ldif_line_collate | \ { # # reading tag values # while read TAG VALUE; do case "$TAG" in base:) BASE=$VALUE ;; scope:) SCOPE=$VALUE ;; filter:) FILTER=$VALUE ;; esac done ldap_shell_log_event search: "base=\"${BASE}\"" "scope=\"${SCOPE}\"" \ "filter=\"${FILTER}\"" entryno=0 cat ${search_conf} | sed -e "/^ *#/d" -e "/^ *$/d" | \ while read ttl command do cache_entry_update "${entryno}" "${ttl}" "${command}" entryno=`${GLOBUS_SH_EXPR} "${entryno}" + 1` done # # parse the filter, and change it into the regular expression, # write the awk file with the r.e. # ${libexecdir}/grid-info-ldap-filter2awk \ "${BASE}" ${SCOPE} "${FILTER}" ${awkfile} if [ $? -ne 0 ]; then ldap_shell_log_error "execution failed \"${libexecdir}/grid-info-ldap-filter2awk "${FILTER}" ${awkfile}\"" echo "" echo "RESULT" exit 1 fi # # run awk, output results to stdout # rm -f ${tmp_cldif_file} for file in "" ${cache_dir}/cldif.* \ ${sysconfdir}/grid-info-tree.cldif do if test ! -z "$file" then cat "$file" 2> /dev/null echo "" fi done | ${GLOBUS_SH_SED-sed} -e "s/^[^:]*: *$/:/g" \ | ${GLOBUS_SH_GREP-grep} -v "^:" \ > ${tmp_cldif_file} ${awk} -f ${awkfile} ${tmp_cldif_file} echo "" echo "RESULT" echo "code: 0" } # end body reading from stdin | ldif_line_collate pipe ###############################################################