diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d48162c..70bf564 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -31,3 +31,9 @@ jobs: VALIDATE_ALL_CODEBASE: true # Fail on errors DISABLE_ERRORS: false + # XXX: Not working, see https://github.com/github/super-linter/issues/3552 + VALIDATE_GITLEAKS: false + # Ignore errors due to: + # - non constant source (SC1090) + # - No such file or directory (SC1091) + SHELLCHECK_OPTS: -e SC1090,SC1091 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..567609b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/CHANGELOG b/CHANGELOG index 3356c79..d64b8c6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,3 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] + +## [1.14.0] - 2023-04-11 + +## Added + +- Drop some deprecated providers (gatekeeper, gridice, lbserver, wmproxy). (#3) (Baptiste Grenier) +- Lint code. (#3) (Enol Fernandez) (Baptiste Grenier) +- Add Community files and GitHub actions. (#2) (Baptiste Grenier) +- Build and release using CentOS 7, AlmaLinux 8 and 9. (#2) (Baptiste Grenier) diff --git a/Makefile b/Makefile index 82b18b6..952fc60 100755 --- a/Makefile +++ b/Makefile @@ -13,8 +13,8 @@ install: @mkdir -p $(prefix)/etc/glite/info/service/ @mkdir -p $(prefix)/usr/share/doc/$(NAME)-$(VERSION) @mkdir -p $(prefix)/usr/share/licenses/$(NAME)-$(VERSION) - @install -m 0755 src/$(NAME) $(prefix)/usr/bin - @install -m 0755 src/$(NAME)-* $(prefix)/usr/bin + @install -m 0755 src/glite-info-service $(prefix)/usr/bin + @install -m 0755 src/glite-info-service-* $(prefix)/usr/bin @install -m 0755 src/glite-info-glue2-* $(prefix)/usr/bin @install -m 0644 etc/*.template $(prefix)/etc/glite/info/service/ @install -m 0644 etc/*.test.ldif* $(prefix)/etc/glite/info/service/ diff --git a/debian/changelog b/debian/changelog index 6df84e2..9c2797f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +glue-service-provider (1.14.0-1) UNRELEASED; urgency=low + + * Drop some deprecated providers (gatekeeper, gridice, lbserver, wmproxy). (#3) (Baptiste Grenier) + * Lint code. (#3) (Enol Fernandez) (Baptiste Grenier) + * Add Community files and GitHub actions. (#2) (Baptiste Grenier) + * Build and release using CentOS 7, AlmaLinux 8 and 9. (#2) (Baptiste Grenier) + + -- Baptiste Grenier Tue, 11 Apr 2023 10:21:00 +0100 + glue-service-provider (1.13.4-1) UNRELEASED; urgency=low * New upstream release diff --git a/doc/README b/doc/README index 738ed05..5e0bf74 100644 --- a/doc/README +++ b/doc/README @@ -196,14 +196,6 @@ LDAP protocol version 3. It might also be useful to publish the Glue schema version as ServiceData, but this has not so far been implemented as there doesn't seem to be an especially easy way to do it. -gridice: - -The version number is for the gridice-sensor RPM. - -The default hostname and port can be overridden with the GRIDICE_HOST -and GRIDICE_PORT variables if necessary. There seems to be no config -file per se, and the location of the PID file is hardwired. - gsirfio: This is just a barebones implementation, it's not clear if we will want to @@ -232,19 +224,6 @@ GlueServiceAccessControlBaseRule: MYPROXY:trusted_retrievers=/DC=ch/DC=cern/OU=c There is no pid file, but there is a lock file so the creation time is used for the service start time. -Gatekeeper: - -This is for the EDG/Globus GT2 gatekeeper on the LCG CE. The version is set -to 2.0.0, which seems to be the protocol version for the GT2 GRAM. - -As usual the hostname and port can be overridden if necessary by setting the -GATEKEEPER_PORT and GATEKEEPER_HOST environment variables. - -The start time is taken from the timestamp on the relevant /proc directory. - -A comma-separated list of the supported jobmanagers is output as a ServiceData -object with Key=Services. The host DN is also output with Key=DN. - CREAM/CEMon: These two services both run under tomcat, so the configuration is very similar @@ -262,25 +241,6 @@ unlikely to change. Possibly CREAM and CEMon should be connected as related services, but this isn't implemented for now. -WMProxy: - -The version is taken from the server RPM, although it's not entirely clear -if this gives the desired result (the interface version). - -The hostname and port can be overridden as usual if necessary, but these -are read from a config file so this should not normally be needed. - -The DN of the host certificate is put into a ServiceData object with key "DN" -to enable matching against the authorised renewer list published by a myproxy. - -LBServer: - -There is apparently no config file. If necessary the default host and port -can be overridden with the LBSERVER_PORT and LBSERVER_HOST variables. - -The version is taken from the server RPM, although it's not entirely clear -if this gives the desired result (the interface version). - VOMS: A VOMS server has a separate service for each VO served. The usage diff --git a/docker/deb/80-acquire-retries b/docker/deb/80-acquire-retries deleted file mode 100644 index 62e52a8..0000000 --- a/docker/deb/80-acquire-retries +++ /dev/null @@ -1 +0,0 @@ -APT::Acquire::Retries 20; diff --git a/docker/deb/Dockerfile b/docker/deb/Dockerfile deleted file mode 100644 index 1b0881a..0000000 --- a/docker/deb/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -# Docker image for building deb packages -FROM ubuntu:xenial -MAINTAINER Baptiste Grenier - -ENV DEBIAN_FRONTEND noninteractive -ENV DEBIAN_PRIORITY critical -ENV DEBCONF_NOWARNINGS yes - -# Install build tools -COPY 80-acquire-retries /etc/apt/apt.conf.d/ -RUN apt-get -y update -RUN apt-get -o "Dpkg::Options::=--force-confnew" -y dist-upgrade -RUN apt-get -y --no-install-recommends install build-essential devscripts debhelper -RUN apt-get -y --no-install-recommends install rsync -RUN apt-get -y --no-install-recommends install python-support - -VOLUME /output - -COPY build-deb /root - -ENTRYPOINT /root/build-deb diff --git a/docker/deb/build-deb b/docker/deb/build-deb deleted file mode 100755 index 22e19ff..0000000 --- a/docker/deb/build-deb +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -set -e - -trap 'chown -R --reference /tmp/source /output/' EXIT - -rsync -a /source /tmp/ -cd /tmp/source -make deb -cp /tmp/source/build/*.deb /output diff --git a/etc/glite-info-glue2-lbserver.conf.template b/etc/glite-info-glue2-lbserver.conf.template deleted file mode 100644 index 1b10679..0000000 --- a/etc/glite-info-glue2-lbserver.conf.template +++ /dev/null @@ -1,95 +0,0 @@ - -# This is the configuration file for the GlueService information provider -# for the lb-server - -# Now extended for GLUE 2 attributes - -# Many of the entries are commands which will be executed -# using backquotes in perl. They should write to stdout - the return -# code is not relevant except for init and status. - -# The init command allows any setup command to be executed -# A non-zero return code will abort the provider -# Environment variables can be set by writing to stdout (x=y) - -init = glite-info-service-lbserver - -# The service type should follow the official list in -# http://glueschema.forge.cnaf.infn.it/V12/ServiceType - -service_type = org.glite.lb.Server - -# This should be a command which returns the service interface version -# in the format 3[.2[.1]]. - -get_version = rpm -qa | grep glite-lb-ws-interface | cut -d- -f5 - -# A command to return the service endpoint to stdout (uses variables set -# in the init script) - -get_endpoint = echo https://$LBSERVER_HOST:$LBSERVER_PORT/ - -# A command to check the status of the service. The status message should be -# returned to stdout - it can be multi-line, the output will be massaged -# and truncated if necessary. -# The return code should indicate the status: -# 0 = OK, 1 = Critical, 2 = Warning, 3 = Unknown, other = Other - -get_status = glite-info-service-test LBSERVER && glite-info-service-status glite-lb-bkserverd - -# The URL of a WSDL document describing the service -# If the string does not start with "http" this will be omitted - -WSDL_URL = http://egee.cesnet.cz/cms/export/sites/egee/en/WSDL/3.1/LB.wsdl - -# A URL to a web page defining the service semantics, e.g. a manual -# If the string does not start with "http" this will be omitted - -semantics_URL = https://edms.cern.ch/file/571273/2/LB-guide.pdf - -# StartTime: A command to return the service start time. -# This should be a unix timestamp, the info provider converts it to ISO8601 - -get_starttime = perl -e '@st=stat($ENV{LBSERVER_PID_FILE});print "@st[10]\n";' - -# Owner: this should return a list of owner VO names, one per line -# Null entries will be omitted -# Needs to be set at config time, no easy way to get it dynamically - -get_owner = echo - -# A list of AccessControlBaseRule strings to indicate who is allowed to -# have access to the service - at the simplest this is the same as the -# Owner but with the VO names prefixed by "VO:" -# Needs to be set at config time, no easy way to get it dynamically - -get_acbr = echo - -# New GLUE 2 attributes start here - -# Capabilities are not very well-defined yet! -# This seems about the best match from the current list - -get_capabilities = echo information.logging - -# These three identify the specific implementation as opposed to the generic -# protocol. NB this version is single-valued. - -get_implementor = echo gLite - -get_implementationname = echo LB - -get_implementationversion = rpm -qa | grep 'glite-lb-server-[0-9]' | cut -d- -f4 - -# The Quality Level for this endpoint: 1 = development, 2 = testing, -# 3 = pre-production and 4 = production -# No mechanism yet to set this - -get_qualitylevel = echo 4 - -# The ServingState for this Endpoint: 1 = closed, 2 = draining, -# 3 = queueing, 4 = production (NB "production" has a different meaning -# here to the QualityLevel) -# Just hardwired for now - -get_servingstate = echo 4 diff --git a/etc/glite-info-glue2-wmproxy.conf.template b/etc/glite-info-glue2-wmproxy.conf.template deleted file mode 100644 index 6b46f30..0000000 --- a/etc/glite-info-glue2-wmproxy.conf.template +++ /dev/null @@ -1,105 +0,0 @@ - -# This is the configuration file for the GlueService information provider -# for a wmproxy endpoint - -# Now extended for GLUE 2 attributes - -# Many of the entries are commands which will be executed -# using backquotes in perl. They should write to stdout - the return -# code is not relevant except for init and status. - -# The init command allows any setup command to be executed -# A non-zero return code will abort the provider -# Environment variables can be set by writing to stdout (x=y) - -init = glite-info-service-wmproxy - -# The service type should follow the official list in -# http://glueschema.forge.cnaf.infn.it/V12/ServiceType - -service_type = org.glite.wms.WMProxy - -# This should be a command which returns the service interface version -# in the format 3[.2[.1]]. Hardwire to 1.0 for now in the absence of anything better. - -get_version = echo 1.0 - -# A command to return the service endpoint to stdout (uses variables set -# in the init script) - -get_endpoint = echo https://$WMPROXY_HOST:$WMPROXY_PORT/glite_wms_wmproxy_server - -# A command to check the status of the service. The status message should be -# returned to stdout - it can be multi-line, the output will be massaged -# and truncated if necessary. -# The return code should indicate the status: -# 0 = OK, 1 = Critical, 2 = Warning, 3 = Unknown, other = Other - -get_status = glite-info-service-test WMPROXY && glite-info-service-status glite-wms-wmproxy - -# The URL of a WSDL document describing the service -# If the string does not start with "http" this will be omitted - -WSDL_URL = http://web.infn.it/gLiteWMS/images/WMS/Docs/wmproxy.wsdl - -# A URL to a web page defining the service semantics, e.g. a manual -# If the string does not start with "http" this will be omitted - -semantics_URL = http://web.infn.it/gLiteWMS/images/WMS/Docs/wmproxy-guide.pdf - -# StartTime: A command to return the service start time. -# This should be a unix timestamp, the info provider converts it to ISO8601 - -get_starttime = perl -e '@st=stat($ENV{WMPROXY_PID_FILE});print "@st[10]\n";' - -# Owner: this should return a list of owner VO names, one per line -# Null entries will be omitted -# Needs to be set at config time, no easy way to get it dynamically - -get_owner = echo - -# A list of AccessControlBaseRule strings to indicate who is allowed to -# have access to the service - at the simplest this is the same as the -# Owner but with the VO names prefixed by "VO:" -# Needs to be set at config time, no easy way to get it dynamically - -get_acbr = echo - -# ServiceData entries if any, as a list of key=value pairs -# This will normally call a separate script -# Here we print the host DN to match against the MyProxy authz - -#get_data = echo -n DN= && grid-cert-info -file /etc/grid-security/hostcert.pem -subject - -# Change to use openssl to avoid the dependency on globus - -get_data = echo -n DN= && openssl x509 -in /etc/grid-security/hostcert.pem -noout -subject | cut -d = -f 2- - -# New GLUE 2 attributes start here - -# Capabilities are not very well-defined yet! - -get_capabilities = echo -e "executionmanagement.candidatesetgenerator\nexecutionmanagement.jobdescription\nexecutionmanagement.jobmanager" - -# These three identify the specific implementation as opposed to the generic -# protocol. NB this version is single-valued. - -get_implementor = echo gLite - -get_implementationname = echo WMS - -get_implementationversion = rpm -q $WMPROXY_RPM --queryformat '%{version}\n' - -# The Quality Level for this endpoint: 1 = development, 2 = testing, -# 3 = pre-production and 4 = production -# No mechanism yet to set this - -get_qualitylevel = echo 4 - -# The ServingState for this Endpoint: 1 = closed, 2 = draining, -# 3 = queueing, 4 = production (NB "production" has a different meaning -# here to the QualityLevel) -# The WMS is in a draining state if a file called /etc/glite-wms/.drain exists - -get_servingstate = [ -e /etc/glite-wms/.drain ] && echo 2 || echo 4 - diff --git a/etc/glite-info-service-gatekeeper.conf.template b/etc/glite-info-service-gatekeeper.conf.template deleted file mode 100644 index a4bb98a..0000000 --- a/etc/glite-info-service-gatekeeper.conf.template +++ /dev/null @@ -1,73 +0,0 @@ - -# This is the configuration file for the GlueService information provider -# for the EDG/Globus gatekeeper on the LCG CE - -# Many of the entries are commands which will be executed -# using backquotes in perl. They should write to stdout - the return -# code is not relevant except for init and status. - -# The init command allows any setup command to be executed -# A non-zero return code will abort the provider -# Environment variables can be set by writing to stdout (x=y) - -init = glite-info-service-gatekeeper - -# The service type should follow the official list in -# http://glueschema.forge.cnaf.infn.it/V12/ServiceType - -service_type = org.edg.gatekeeper - -# This should be a command which returns the service interface version -# in the format 3[.2[.1]] - just hardwire to 2.0.0 here. GT2 apparently -# uses GRAM protocol version 2, see -# http://www-unix.globus.org/api/c-globus-2.4/globus_gram_protocol/html/globus_gram_protocol.html#globus_gram_protocol - -get_version = echo 2.0.0 - -# A command to return the service endpoint to stdout (uses variables set -# in the init script) - -get_endpoint = echo gram://$GATEKEEPER_HOST:$GATEKEEPER_PORT/ - -# A command to check the status of the service. The status message should be -# returned to stdout - it can be multi-line, the output will be massaged -# and truncated if necessary. -# The return code should indicate the status: -# 0 = OK, 1 = Critical, 2 = Warning, 3 = Unknown, other = Other - -get_status = glite-info-service-test GATEKEEPER && /sbin/service globus-gatekeeper status - -# The URL of a WSDL document describing the service -# If the string does not start with "http" this will be omitted - -WSDL_URL = nohttp://not.a.web.service/ - -# A URL to a web page defining the service semantics, e.g. a manual -# If the string does not start with "http" this will be omitted - -semantics_URL = http://www.globus.org/toolkit/docs/2.4/gram/ - -# StartTime: A command to return the service start time. -# This should be a unix timestamp, the info provider converts it to ISO8601 - -get_starttime = perl -e '@st=stat($ENV{GATEKEEPER_PROCDIR});print "@st[10]\n";' - -# Owner: this should return a list of owner VO names, one per line -# Null entries will be omitted - -get_owner = echo - -# A list of AccessControlBaseRule strings to indicate who is allowed to -# have access to the service - at the simplest this is the same as the -# Owner but with the VO names prefixed by "VO:" - -get_acbr = echo - -# ServiceData entries if any, as a list of key=value pairs -# This will normally call a separate script - -get_data = echo -en "Services=$GATEKEEPER_SERVICES\nDN=" && grid-cert-info -file /etc/grid-security/hostcert.pem -subject - -# Associated services - not used here - -get_services = echo diff --git a/etc/glite-info-service-gridice.conf.template b/etc/glite-info-service-gridice.conf.template deleted file mode 100644 index 38039d6..0000000 --- a/etc/glite-info-service-gridice.conf.template +++ /dev/null @@ -1,73 +0,0 @@ - -# This is the configuration file for the GlueService information provider -# for gridice - -# Many of the entries are commands which will be executed -# using backquotes in perl. They should write to stdout - the return -# code is not relevant except for init and status. - -# The init command allows any setup command to be executed -# A non-zero return code will abort the provider -# Environment variables can be set by writing to stdout (x=y) - -init = glite-info-service-gridice - -# The service type should follow the official list in -# http://glueschema.forge.cnaf.infn.it/V12/ServiceType - -service_type = it.infn.GridICE - -# This should be a command which returns the service interface version -# in the format 3[.2[.1]] - for gridice just take the sensor rpm version - -get_version = rpm -qa | grep gridice-sensor | cut -d- -f3 - -# A command to return the service endpoint to stdout (uses variables set -# in the init script) - -get_endpoint = echo ldap://$GRIDICE_HOST:$GRIDICE_PORT/mds-vo-name=local,o=grid - -# A command to check the status of the service. The status message should be -# returned to stdout - it can be multi-line, the output will be massaged -# and truncated if necessary. -# The return code should indicate the status: -# 0 = OK, 1 = Critical, 2 = Warning, 3 = Unknown, other = Other - -get_status = glite-info-service-test GRIDICE && /sbin/service gridice-mds status - -# The URL of a WSDL document describing the service -# If the string does not start with "http" this will be omitted - -WSDL_URL = nohttp://not.a.web.service/ - -# A URL to a web page defining the service semantics, e.g. a manual -# If the string does not start with "http" this will be omitted - -semantics_URL = http://gridice.forge.cnaf.infn.it/ - -# StartTime: A command to return the service start time. -# This should be a unix timestamp, the info provider converts it to ISO8601 - -get_starttime = perl -e '@st=stat($ENV{GRIDICE_PID_FILE});print "@st[10]\n";' - -# Owner: this should return a list of owner VO names, one per line -# Null entries will be omitted -# gridice has no access control - -get_owner = echo - -# A list of AccessControlBaseRule strings to indicate who is allowed to -# have access to the service - at the simplest this is the same as the -# Owner but with the VO names prefixed by "VO:" -# gridice has no access control - -get_acbr = echo - -# ServiceData entries if any, as a list of key=value pairs -# This will normally call a separate script - -get_data = echo - -# Associated services - not used here - -get_services = echo diff --git a/etc/glite-info-service-lbserver.conf.template b/etc/glite-info-service-lbserver.conf.template deleted file mode 100644 index dd79c22..0000000 --- a/etc/glite-info-service-lbserver.conf.template +++ /dev/null @@ -1,73 +0,0 @@ - -# This is the configuration file for the GlueService information provider -# for the lb-server - -# Many of the entries are commands which will be executed -# using backquotes in perl. They should write to stdout - the return -# code is not relevant except for init and status. - -# The init command allows any setup command to be executed -# A non-zero return code will abort the provider -# Environment variables can be set by writing to stdout (x=y) - -init = glite-info-service-lbserver - -# The service type should follow the official list in -# http://glueschema.forge.cnaf.infn.it/V12/ServiceType - -service_type = org.glite.lb.Server - -# This should be a command which returns the service interface version -# in the format 3[.2[.1]]. Set to the RPM version for the LB server. - -get_version = rpm -qa | grep 'glite-lb-server-[0-9]' | cut -d- -f4 - -# A command to return the service endpoint to stdout (uses variables set -# in the init script) - -get_endpoint = echo https://$LBSERVER_HOST:$LBSERVER_PORT/ - -# A command to check the status of the service. The status message should be -# returned to stdout - it can be multi-line, the output will be massaged -# and truncated if necessary. -# The return code should indicate the status: -# 0 = OK, 1 = Critical, 2 = Warning, 3 = Unknown, other = Other - -get_status = glite-info-service-test LBSERVER && glite-info-service-status glite-lb-bkserverd - -# The URL of a WSDL document describing the service -# If the string does not start with "http" this will be omitted - -WSDL_URL = http://egee.cesnet.cz/cms/export/sites/egee/en/WSDL/3.1/LB.wsdl - -# A URL to a web page defining the service semantics, e.g. a manual -# If the string does not start with "http" this will be omitted - -semantics_URL = https://edms.cern.ch/file/571273/2/LB-guide.pdf - -# StartTime: A command to return the service start time. -# This should be a unix timestamp, the info provider converts it to ISO8601 - -get_starttime = perl -e '@st=stat($ENV{LBSERVER_PID_FILE});print "@st[10]\n";' - -# Owner: this should return a list of owner VO names, one per line -# Null entries will be omitted -# Needs to be set at config time, no easy way to get it dynamically - -get_owner = echo - -# A list of AccessControlBaseRule strings to indicate who is allowed to -# have access to the service - at the simplest this is the same as the -# Owner but with the VO names prefixed by "VO:" -# Needs to be set at config time, no easy way to get it dynamically - -get_acbr = echo - -# ServiceData entries if any, as a list of key=value pairs -# This will normally call a separate script - -get_data = echo - -# Associated services - not used here - -get_services = echo diff --git a/etc/glite-info-service-wmproxy.conf.template b/etc/glite-info-service-wmproxy.conf.template deleted file mode 100644 index 54bd509..0000000 --- a/etc/glite-info-service-wmproxy.conf.template +++ /dev/null @@ -1,78 +0,0 @@ - -# This is the configuration file for the GlueService information provider -# for a wmproxy - -# Many of the entries are commands which will be executed -# using backquotes in perl. They should write to stdout - the return -# code is not relevant except for init and status. - -# The init command allows any setup command to be executed -# A non-zero return code will abort the provider -# Environment variables can be set by writing to stdout (x=y) - -init = glite-info-service-wmproxy - -# The service type should follow the official list in -# http://glueschema.forge.cnaf.infn.it/V12/ServiceType - -service_type = org.glite.wms.WMProxy - -# This should be a command which returns the service interface version -# in the format 3[.2[.1]]. Set to the RPM version. - -get_version = rpm -q $WMPROXY_RPM --queryformat '%{version}\n' - -# A command to return the service endpoint to stdout (uses variables set -# in the init script) - -get_endpoint = echo https://$WMPROXY_HOST:$WMPROXY_PORT/glite_wms_wmproxy_server - -# A command to check the status of the service. The status message should be -# returned to stdout - it can be multi-line, the output will be massaged -# and truncated if necessary. -# The return code should indicate the status: -# 0 = OK, 1 = Critical, 2 = Warning, 3 = Unknown, other = Other - -get_status = glite-info-service-test WMPROXY && /etc/init.d/glite-wms-wmproxy status - -# The URL of a WSDL document describing the service -# If the string does not start with "http" this will be omitted - -WSDL_URL = http://web.infn.it/gLiteWMS/images/WMS/Docs/wmproxy.wsdl - -# A URL to a web page defining the service semantics, e.g. a manual -# If the string does not start with "http" this will be omitted - -semantics_URL = http://web.infn.it/gLiteWMS/images/WMS/Docs/wmproxy-guide.pdf - -# StartTime: A command to return the service start time. -# This should be a unix timestamp, the info provider converts it to ISO8601 - -get_starttime = perl -e '@st=stat($ENV{WMPROXY_PID_FILE});print "@st[10]\n";' - -# Owner: this should return a list of owner VO names, one per line -# Null entries will be omitted -# Needs to be set at config time, no easy way to get it dynamically - -get_owner = echo - -# A list of AccessControlBaseRule strings to indicate who is allowed to -# have access to the service - at the simplest this is the same as the -# Owner but with the VO names prefixed by "VO:" -# Needs to be set at config time, no easy way to get it dynamically - -get_acbr = echo - -# ServiceData entries if any, as a list of key=value pairs -# This will normally call a separate script -# Here we print the host DN to match against the MyProxy authz - -#get_data = echo -n DN= && grid-cert-info -file /etc/grid-security/hostcert.pem -subject - -# Change to use openssl to avoid the dependency on globus - -get_data = echo -n DN= && openssl x509 -in /etc/grid-security/hostcert.pem -noout -subject | cut -d = -f 2- - -# Associated services - not used here - -get_services = echo diff --git a/glite-info-provider-service.spec b/glite-info-provider-service.spec index 4c04d78..fc06122 100644 --- a/glite-info-provider-service.spec +++ b/glite-info-provider-service.spec @@ -1,10 +1,10 @@ Name: glite-info-provider-service -Version: 1.13.4 +Version: 1.14.0 Release: 1%{?dist} Summary: The GLUE service information provider Group: Development/Libraries License: ASL 2.0 -URL: https://github.com/EGI-Federation/glite-info-provider-ldap +URL: https://github.com/EGI-Federation/glite-info-provider-service Source: %{name}-%{version}.tar.gz BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -29,7 +29,7 @@ rm -rf %{buildroot} %files %defattr(-,root,root,-) -%dir ${_sysconfdir}/glite/info/service +%dir %{_sysconfdir}/glite/info/service %{_bindir}/glite-info-glue2-service %{_bindir}/glite-info-glue2-endpoint %{_bindir}/glite-info-glue2-simple @@ -42,21 +42,17 @@ rm -rf %{buildroot} %{_bindir}/glite-info-service-amga %{_bindir}/glite-info-service-argus %{_bindir}/glite-info-service-bdii -%{_bindir}/glite-info-service-gridice %{_bindir}/glite-info-service-vobox %{_bindir}/glite-info-service-voms %{_bindir}/glite-info-service-voms-wrapper %{_bindir}/glite-info-service-voms-admin %{_bindir}/glite-info-service-myproxy -%{_bindir}/glite-info-service-wmproxy -%{_bindir}/glite-info-service-lbserver %{_bindir}/glite-info-service-frontier %{_bindir}/glite-info-service-squid %{_bindir}/glite-info-service-cream %{_bindir}/glite-info-service-dcache %{_bindir}/glite-info-service-dpm %{_bindir}/glite-info-service-rtepublisher -%{_bindir}/glite-info-service-gatekeeper %{_bindir}/glite-info-service-status %{_sysconfdir}/glite/info/service/glite-info-glue2-amga.conf.template %{_sysconfdir}/glite/info/service/glite-info-glue2-argus-pap.conf.template @@ -64,7 +60,6 @@ rm -rf %{buildroot} %{_sysconfdir}/glite/info/service/glite-info-glue2-argus-pdp.conf.template %{_sysconfdir}/glite/info/service/glite-info-glue2-bdii-site.conf.template %{_sysconfdir}/glite/info/service/glite-info-glue2-bdii-top.conf.template -%{_sysconfdir}/glite/info/service/glite-info-glue2-lbserver.conf.template %{_sysconfdir}/glite/info/service/glite-info-glue2-rtepublisher.conf.template %{_sysconfdir}/glite/info/service/glite-info-glue2-vobox.conf.template %{_sysconfdir}/glite/info/service/glite-info-glue2-voms.conf.template @@ -73,7 +68,6 @@ rm -rf %{buildroot} %{_sysconfdir}/glite/info/service/glite-info-glue2-squid.conf.template %{_sysconfdir}/glite/info/service/glite-info-glue2-myproxy.conf.template %{_sysconfdir}/glite/info/service/glite-info-glue2-cemon.conf.template -%{_sysconfdir}/glite/info/service/glite-info-glue2-wmproxy.conf.template %{_sysconfdir}/glite/info/service/glite-info-service-test.conf.template %{_sysconfdir}/glite/info/service/glite-info-service-amga.conf.template %{_sysconfdir}/glite/info/service/glite-info-service-argus-pap.conf.template @@ -82,9 +76,7 @@ rm -rf %{buildroot} %{_sysconfdir}/glite/info/service/glite-info-service-bdii.conf.template %{_sysconfdir}/glite/info/service/glite-info-service-bdii-site.conf.template %{_sysconfdir}/glite/info/service/glite-info-service-bdii-top.conf.template -%{_sysconfdir}/glite/info/service/glite-info-service-gridice.conf.template %{_sysconfdir}/glite/info/service/glite-info-service-gsirfio.conf.template -%{_sysconfdir}/glite/info/service/glite-info-service-lbserver.conf.template %{_sysconfdir}/glite/info/service/glite-info-service-frontier.conf.template %{_sysconfdir}/glite/info/service/glite-info-service-squid.conf.template %{_sysconfdir}/glite/info/service/glite-info-service-cream.conf.template @@ -97,9 +89,7 @@ rm -rf %{buildroot} %{_sysconfdir}/glite/info/service/glite-info-service-srm-dcache-v2.conf.template %{_sysconfdir}/glite/info/service/glite-info-service-srm-dpm-v1.conf.template %{_sysconfdir}/glite/info/service/glite-info-service-srm-dpm-v2.conf.template -%{_sysconfdir}/glite/info/service/glite-info-service-wmproxy.conf.template %{_sysconfdir}/glite/info/service/glite-info-service-rtepublisher.conf.template -%{_sysconfdir}/glite/info/service/glite-info-service-gatekeeper.conf.template %{_sysconfdir}/glite/info/service/glite-info-glue2-test.conf.template %{_sysconfdir}/glite/info/service/glite-info-glue2-test2.conf.template %{_sysconfdir}/glite/info/service/glite-info-glue2-service-test.conf.template @@ -113,15 +103,21 @@ rm -rf %{buildroot} %doc %{_docdir}/%{name}-%{version}/README %doc %{_docdir}/%{name}-%{version}/README-GLUE2 %doc %{_docdir}/%{name}-%{version}/AUTHORS.md -%license ${_datadir}/licenses/%{name}-%{version}/COPYRIGHT -%license ${_datadir}/licenses/%{name}-%{version}/LICENSE.txt +%license %{_datadir}/licenses/%{name}-%{version}/COPYRIGHT +%license %{_datadir}/licenses/%{name}-%{version}/LICENSE.txt %changelog +* Tue Apr 11 2023 Baptiste Grenier - 1.14.0-1 +- Drop some deprecated providers (gatekeeper, gridice, lbserver, wmproxy). (#3) (Baptiste Grenier) +- Lint code. (#3) (Enol Fernandez) (Baptiste Grenier) +- Add Community files and GitHub actions. (#2) (Baptiste Grenier) +- Build and release using CentOS 7, AlmaLinux 8 and 9. (#2) (Baptiste Grenier) + * Mon Aug 04 2014 Stephen Burke - 1.13.4-1 - Patch for the RTEPublisher start time, GGUS #107264 - Publish the schema version as OtherInfo for the site and top BDII -* Thu Apr 15 2014 Stephen Burke - 1.13.3-1 +* Tue Apr 15 2014 Stephen Burke - 1.13.3-1 - Change the RPM name for the tag publisher version, bug #102207 * Thu Aug 01 2013 Stephen Burke - 1.13.1-1 diff --git a/src/glite-info-glue2-endpoint b/src/glite-info-glue2-endpoint index 86e91cd..57fc23f 100755 --- a/src/glite-info-glue2-endpoint +++ b/src/glite-info-glue2-endpoint @@ -1,6 +1,5 @@ #!/usr/bin/perl -w -# # glite-info-glue2-endpoint: an information provider for the # Endpoint and associated AccessPolicy objects, in v 2.0 of the GLUE schema # Ref: http://www.ogf.org/documents/GFD.147.pdf @@ -82,8 +81,9 @@ my $SUID = $ARGV[1]; $SUID =~ s/\s+//g if ($SUID); # We must have at least 2 arguments -if (!$SUID) { - print STDERR "Usage: glite-info-glue2-endpoint []\n"; +if ( !$SUID ) { + print STDERR +"Usage: glite-info-glue2-endpoint []\n"; exit 1; } @@ -94,61 +94,75 @@ my $bind_dn = "GLUE2ServiceID=$SUID,GLUE2GroupID=resource,o=glue"; # Non-mandatory attributes get a default value, usually "echo" i.e. empty my %config = ( - init => 'echo', -# The type (actually InterfaceName) is mandatory - service_type => '', - get_otherinfo => 'echo', -# We must have an endpoint! - get_endpoint => '', - get_capabilities => 'echo', - get_technology => 'echo', -# Version is technically not mandatory, but I think we should require it - get_version => '', - get_interfaceextensions => 'echo', - get_WSDL => 'echo', -# Legacy attribute for glue 1 config files - WSDL_URL => 'nohttp://nothing.to.see.here/', - get_profiles => 'echo', - get_semantics => 'echo', -# Legacy attribute for glue 1 config files - semantics_URL => 'nohttp://nothing.to.see.here/', -# It may be good to require these but they aren't in the 1.3 config files, -# so make them optional for now - get_implementor => 'echo', - get_implementationname => 'echo', - get_implementationversion => 'echo', -# Similarly this is not defined for 1.3, so default to "production" for -# now but maybe it should become mandatory - get_qualitylevel => 'echo 4', -# Status is now called HealthState, but remains mandatory - get_status => '', -# As for QualityLevel, supply a default for ServingState for now -# but it should probably become mandatory - get_servingstate => 'echo 4', -# StartTime is technically not mandatory but we should continue to require it - get_starttime => '', - get_extensions => 'echo', - get_data => 'echo', - get_acbr => 'echo', - get_owner => 'echo', - ); + init => 'echo', + + # The type (actually InterfaceName) is mandatory + service_type => '', + get_otherinfo => 'echo', + + # We must have an endpoint! + get_endpoint => '', + get_capabilities => 'echo', + get_technology => 'echo', + + # Version is technically not mandatory, but I think we should require it + get_version => '', + get_interfaceextensions => 'echo', + get_WSDL => 'echo', + + # Legacy attribute for glue 1 config files + WSDL_URL => 'nohttp://nothing.to.see.here/', + get_profiles => 'echo', + get_semantics => 'echo', + + # Legacy attribute for glue 1 config files + semantics_URL => 'nohttp://nothing.to.see.here/', + + # It may be good to require these but they aren't in the 1.3 config files, + # so make them optional for now + get_implementor => 'echo', + get_implementationname => 'echo', + get_implementationversion => 'echo', + + # Similarly this is not defined for 1.3, so default to "production" for + # now but maybe it should become mandatory + get_qualitylevel => 'echo 4', + + # Status is now called HealthState, but remains mandatory + get_status => '', + + # As for QualityLevel, supply a default for ServingState for now + # but it should probably become mandatory + get_servingstate => 'echo 4', + + # StartTime is technically not mandatory but we should continue to require it + get_starttime => '', + get_extensions => 'echo', + get_data => 'echo', + get_acbr => 'echo', + get_owner => 'echo', +); # Read in the configuration file -my $fh = new FileHandle $confile - or die "Error: Can't open configuration file: $confile\n"; +my $fh = FileHandle->new($confile) + or die "Error: Can't open configuration file: $confile\n"; foreach (<$fh>) { -# For lines containing an = and not starting with # - if ( (! m/^\#/) & (m/=/) ) { -# Split on the first =, no leading or trailing whitespace in the value - m/^(.*?)=\s*(.*)\s*$/; -# The first part is the config key name, the rest is the value - my $key = $1; - my $value = $2; -# No whitespace in the key - $key =~ s/\s+//g; - $config{$key} = $value; + + # For lines containing an = and not starting with # + if ( ( !m/^\#/ ) & (m/=/) ) { + + # Split on the first =, no leading or trailing whitespace in the value + m/^(.*?)=\s*(.*)\s*$/; + + # The first part is the config key name, the rest is the value + my $key = $1; + my $value = $2; + + # No whitespace in the key + $key =~ s/\s+//g; + $config{$key} = $value; } } @@ -157,14 +171,15 @@ close $fh; # Check that all configuration items are set to something my $missing = 0; -while ( my ($key, $value) = each(%config) ) { - if ( ! $config{$key} ) { +while ( my ( $key, $value ) = each(%config) ) { + if ( !$config{$key} ) { print STDERR "Error: configuration parameter $key not set\n"; $missing += 1; } } if ($missing) { - print STDERR "Error: $missing configuration parameter(s) not set in file $confile\n"; + print STDERR + "Error: $missing configuration parameter(s) not set in file $confile\n"; exit 2; } @@ -180,7 +195,7 @@ if ($missing) { $command = $config{init}; my @init_result = `$command`; -my $init_rc = $? >> 8; +my $init_rc = $? >> 8; if ($init_rc) { print STDERR "Error: init command $command failed\n"; print STDERR "@init_result\n"; @@ -188,17 +203,20 @@ if ($init_rc) { } foreach (@init_result) { -# Should be key=value pairs - if ( m/=/ ){ -# Split on the first =, no leading or trailing whitespace in the value + + # Should be key=value pairs + if (m/=/) { + + # Split on the first =, no leading or trailing whitespace in the value m/^(.*?)=\s*(.*)\s*$/; - my $key = $1; + my $key = $1; my $value = $2; -# No whitespace in the key + + # No whitespace in the key $key =~ s/\s+//g; - if ($key) { - $ENV{$key} = $value; - } + if ($key) { + $ENV{$key} = $value; + } } } @@ -240,7 +258,7 @@ my @WSDL = `$command`; # Legacy support for 1.3 config files my $WSDL = $config{WSDL_URL}; -if ($WSDL =~ m/^http/) { +if ( $WSDL =~ m/^http/ ) { push @WSDL, $WSDL; } @@ -253,7 +271,7 @@ my @Semantics = `$command`; # Legacy support for 1.3 config files my $Semantics = $config{semantics_URL}; -if ($Semantics =~ m/^http/) { +if ( $Semantics =~ m/^http/ ) { push @Semantics, $Semantics; } @@ -271,6 +289,7 @@ my $QualityLevel = `$command`; $command = $config{get_status}; my $Info = `$command`; + # We need to keep the return code from the status command my $Status = $? >> 8; @@ -300,7 +319,7 @@ my @Owner = `$command`; # The GLUE2EndpointID needs to be unique by construction. # We already have a unique Service ID so we just need to append something -# locally unique to distinguish multiple endpoints. +# locally unique to distinguish multiple endpoints. # There may be a need to preserve a persistent ID in some cases, # hence the entire ID can be passed as an optional third argument @@ -309,16 +328,17 @@ my $UID = $ARGV[2]; # Strip whitespace just in case ... $UID =~ s/\s+//g if ($UID); -if (!$UID) { -# A checksum of the config file will let us distinguish endpoints -# with different configs. -# This won't necessarily cover everything, e.g. multiple endpoints -# of the same type using the same config file but steered by an -# environment variable. However it's about the best we can do -# automatically. +if ( !$UID ) { + + # A checksum of the config file will let us distinguish endpoints + # with different configs. + # This won't necessarily cover everything, e.g. multiple endpoints + # of the same type using the same config file but steered by an + # environment variable. However it's about the best we can do + # automatically. my $check = `cksum $confile | cut -d\" \" -f 1`; chomp($check); - $UID = $SUID . "_" . $Type ."_" . $check; + $UID = $SUID . "_" . $Type . "_" . $check; } # Now start outputting LDIF lines for the Endpoint object. @@ -335,9 +355,10 @@ print "objectClass: GLUE2Endpoint\n"; # Storage Endpoints. The real thing will need to be a lot more # elaborate. -if ($Type =~ m/^org\.glite\.ce\..*?/) { +if ( $Type =~ m/^org\.glite\.ce\..*?/ ) { print "objectClass: GLUE2ComputingEndpoint\n"; -} elsif ($Type eq "SRM") { +} +elsif ( $Type eq "SRM" ) { print "objectClass: GLUE2StorageEndpoint\n"; } @@ -345,12 +366,12 @@ print "GLUE2EndpointID: $UID\n"; # Attributes are generally dealt with in the order in which they appear # in the GLUE 2 specification document, unless dependencies dictate -# otherwise. +# otherwise. # Creation time and validity are standard attributes for all objects # Times are mandated to be UTC only -my $TimeNow = strftime("%Y-%m-%dT%H:%M:%SZ", gmtime()); +my $TimeNow = strftime( "%Y-%m-%dT%H:%M:%SZ", gmtime() ); print "GLUE2EntityCreationTime: $TimeNow\n"; # Validity is hardwired above @@ -385,12 +406,12 @@ print "GLUE2EntityOtherInfo: ProfileVersion=$profileversion\n"; # Publish OS name and version if we can extract them -my $OSName=`lsb_release -i | cut -f2`; +my $OSName = `lsb_release -i | cut -f2`; chomp($OSName); if ($OSName) { print "GLUE2EntityOtherInfo: OSName=$OSName\n"; } -my $OSVersion=`lsb_release -r | cut -f2`; +my $OSVersion = `lsb_release -r | cut -f2`; chomp($OSVersion); if ($OSVersion) { print "GLUE2EntityOtherInfo: OSVersion=$OSVersion\n"; @@ -398,14 +419,14 @@ if ($OSVersion) { # Version number for EMI if it exists -if (my $ev = new FileHandle $emiversion) { +if ( my $ev = FileHandle->new($emiversion) ) { foreach (<$ev>) { - s/\s+//g; - if ($_) { - print "GLUE2EntityOtherInfo: MiddlewareName=EMI\n"; - print "GLUE2EntityOtherInfo: MiddlewareVersion=$_\n"; - last; - } + s/\s+//g; + if ($_) { + print "GLUE2EntityOtherInfo: MiddlewareName=EMI\n"; + print "GLUE2EntityOtherInfo: MiddlewareVersion=$_\n"; + last; + } } close $ev; } @@ -417,15 +438,16 @@ if (my $ev = new FileHandle $emiversion) { $Endpoint =~ s/\s+//g; trunc($Endpoint); -if (!$Endpoint) { +if ( !$Endpoint ) { $Endpoint = "http://unknown.invalid:4444/"; } print "GLUE2EndpointURL: $Endpoint\n"; foreach (@Capabilities) { -# Should be no need for validation as they will be fixed per endpoint type, -# but still strip any leading and trailing spaces + + # Should be no need for validation as they will be fixed per endpoint type, + # but still strip any leading and trailing spaces trunc($_); if ($_) { print "GLUE2EndpointCapability: $_\n"; @@ -441,18 +463,20 @@ print "GLUE2EndpointInterfaceName: $Type\n"; # and can be multi-valued (or omitted!) foreach (@Version) { -# No white space allowed here, but otherwise free-format + + # No white space allowed here, but otherwise free-format s/\s+//g; trunc($_); if ($_) { - print "GLUE2EndpointInterfaceVersion: $_\n"; + print "GLUE2EndpointInterfaceVersion: $_\n"; } } # Interface extensions are a combination of supplementary types and versions foreach (@InterfaceExtensions) { -# These are supposed to be URIs, but we won't impose any format + + # These are supposed to be URIs, but we won't impose any format trunc($_); if ($_) { print "GLUE2EndpointInterfaceExtension: $_\n"; @@ -465,12 +489,14 @@ foreach (@InterfaceExtensions) { my $wsdls = 0; foreach (@WSDL) { -# Should be a URL, so no white space allowed here + + # Should be a URL, so no white space allowed here s/\s+//g; -# Simple sanity check (no longer enforce that strings start "http") + + # Simple sanity check (no longer enforce that strings start "http") trunc($_); if ($_) { - $wsdls++; + $wsdls++; print "GLUE2EndpointWSDL: $_\n"; } } @@ -483,12 +509,14 @@ $Technology =~ s/\s+//g; if ($Technology) { print "GLUE2EndpointTechnology: $Technology\n"; -} elsif ($wsdls) { +} +elsif ($wsdls) { print "GLUE2EndpointTechnology: webservice\n"; } foreach (@Profiles) { -# Should be a URI, but no format imposed + + # Should be a URI, but no format imposed trunc($_); if ($_) { print "GLUE2EndpointSupportedProfile: $_\n"; @@ -496,9 +524,11 @@ foreach (@Profiles) { } foreach (@Semantics) { -# This is a URL, so no white space allowed here + + # This is a URL, so no white space allowed here s/\s+//g; -# Simple sanity check (no longer enforce that strings start "http") + + # Simple sanity check (no longer enforce that strings start "http") trunc($_); if ($_) { print "GLUE2EndpointSemantics: $_\n"; @@ -523,13 +553,14 @@ if ($ImplementationVersion) { print "GLUE2EndpointImplementationVersion: $ImplementationVersion\n"; } -my @QLenum = ("", "development", "testing", "pre-production", "production"); +my @QLenum = ( "", "development", "testing", "pre-production", "production" ); # The QualityLevel command should have returned an integer between 1 and 4 # Non-numeric strings should equate to 0 -if ($QualityLevel < 1 || $QualityLevel > 4) { +if ( $QualityLevel < 1 || $QualityLevel > 4 ) { print "GLUE2EndpointQualityLevel: UNDEFINEDVALUE: Level $QualityLevel\n"; -} else { +} +else { print "GLUE2EndpointQualityLevel: $QLenum[$QualityLevel]\n"; } @@ -537,11 +568,11 @@ if ($QualityLevel < 1 || $QualityLevel > 4) { # 0 = OK, 1 = Critical, 2 = Warning, 3 = Unknown, other = Other my $Statcode; -if ($Status == 0) { $Statcode = "ok" } -elsif ($Status == 1) { $Statcode = "critical" } -elsif ($Status == 2) { $Statcode = "warning" } -elsif ($Status == 3) { $Statcode = "unknown" } -else { $Statcode = "other" } +if ( $Status == 0 ) { $Statcode = "ok" } +elsif ( $Status == 1 ) { $Statcode = "critical" } +elsif ( $Status == 2 ) { $Statcode = "warning" } +elsif ( $Status == 3 ) { $Statcode = "unknown" } +else { $Statcode = "other" } print "GLUE2EndpointHealthState: $Statcode\n"; @@ -563,13 +594,14 @@ if ($Info) { print "GLUE2EndpointHealthStateInfo: $Info\n"; } -my @SSenum = ("", "closed", "draining", "queueing", "production"); +my @SSenum = ( "", "closed", "draining", "queueing", "production" ); # The ServingState command should have returned an integer between 1 and 4 # Non-numeric strings should equate to 0 -if ($ServingState < 1 || $ServingState > 4) { +if ( $ServingState < 1 || $ServingState > 4 ) { print "GLUE2EndpointServingState: UNDEFINEDVALUE: State $ServingState\n"; -} else { +} +else { print "GLUE2EndpointServingState: $SSenum[$ServingState]\n"; } @@ -589,30 +621,35 @@ $ST =~ s/\s+//g; # to indicate that the service is not running at all if ($ST) { -# Must be a positive integer - if ( !($ST =~ m/^\d+$/) ) { -# The error indicator here is the Unix epoch - $ST = 0; + + # Must be a positive integer + if ( !( $ST =~ m/^\d+$/ ) ) { + + # The error indicator here is the Unix epoch + $ST = 0; } -# We need to munge the timezone indicator to add a colon between -# the hours and minutes -# my $tz = strftime("%z", localtime($ST)); -# $tz =~ s/(\d{2})(\d{2})/$1:$2/; -# my $StartTime = strftime("%Y-%m-%dT%H:%M:%S", localtime($ST)) . $tz; -# Same thing in UTC as required by the schema - my $StartTime = strftime("%Y-%m-%dT%H:%M:%SZ", gmtime($ST)); -# No error checks as strftime should return something reasonable + + # We need to munge the timezone indicator to add a colon between + # the hours and minutes + # my $tz = strftime("%z", localtime($ST)); + # $tz =~ s/(\d{2})(\d{2})/$1:$2/; + # my $StartTime = strftime("%Y-%m-%dT%H:%M:%S", localtime($ST)) . $tz; + # Same thing in UTC as required by the schema + my $StartTime = strftime( "%Y-%m-%dT%H:%M:%SZ", gmtime($ST) ); + + # No error checks as strftime should return something reasonable print "GLUE2EndpointStartTime: $StartTime\n"; } # Host cert location is currently hard-wired my $hostcert = "/etc/grid-security/hostcert.pem"; -my $Issuer = ""; +my $Issuer = ""; my $Subject = ""; -if ( -e $hostcert) { -# This should give us the host cert issuer and subject, if any - $Issuer = `openssl x509 -issuer -noout -in $hostcert | sed 's/^[^/]*//'`; +if ( -e $hostcert ) { + + # This should give us the host cert issuer and subject, if any + $Issuer = `openssl x509 -issuer -noout -in $hostcert | sed 's/^[^/]*//'`; $Subject = `openssl x509 -subject -noout -in $hostcert | sed 's/^[^/]*//'`; } @@ -636,7 +673,8 @@ foreach (@TrustedCA) { # Downtimes are handled by the GOC DB in EGI, so not published here (yet?) -print "GLUE2EndpointDownTimeInfo: See the GOC DB for downtimes: https://goc.egi.eu/\n"; +print +"GLUE2EndpointDownTimeInfo: See the GOC DB for downtimes: https://goc.egi.eu/\n"; # Finally print the upward link to the parent Service @@ -645,49 +683,58 @@ print "GLUE2EndpointServiceForeignKey: $SUID\n"; # Print a newline to finish the object print "\n"; -# Now we deal with any Extensions to the Endpoint. +# Now we deal with any Extensions to the Endpoint. # Old-style (1.3) ServiceData entries are mapped to Extensions # by default, although in some cases an OtherInfo may be sufficient. -my %items = (); -my $ext = 0; +my %items = (); +my $ext = 0; my $keyext = ""; foreach (@Extensions) { -# Should be key=value pairs - if ( m/=/ ) { -# Split on the first =, no leading or trailing whitespace in the value, -# no whitespace at all in the key -# NB This means you can't have an = in the Key! + + # Should be key=value pairs + if (m/=/) { + + # Split on the first =, no leading or trailing whitespace in the value, + # no whitespace at all in the key + # NB This means you can't have an = in the Key! m/^(.*?)=\s*(.*)\s*$/; - my $key = $1; + my $key = $1; my $value = $2; $key =~ s/\s+//g; - trunc($key); - trunc($value); -# Don't output anything if the key is null - if (length($key) > 0) { - $ext++; -# Allow for duplicate keys (= as separator since it isn't allowed as above) - $keyext = $key . "=" . $ext; -# Value seems to be a mandatory attribute, so: - if ($value){ - $items{$keyext} = $value; - } else { - $items{$keyext} = "UNDEFINEDVALUE"; - } - }else{ - print STDERR "Extension Key has 0 length, value is: " . $value . "\n"; - } + trunc($key); + trunc($value); + + # Don't output anything if the key is null + if ( length($key) > 0 ) { + $ext++; + + # Allow for duplicate keys (= as separator since it isn't allowed as above) + $keyext = $key . "=" . $ext; + + # Value seems to be a mandatory attribute, so: + if ($value) { + $items{$keyext} = $value; + } + else { + $items{$keyext} = "UNDEFINEDVALUE"; + } + } + else { + print STDERR "Extension Key has 0 length, value is: " . $value + . "\n"; + } } } # Now print the Extension objects - the order is random but it doesn't matter my $ELID = "0"; -while ( my ($keyx, $value) = each(%items) ) { - (my $key, $ext) = split /=/, $keyx; -# Extensions only need a local ID - but note that the Key may not be unique +while ( my ( $keyx, $value ) = each(%items) ) { + ( my $key, $ext ) = split /=/, $keyx; + + # Extensions only need a local ID - but note that the Key may not be unique $ELID = $key . "_" . $ext; print "dn: GLUE2ExtensionLocalID=$ELID,GLUE2EndpointID=$UID,$bind_dn\n"; print "objectClass: GLUE2Extension\n"; @@ -756,13 +803,13 @@ my $rules = 0; foreach (@ACBR) { trunc($_); if ($_) { - $rules++; + $rules++; print "GLUE2PolicyRule: $_\n"; } } # "ALL" is a reserved word meaning that there is no authz -if ($rules == 0) { +if ( $rules == 0 ) { print "GLUE2PolicyRule: ALL\n"; } @@ -776,8 +823,9 @@ foreach (@Owner) { s/\s+//g; trunc($_); if ($_) { -# $rules++; - print "GLUE2PolicyUserDomainForeignKey: $_\n"; + + # $rules++; + print "GLUE2PolicyUserDomainForeignKey: $_\n"; } } @@ -804,23 +852,23 @@ exit 0; sub trunc { -# Truncates string attributes to a "reasonable" length, somewhat arbitrarily -# taken to be 240 chars. Excess text is replaced by the "well-known" error -# indicator 4444. Also strip leading and trailing spaces, which are unlikely -# to be useful in any attribute. Also for now translate non-ASCII characters -# to ? as the deployed schema doesn't allow them, see -# https://savannah.cern.ch/bugs/?98046 + # Truncates string attributes to a "reasonable" length, somewhat arbitrarily + # taken to be 240 chars. Excess text is replaced by the "well-known" error + # indicator 4444. Also strip leading and trailing spaces, which are unlikely + # to be useful in any attribute. Also for now translate non-ASCII characters + # to ? as the deployed schema doesn't allow them, see + # https://savannah.cern.ch/bugs/?98046 - if ($_[0]) { - $_[0] =~ s/^\s+//; - $_[0] =~ s/\s+$//; + if ( $_[0] ) { + $_[0] =~ s/^\s+//; + $_[0] =~ s/\s+$//; -# Zap any non-ASCII characters (replaced with a ?) - $_[0] =~ tr/\0-\x7f/?/c; + # Zap any non-ASCII characters (replaced with a ?) + $_[0] =~ tr/\0-\x7f/?/c; - if (length($_[0]) > 240) { - $_[0] = substr($_[0], 0, 239) . "...4444"; - } + if ( length( $_[0] ) > 240 ) { + $_[0] = substr( $_[0], 0, 239 ) . "...4444"; + } } } diff --git a/src/glite-info-glue2-multi b/src/glite-info-glue2-multi index 04eb970..5b9dd4d 100755 --- a/src/glite-info-glue2-multi +++ b/src/glite-info-glue2-multi @@ -1,6 +1,5 @@ #!/usr/bin/perl -w -# # glite-info-glue2-multi: a script to generate a GLUE 2 # Service object with multiple Endpoints # @@ -55,8 +54,9 @@ use FileHandle; my $command; # Only the first two arguments are mandatory -if (! $ARGV[1]) { - print STDERR "Usage: glite-info-glue2-multi [,[,...]] [] [] [ [[ [ ...]]]]\n"; +if ( !$ARGV[1] ) { + print STDERR +"Usage: glite-info-glue2-multi [,[,...]] [] [] [ [[ [ ...]]]]\n"; exit 1; } @@ -68,9 +68,9 @@ my @ConfigFiles = split /,/, $Config; # Simple check on the readability of the files foreach (@ConfigFiles) { - if (!(-r $_)) { - print STDERR "Error: Configuration file $_ is not readable\n"; - exit 2; + if ( !( -r $_ ) ) { + print STDERR "Error: Configuration file $_ is not readable\n"; + exit 2; } } @@ -83,19 +83,23 @@ my $SID = ""; my $Service_conf = shift @ARGV; # If it isn't openable as a file it must be an ID -if (!(-r $Service_conf)) { +if ( !( -r $Service_conf ) ) { $DID = $Service_conf; -# Try again with the next argument + + # Try again with the next argument $Service_conf = shift @ARGV; -# If it isn't openable as a file it must be an ID (is there an echo?) - if ($Service_conf && (!(-r $Service_conf))) { - $SID = $Service_conf; - $Service_conf = ""; - } else { - $SID = shift @ARGV; + + # If it isn't openable as a file it must be an ID (is there an echo?) + if ( $Service_conf && ( !( -r $Service_conf ) ) ) { + $SID = $Service_conf; + $Service_conf = ""; + } + else { + $SID = shift @ARGV; } -} else { - $SID = shift @ARGV; +} +else { + $SID = shift @ARGV; } # If anything is left they must be Endpoint IDs (NB no check on the number) @@ -111,33 +115,37 @@ $SID =~ s/\s+//g if ($SID); # Config items are commands to be executed - "echo" is a no-op my %config = ( - get_site_id => 'echo', - get_service_id => 'echo', - get_capability => 'echo', - get_type => 'echo', - get_qualitylevel => 'echo', - get_statusinfo => 'echo', - get_complexity => 'echo', - get_otherinfo => 'echo' - ); + get_site_id => 'echo', + get_service_id => 'echo', + get_capability => 'echo', + get_type => 'echo', + get_qualitylevel => 'echo', + get_statusinfo => 'echo', + get_complexity => 'echo', + get_otherinfo => 'echo' +); # Process the service config file if it exists if ($Service_conf) { - my $fh = new FileHandle $Service_conf - or die "Error: Can't open configuration file: $Service_conf\n"; + my $fh = FileHandle->($Service_conf) + or die "Error: Can't open configuration file: $Service_conf\n"; foreach (<$fh>) { -# For lines containing an = and not starting with # - if ((! m/^\#/) & (m/=/)) { -# Split on the first =, no leading or trailing whitespace in the value - m/^(.*?)=\s*(.*)\s*$/; - my $key = $1; - my $value = $2; -# No whitespace at all in the key - $key =~ s/\s+//g; -# Replace the default defined above - $config{$key} = $value; - } + + # For lines containing an = and not starting with # + if ( ( !m/^\#/ ) & (m/=/) ) { + + # Split on the first =, no leading or trailing whitespace in the value + m/^(.*?)=\s*(.*)\s*$/; + my $key = $1; + my $value = $2; + + # No whitespace at all in the key + $key =~ s/\s+//g; + + # Replace the default defined above + $config{$key} = $value; + } } } @@ -150,14 +158,15 @@ my $Type = `$command`; $Type =~ s/\s+//g; # For the DomainID an explicit argument takes precedence over the config file -if (!$DID) { +if ( !$DID ) { $command = $config{get_site_id}; - $DID = `$command`; + $DID = `$command`; $DID =~ s/\s+//g; } -if (!$DID) { -# No sensible default possible, this must be configured +if ( !$DID ) { + + # No sensible default possible, this must be configured print STDERR "Error: Site name (DomainID) not specified\n"; exit 3; } @@ -168,38 +177,44 @@ if (!$DID) { $ENV{"GLITE_INFO_SERVICE_SITE_ID"} = $DID; # Similarly for the ServiceID an explicit argument takes precedence -if (!$SID) { +if ( !$SID ) { $command = $config{get_service_id}; - $SID = `$command`; + $SID = `$command`; $SID =~ s/\s+//g; } -if (!$SID) { +if ( !$SID ) { + # This time we can construct a default, made from the host name, service type and # a checksum of the Endpoint config files my $host = `hostname -f`; chomp($host); - if (!$host) { -# If we can't get a local hostname at all we can't construct a unique ID + if ( !$host ) { + + # If we can't get a local hostname at all we can't construct a unique ID print STDERR "Error: hostname -f returned a null string\n"; exit 99; } -# We checked above that the config files are readable + + # We checked above that the config files are readable my $check = `cat @ConfigFiles | cksum | cut -d\" \" -f 1`; chomp($check); my $typeguess = $Type; - if (!$typeguess) { + if ( !$typeguess ) { + # If the Type isn't configured we assume that the first config file name follows the # standard convention with the type name embedded ... - $ConfigFiles[0] =~ m/glite-info-\w+-(.+).conf/; - $typeguess = $1; + $ConfigFiles[0] =~ m/glite-info-\w+-(.+).conf/; + $typeguess = $1; } - if (!$typeguess) { -# ... or if not it doesn't really matter, it's just cosmetic - $typeguess = "unknown"; + if ( !$typeguess ) { + + # ... or if not it doesn't really matter, it's just cosmetic + $typeguess = "unknown"; } -# Note that this may cause trouble if hostname -f does not return an fqdn, -# but I think that is normally required by other things anyway + + # Note that this may cause trouble if hostname -f does not return an fqdn, + # but I think that is normally required by other things anyway $SID = $host . "_" . $typeguess . "_" . $check; } @@ -235,12 +250,15 @@ my @endpoint_ldif = ""; my $EID; foreach (@ConfigFiles) { -# Use the next Endpoint ID if provided, otherwise it will be auto-generated + + # Use the next Endpoint ID if provided, otherwise it will be auto-generated $EID = shift @EIDs; -# Void values seem to make perl choke, so make sure it's a null string - $EID = "" if (!$EID); + + # Void values seem to make perl choke, so make sure it's a null string + $EID = "" if ( !$EID ); $EID =~ s/\s+//g; - @endpoint_ldif = (@endpoint_ldif, `glite-info-glue2-endpoint $_ $SID $EID`); + @endpoint_ldif = + ( @endpoint_ldif, `glite-info-glue2-endpoint $_ $SID $EID` ); } # Various attributes need to be collected out of the Endpoints to be @@ -257,52 +275,61 @@ my $BestQL = "UNDEFINEDVALUE"; my $QLnum; my $QLmax = 0; my %QLmap = ( - "development" => 1, - "testing" => 2, - "pre-production" => 3, - "production" => 4 - ); + "development" => 1, + "testing" => 2, + "pre-production" => 3, + "production" => 4 +); my $Cap; # Read through the LDIF and look for the relevant attributes foreach (@endpoint_ldif) { - if ( m/^GLUE2EndpointInterfaceName:/) { - ($Attr, $TypeName) = split /:/, $_, 2; - $TypeName =~ s/\s+//g; -# Record each Endpoint type (InterfaceName) in a hash - $TypeList{$TypeName} = 1; -# The first type name we hit will be the default Service Type - $FirstType = $TypeName if (!$FirstType); - } elsif ( m/^GLUE2EndpointQualityLevel:/ ) { - ($Attr, $QL) = split /:/, $_, 2; + if (m/^GLUE2EndpointInterfaceName:/) { + ( $Attr, $TypeName ) = split /:/, $_, 2; + $TypeName =~ s/\s+//g; + + # Record each Endpoint type (InterfaceName) in a hash + $TypeList{$TypeName} = 1; + + # The first type name we hit will be the default Service Type + $FirstType = $TypeName if ( !$FirstType ); + } + elsif (m/^GLUE2EndpointQualityLevel:/) { + ( $Attr, $QL ) = split /:/, $_, 2; $QL =~ s/\s+//g; -# Convert the textual QL to a number (closed enumeration) + + # Convert the textual QL to a number (closed enumeration) $QLnum = $QLmap{$QL}; -# The Service QualityLevel is the best QL of any Endpoint - if ( $QLnum > $QLmax ){ - $QLmax = $QLnum; + + # The Service QualityLevel is the best QL of any Endpoint + if ( $QLnum > $QLmax ) { + $QLmax = $QLnum; $BestQL = $QL; } - } elsif ( m/^GLUE2EndpointCapability:/ ) { - ($Attr, $Cap) = split /:/, $_, 2; - $Cap =~ s/\s+//g; -# The Service accumulates all the (distinct) Capabilities of its Endpoints - if ( !($Capabilities =~ m/,$Cap/) ) { -# Make a comma-separated list (with a leading comma) - $Capabilities = $Capabilities . "," . $Cap; - } + } + elsif (m/^GLUE2EndpointCapability:/) { + ( $Attr, $Cap ) = split /:/, $_, 2; + $Cap =~ s/\s+//g; + + # The Service accumulates all the (distinct) Capabilities of its Endpoints + if ( !( $Capabilities =~ m/,$Cap/ ) ) { + + # Make a comma-separated list (with a leading comma) + $Capabilities = $Capabilities . "," . $Cap; + } } } # If the ServiceType wasn't set in the config file just take the # InterfaceName of the first Endpoint -if (!$Type) { +if ( !$Type ) { $Type = $FirstType; } -if (!$Type) { -# This should be impossible, but ... +if ( !$Type ) { + + # This should be impossible, but ... $Type = "UNDEFINEDVALUE"; } @@ -310,14 +337,15 @@ if (!$Type) { $Type = $Type . $Capabilities; # Allow an override from the config file -if (!$QualityLevel) { +if ( !$QualityLevel ) { $QualityLevel = $BestQL; } # Allow an override from the config file -if (!$Complexity) { -# Complexity is basically the number of Endpoint types - $Complexity = scalar(keys(%TypeList)); +if ( !$Complexity ) { + + # Complexity is basically the number of Endpoint types + $Complexity = scalar( keys(%TypeList) ); } # Concatenate the QualityLevel and Complexity @@ -327,20 +355,22 @@ my $EndpointInfo = $QualityLevel . "," . $Complexity; foreach (@SI) { s/\s+//g; if ($_) { - $EndpointInfo = $EndpointInfo . "," . $_; + $EndpointInfo = $EndpointInfo . "," . $_; } } # And finally see if there are any OtherInfo strings my $OtherInfo = ""; foreach (@OI) { -# These might contain white space so we should quote them + + # These might contain white space so we should quote them $OtherInfo = $OtherInfo . '"' . $_ . '"' . " "; } # Execute the Service provider, again catching the output # (The service LDIF could just be printed directly but this seems more consistent) -my @service_ldif = `glite-info-glue2-service $DID $SID $Type $EndpointInfo $OtherInfo`; +my @service_ldif = + `glite-info-glue2-service $DID $SID $Type $EndpointInfo $OtherInfo`; # Finally just print the LDIF back to stdout diff --git a/src/glite-info-glue2-service b/src/glite-info-glue2-service index 6026301..b05172b 100755 --- a/src/glite-info-glue2-service +++ b/src/glite-info-glue2-service @@ -1,6 +1,5 @@ #!/usr/bin/perl -w -# # glite-info-glue2-service: an information provider for the Service # object, in v 2.0 of the GLUE schema # @@ -65,8 +64,9 @@ my $validity = "3600"; # Process the arguments - must be at least 4 -if (!($ARGV[3])){ - print STDERR "Usage: glite-info-glue2-service [ [] ...]\n"; +if ( !( $ARGV[3] ) ) { + print STDERR +"Usage: glite-info-glue2-service [ [] ...]\n"; exit 1; } @@ -97,7 +97,7 @@ $TypeCap =~ s/\s+//g; # NB Assumes that commas are not allowed in these attributes my @Capabilities = split /,/, $TypeCap; -my $Type = shift @Capabilities; +my $Type = shift @Capabilities; my $EndpointInfo = shift @ARGV; @@ -108,33 +108,35 @@ $EndpointInfo =~ s/\s+//g; # optional StatusInfo endpoints, comma-separated # NB Assumes that commas are not allowed in these attributes -my @Info = split /,/, $EndpointInfo; +my @Info = split /,/, $EndpointInfo; my $QualityLevel = shift @Info; -my $Complexity = shift @Info; +my $Complexity = shift @Info; -if (!$Complexity) { +if ( !$Complexity ) { $Complexity = 1; } # Split the Complexity into its three components -(my $EndpointCount, my $ShareCount, my $ResourceCount) = split /:/, $Complexity, 3; +( my $EndpointCount, my $ShareCount, my $ResourceCount ) = split /:/, + $Complexity, 3; -if (!$EndpointCount) { +if ( !$EndpointCount ) { $EndpointCount = 0; } -if (!$ShareCount) { +if ( !$ShareCount ) { $ShareCount = 0; } -if (!$ResourceCount) { +if ( !$ResourceCount ) { $ResourceCount = 0; } # Check that we still have non-null values where necessary -if (!$SiteID || !$UID || !$Type || !$QualityLevel) { - print STDERR "Usage: glite-info-glue2-service [ [] ...]\n"; +if ( !$SiteID || !$UID || !$Type || !$QualityLevel ) { + print STDERR +"Usage: glite-info-glue2-service [ [] ...]\n"; exit 2; } @@ -156,9 +158,10 @@ print "objectClass: GLUE2Service\n"; # ComputingService and StorageService. The real things will need # a lot more work. -if ($Type eq "org.glite.ce") { +if ( $Type eq "org.glite.ce" ) { print "objectClass: GLUE2ComputingService\n"; -} elsif ($Type eq "org.glite.se") { +} +elsif ( $Type eq "org.glite.se" ) { print "objectClass: GLUE2StorageService\n"; } @@ -171,7 +174,7 @@ print "GLUE2ServiceID: $UID\n"; # Creation time and validity are standard attributes for all objects # Times are mandated to be UTC only -my $TimeNow = strftime("%Y-%m-%dT%H:%M:%SZ", gmtime()); +my $TimeNow = strftime( "%Y-%m-%dT%H:%M:%SZ", gmtime() ); print "GLUE2EntityCreationTime: $TimeNow\n"; # Validity is currently hardwired above @@ -199,18 +202,20 @@ print "GLUE2EntityOtherInfo: ProfileVersion=$profileversion\n"; # Print any more OtherInfo foreach (@OtherInfo) { -# Basically just print this as it comes, but no leading or trailing white -# space and no blank lines + + # Basically just print this as it comes, but no leading or trailing white + # space and no blank lines s/^\s+//; s/\s+$//; if ($_) { - print "GLUE2EntityOtherInfo: $_\n"; + print "GLUE2EntityOtherInfo: $_\n"; } } foreach (@Capabilities) { -# Should be no need for validation as it will be fixed per service type, -# but make sure we don't emit a blank string as it isn't valid LDIF + + # Should be no need for validation as it will be fixed per service type, + # but make sure we don't emit a blank string as it isn't valid LDIF if ($_) { print "GLUE2ServiceCapability: $_\n"; } @@ -221,16 +226,18 @@ print "GLUE2ServiceType: $Type\n"; print "GLUE2ServiceQualityLevel: $QualityLevel\n"; foreach (@Info) { -# This is supposed to be a URL but we'll print it as it comes, -# but make sure we don't emit a blank string as it isn't valid LDIF + + # This is supposed to be a URL but we'll print it as it comes, + # but make sure we don't emit a blank string as it isn't valid LDIF if ($_) { - print "GLUE2ServiceStatusInfo: $_\n"; + print "GLUE2ServiceStatusInfo: $_\n"; } } # These should be integers, but just print whatever we got -print "GLUE2ServiceComplexity: endpointType=$EndpointCount, share=$ShareCount, resource=$ResourceCount\n"; +print +"GLUE2ServiceComplexity: endpointType=$EndpointCount, share=$ShareCount, resource=$ResourceCount\n"; # Upward reference to the hosting site (AdminDomain) @@ -240,7 +247,8 @@ print "GLUE2ServiceAdminDomainForeignKey: $SiteID\n"; # Other relations will point to the Service and not from it foreach (@RelatedServices) { -# Make sure we don't emit a blank string as it isn't valid LDIF + + # Make sure we don't emit a blank string as it isn't valid LDIF if ($_) { print "GLUE2ServiceServiceForeignKey: $_\n"; } diff --git a/src/glite-info-glue2-simple b/src/glite-info-glue2-simple index bf8d3f1..6216111 100755 --- a/src/glite-info-glue2-simple +++ b/src/glite-info-glue2-simple @@ -1,6 +1,5 @@ #!/usr/bin/perl -w -# # glite-info-glue2-simple: a script to generate a GLUE 2 # Service object with a single Endpoint, analogous to the existing # GLUE 1 Service provider glite-info-service @@ -55,8 +54,9 @@ my $command; # Only the first argument is mandatory -if (! $ARGV[0]) { - print STDERR "Usage: glite-info-glue2-simple [,] [ [ []]]\n"; +if ( !$ARGV[0] ) { + print STDERR +"Usage: glite-info-glue2-simple [,] [ [ []]]\n"; exit 1; } @@ -69,7 +69,7 @@ my @ConfigFiles = split /,/, $Config; my $Endpoint_conf = shift @ConfigFiles; # Simple check on the file -if (!(-r $Endpoint_conf)) { +if ( !( -r $Endpoint_conf ) ) { print STDERR "Error: Configuration file $Endpoint_conf is not readable\n"; exit 2; } @@ -94,47 +94,53 @@ $EID =~ s/\s+//g if ($EID); # Config items are commands to be executed - "echo" is a no-op my %config = ( - get_site_id => 'echo', - get_service_id => 'echo', - get_capability => 'echo', - get_type => 'echo', - get_qualitylevel => 'echo', - get_statusinfo => 'echo', - get_complexity => 'echo', - get_otherinfo => 'echo' - ); + get_site_id => 'echo', + get_service_id => 'echo', + get_capability => 'echo', + get_type => 'echo', + get_qualitylevel => 'echo', + get_statusinfo => 'echo', + get_complexity => 'echo', + get_otherinfo => 'echo' +); # Process the service config file if it exists if ($Service_conf) { - my $fh = new FileHandle $Service_conf - or die "Error: Can't open configuration file: $Service_conf\n"; + my $fh = FileHandle->new($Service_conf) + or die "Error: Can't open configuration file: $Service_conf\n"; foreach (<$fh>) { - if ((! m/^\#/) & (m/=/)){ -# For lines containing an = and not starting with # - m/^(.*?)=\s*(.*)\s*$/; -# Split on the first =, no leading or trailing whitespace in the value - my $key = $1; - my $value = $2; -# No whitespace at all in the key - $key =~ s/\s+//g; - $config{$key} = $value; - } + if ( ( !m/^\#/ ) & (m/=/) ) { + + # For lines containing an = and not starting with # + m/^(.*?)=\s*(.*)\s*$/; + + # Split on the first =, no leading or trailing whitespace in the value + my $key = $1; + my $value = $2; + + # No whitespace at all in the key + $key =~ s/\s+//g; + $config{$key} = $value; + } } } # Now sort out the arguments -if (!$DID) { -# An explicit argument takes precedence over the config file +if ( !$DID ) { + + # An explicit argument takes precedence over the config file $command = $config{get_site_id}; - $DID = `$command`; -# No whitespace in IDs + $DID = `$command`; + + # No whitespace in IDs $DID =~ s/\s+//g; } -if (!$DID) { -# No default possible +if ( !$DID ) { + + # No default possible print STDERR "Error: Site name (DomainID) not specified\n"; exit 3; } @@ -144,41 +150,45 @@ if (!$DID) { $ENV{"GLITE_INFO_SERVICE_SITE_ID"} = $DID; +if ( !$SID ) { -if (!$SID) { -# Again an explicit argument takes precedence + # Again an explicit argument takes precedence $command = $config{get_service_id}; - $SID = `$command`; + $SID = `$command`; $SID =~ s/\s+//g; } -if (!$SID) { +if ( !$SID ) { my $host = `hostname -f`; chomp($host); - if (!$host) { -# If we can't get a local hostname at all we can't construct a unique ID + if ( !$host ) { + + # If we can't get a local hostname at all we can't construct a unique ID print STDERR "Error: hostname -f returned a null string\n"; exit 99; } -# This time we can construct a default, made from the host name and -# a checksum of the config file. Unfortunately this can't include the -# service type because we don't know it yet ... + + # This time we can construct a default, made from the host name and + # a checksum of the config file. Unfortunately this can't include the + # service type because we don't know it yet ... my $check = `cksum $Endpoint_conf | cut -d\" \" -f 1`; chomp($check); -# ... but we can cheat by assuming that the config file name follows the -# standard convention ... + + # ... but we can cheat by assuming that the config file name follows the + # standard convention ... $Endpoint_conf =~ m/glite-info-\w+-(.+).conf/; my $typeguess = $1; - if (!$typeguess) { - $typeguess = "unknown"; + if ( !$typeguess ) { + $typeguess = "unknown"; } -# Note that this may cause trouble if hostname -f does not return an fqdn, -# but I think that is normally required by other things anyway + + # Note that this may cause trouble if hostname -f does not return an fqdn, + # but I think that is normally required by other things anyway $SID = $host . "_" . $typeguess . "_" . $check; } # No default needed here, the provider constructs it -if (!$EID) { +if ( !$EID ) { $EID = ""; } @@ -227,26 +237,33 @@ my $QL = "UNDEFINEDVALUE"; my $Cap; foreach (@endpoint_ldif) { -# Read through the LDIF and look for the relevant attributes - if ( m/^GLUE2EndpointInterfaceName:/ && !$Type) { - ($Attr, $Type) = split /:/, $_, 2; -# For simple services we'll set the ServiceType the same as the endpoint type - $Type =~ s/\s+//g; - } elsif ( m/^GLUE2EndpointQualityLevel:/ ) { -# The Service QualityLevel is the best QL of any Endpoint - we only -# have one here so it must be the best ... - ($Attr, $QL) = split /:/, $_, 2; + + # Read through the LDIF and look for the relevant attributes + if ( m/^GLUE2EndpointInterfaceName:/ && !$Type ) { + ( $Attr, $Type ) = split /:/, $_, 2; + + # For simple services we'll set the ServiceType the same as the endpoint type + $Type =~ s/\s+//g; + } + elsif (m/^GLUE2EndpointQualityLevel:/) { + + # The Service QualityLevel is the best QL of any Endpoint - we only + # have one here so it must be the best ... + ( $Attr, $QL ) = split /:/, $_, 2; $QL =~ s/\s+//g; - } elsif ( m/^GLUE2EndpointCapability:/ ) { -# The Service accumulates all the Capabilities of its Endpoints - ($Attr, $Cap) = split /:/, $_, 2; - $Cap =~ s/\s+//g; -# Make a comma-separated list (with a leading comma) - $Capabilities = $Capabilities . "," . $Cap; + } + elsif (m/^GLUE2EndpointCapability:/) { + + # The Service accumulates all the Capabilities of its Endpoints + ( $Attr, $Cap ) = split /:/, $_, 2; + $Cap =~ s/\s+//g; + + # Make a comma-separated list (with a leading comma) + $Capabilities = $Capabilities . "," . $Cap; } } -if (!$Type) { +if ( !$Type ) { $Type = "UNDEFINEDVALUE"; } @@ -254,11 +271,11 @@ if (!$Type) { $Type = $Type . $Capabilities; # Allow overrides from the config file -if (!$QualityLevel) { +if ( !$QualityLevel ) { $QualityLevel = $QL; } -if (!$Complexity) { +if ( !$Complexity ) { $Complexity = 1; } @@ -270,19 +287,21 @@ my $EndpointInfo = $QualityLevel . "," . $Complexity; foreach (@SI) { s/\s+//g; if ($_) { - $EndpointInfo = $EndpointInfo . "," . $_; + $EndpointInfo = $EndpointInfo . "," . $_; } } # And finally see if there are any OtherInfo strings my $OtherInfo = ""; foreach (@OI) { -# These might contain white space so we should quote them + + # These might contain white space so we should quote them $OtherInfo = $OtherInfo . '"' . $_ . '"' . " "; } # Execute the Service provider, again catching the output -my @service_ldif = `glite-info-glue2-service $DID $SID $Type $EndpointInfo $OtherInfo`; +my @service_ldif = + `glite-info-glue2-service $DID $SID $Type $EndpointInfo $OtherInfo`; # Finally just print the LDIF back to stdout diff --git a/src/glite-info-glue2-voms b/src/glite-info-glue2-voms index 7f6b139..f111298 100755 --- a/src/glite-info-glue2-voms +++ b/src/glite-info-glue2-voms @@ -1,6 +1,5 @@ #!/usr/bin/perl -w -# # glite-info-glue2-voms: a VOMS-specific GLUE 2 information provider. # This produces a single Service object for a VOMS server, with one # Endpoint per VO for each of voms and voms-admin (if configured). @@ -45,13 +44,14 @@ use strict; # Location of the VOMS config files -my $vomsdir = "/etc/voms"; +my $vomsdir = "/etc/voms"; my $vomsadmindir = "/etc/voms-admin"; # Two arguments are mandatory -if (! $ARGV[1]) { - print STDERR "Usage: glite-info-glue2-voms [,] []\n"; +if ( !$ARGV[1] ) { + print STDERR +"Usage: glite-info-glue2-voms [,] []\n"; exit 1; } @@ -67,14 +67,15 @@ my $vomsconf = shift @ConfigFiles; my $vomsadminconf = shift @ConfigFiles; # Simple check on the files -if (!(-r $vomsconf)) { +if ( !( -r $vomsconf ) ) { print STDERR "Error: Configuration file $vomsconf is not readable\n"; exit 2; } if ($vomsadminconf) { - if (!(-r $vomsadminconf)) { - print STDERR "Error: Configuration file $vomsadminconf is not readable\n"; - exit 3; + if ( !( -r $vomsadminconf ) ) { + print STDERR + "Error: Configuration file $vomsadminconf is not readable\n"; + exit 3; } } @@ -88,28 +89,32 @@ my $SID = $ARGV[2]; $DID =~ s/\s+//g; $SID =~ s/\s+//g if ($SID); -if (!$DID) { -# No default possible +if ( !$DID ) { + + # No default possible print STDERR "Error: Site name (DomainID) not specified\n"; exit 4; } -if (!$SID) { -# We construct a default, made from the host name, type and -# a checksum of the voms config file (the latter not really needed -# since we can't have more than one VOMS server per node, but we may -# as well be consistent). +if ( !$SID ) { + + # We construct a default, made from the host name, type and + # a checksum of the voms config file (the latter not really needed + # since we can't have more than one VOMS server per node, but we may + # as well be consistent). my $host = `hostname -f`; chomp($host); - if (!$host) { -# If we can't get a local hostname at all we can't construct a unique ID + if ( !$host ) { + + # If we can't get a local hostname at all we can't construct a unique ID print STDERR "Error: hostname -f returned a null string\n"; exit 99; } my $check = `cksum $vomsconf | cut -d\" \" -f 1`; chomp($check); -# Note that this may cause trouble if hostname -f does not return an fqdn, -# but I think that is normally required by other things anyway + + # Note that this may cause trouble if hostname -f does not return an fqdn, + # but I think that is normally required by other things anyway $SID = $host . "_VOMS_" . $check; } @@ -142,14 +147,18 @@ my $Complexity = 0; foreach (@volist) { chomp; -# Check that there is a config file for the VO + + # Check that there is a config file for the VO if ( -e "$vomsdir/$_/voms.conf" ) { - $Complexity = 1; -# Set a variable to transmit the VO name to the provider scripts - $ENV{"GLITE_INFO_SERVICE_VO"} = $_; -# Run the Endpoint info provider, catching the LDIF in a list, with the VO -# name appended to the EndpointID - push @endpoint_ldif, `glite-info-glue2-endpoint $vomsconf $SID ${VEID}_$_`; + $Complexity = 1; + + # Set a variable to transmit the VO name to the provider scripts + $ENV{"GLITE_INFO_SERVICE_VO"} = $_; + + # Run the Endpoint info provider, catching the LDIF in a list, with the VO + # name appended to the EndpointID + push @endpoint_ldif, + `glite-info-glue2-endpoint $vomsconf $SID ${VEID}_$_`; } } @@ -157,13 +166,15 @@ foreach (@volist) { if ($vomsadminconf) { foreach (@volist) { - chomp; -# Check that there is a config file and voms-admin directory for the VO - if ( -e "$vomsdir/$_/voms.conf" && -d "$vomsadmindir/$_") { - $Complexity = 2; - $ENV{"GLITE_INFO_SERVICE_VO"} = $_; - push @endpoint_ldif, `glite-info-glue2-endpoint $vomsadminconf $SID ${VAEID}_$_`; - } + chomp; + + # Check that there is a config file and voms-admin directory for the VO + if ( -e "$vomsdir/$_/voms.conf" && -d "$vomsadmindir/$_" ) { + $Complexity = 2; + $ENV{"GLITE_INFO_SERVICE_VO"} = $_; + push @endpoint_ldif, + `glite-info-glue2-endpoint $vomsadminconf $SID ${VAEID}_$_`; + } } } @@ -174,39 +185,45 @@ my $Attr; my $QL; my $QLnum; -my $QLmax = 0; +my $QLmax = 0; my $QualityLevel = "UNDEFINEDVALUE"; my %QLmap = ( - "development" => 1, - "testing" => 2, - "pre-production" => 3, - "production" => 4 - ); + "development" => 1, + "testing" => 2, + "pre-production" => 3, + "production" => 4 +); my $Cap; my $Capabilities = ""; foreach (@endpoint_ldif) { -# Read through the LDIF and look for the relevant attributes - if ( m/^GLUE2EndpointQualityLevel:/ ) { - ($Attr, $QL) = split /:/, $_, 2; + + # Read through the LDIF and look for the relevant attributes + if (m/^GLUE2EndpointQualityLevel:/) { + ( $Attr, $QL ) = split /:/, $_, 2; $QL =~ s/\s+//g; -# Convert the textual QL to a number - $QLnum = $QLmap{$QL}; -# The Service QualityLevel is the best QL of any Endpoint - if ( $QLnum > $QLmax ){ - $QLmax = $QLnum; - $QualityLevel = $QL; - } - } elsif ( m/^GLUE2EndpointCapability:/ ) { - ($Attr, $Cap) = split /:/, $_, 2; - $Cap =~ s/\s+//g; -# The Service accumulates all the (distinct) Capabilities of its Endpoints - if ( !($Capabilities =~ m/,$Cap/) ) { -# Make a comma-separated list (with a leading comma) - $Capabilities = $Capabilities . "," . $Cap; - } + + # Convert the textual QL to a number + $QLnum = $QLmap{$QL}; + + # The Service QualityLevel is the best QL of any Endpoint + if ( $QLnum > $QLmax ) { + $QLmax = $QLnum; + $QualityLevel = $QL; + } + } + elsif (m/^GLUE2EndpointCapability:/) { + ( $Attr, $Cap ) = split /:/, $_, 2; + $Cap =~ s/\s+//g; + + # The Service accumulates all the (distinct) Capabilities of its Endpoints + if ( !( $Capabilities =~ m/,$Cap/ ) ) { + + # Make a comma-separated list (with a leading comma) + $Capabilities = $Capabilities . "," . $Cap; + } } } diff --git a/src/glite-info-service b/src/glite-info-service index 8df6e47..bdfd0fb 100755 --- a/src/glite-info-service +++ b/src/glite-info-service @@ -31,20 +31,20 @@ # automatically constructed) # # -# Copyright (c) Members of the EGEE Collaboration. 2007-2010. +# Copyright (c) Members of the EGEE Collaboration. 2007-2010. # See http://www.eu-egee.org/partners/ for details on the copyright # holders. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and # limitations under the License. # @@ -70,66 +70,75 @@ my $SiteID = $ARGV[1]; # Read in the configuration file (first argument) my %config = ( -# New attribute for the Site ID - predefining as "echo" makes it optional - get_site_id => 'echo', - init => '', - service_type => '', - get_version => '', - get_endpoint => '', - get_status => '', - WSDL_URL => '', - semantics_URL => '', - get_starttime => '', - get_owner => '', - get_acbr => '', - get_data => '', - get_services => '', - ); - -if ($ARGV[0]){ + + # New attribute for the Site ID - predefining as "echo" makes it optional + get_site_id => 'echo', + init => '', + service_type => '', + get_version => '', + get_endpoint => '', + get_status => '', + WSDL_URL => '', + semantics_URL => '', + get_starttime => '', + get_owner => '', + get_acbr => '', + get_data => '', + get_services => '', +); + +if ( $ARGV[0] ) { $confile = $ARGV[0]; - my $fh = new FileHandle $confile - or die "Error: Can't open configuration file: $ARGV[0]\n"; - foreach (<$fh>){ - if ((! m/^\#/) & (m/=/)){ -# For lines containing an = and not starting with # + my $fh = FileHandle->new($confile) + or die "Error: Can't open configuration file: $ARGV[0]\n"; + foreach (<$fh>) { + if ( ( !m/^\#/ ) & (m/=/) ) { + + # For lines containing an = and not starting with # m/^(.*?)=\s*(.*)\s*$/; -# Split on the first =, no leading or trailing whitespace in the value - my $key=$1; - my $value=$2; - $key=~s/\s+//g; - $config{$key}=$value; + + # Split on the first =, no leading or trailing whitespace in the value + my $key = $1; + my $value = $2; + $key =~ s/\s+//g; + $config{$key} = $value; } } -}else{ - print STDERR "Usage: glite-info-service [ []]\n"; +} +else { + print STDERR + "Usage: glite-info-service [ []]\n"; exit 1; } # Check that all configuration items are set my $missing = 0; -while ( my ($key, $value) = each(%config) ) { - if ( ! $config{$key} ){ +while ( my ( $key, $value ) = each(%config) ) { + if ( !$config{$key} ) { print STDERR "Error: configuration parameter $key not set\n"; $missing += 1; } } -if ( $missing ){ - print STDERR "Error: $missing configuration parameter(s) not set in file $confile\n"; +if ($missing) { + print STDERR + "Error: $missing configuration parameter(s) not set in file $confile\n"; exit 2; } -if (!$SiteID) { -# An explicit argument takes precedence over the config file +if ( !$SiteID ) { + + # An explicit argument takes precedence over the config file $command = $config{get_site_id}; - $SiteID = `$command`; -# No whitespace in IDs + $SiteID = `$command`; + + # No whitespace in IDs $SiteID =~ s/\s+//g; } -if (!$SiteID) { -# It must be defined one way or the other +if ( !$SiteID ) { + + # It must be defined one way or the other print STDERR "Error: Site name (GlueSiteUniqueID) not specified\n"; exit 3; } @@ -151,24 +160,26 @@ $ENV{"GLITE_INFO_SERVICE_SITE_ID"} = $SiteID; $command = $config{init}; my @init_result = `$command`; -my $init_rc = $? >> 8; -if ( $init_rc ){ +my $init_rc = $? >> 8; +if ($init_rc) { print STDERR "Error: init command $command failed\n"; print STDERR "@init_result\n"; exit $init_rc; } foreach (@init_result) { -# Should be key=value pairs - if ( m/=/ ){ + + # Should be key=value pairs + if (m/=/) { m/^(.*?)=\s*(.*)\s*$/; -# Split on the first =, no leading or trailing whitespace in the value - my $key=$1; - my $value=$2; - $key=~s/\s+//g; - if ($key) { - $ENV{$key} = $value; - } + + # Split on the first =, no leading or trailing whitespace in the value + my $key = $1; + my $value = $2; + $key =~ s/\s+//g; + if ($key) { + $ENV{$key} = $value; + } } } @@ -179,7 +190,7 @@ $command = $config{get_endpoint}; my $Endpoint = `$command`; $command = $config{get_status}; -my $Info = `$command`; +my $Info = `$command`; my $Status = $? >> 8; $command = $config{get_starttime}; @@ -209,25 +220,28 @@ my $Type = $config{service_type}; # used hostname_vo_type; the YAIM scheme is something like hostname:port. # Neither is sufficient, e.g. Type SRM may have two endpoints on the same # port for SRM v1 and SRM v2. However the endpoint is also not necessarily -# enough (it's not obvious that all published services have endpoints). +# enough (it's not obvious that all published services have endpoints). # Also there is a need to watch out for invalid characters as # the UniqueID is used to form the DN. The solution chosen is to append a # checksum of the config file by default. However, there may be a need to # preserve a persistent UniqueID in some cases, hence the entire UniqueID # can be passed as an optional third argument. -if ($ARGV[2]) { +if ( $ARGV[2] ) { $UID = $ARGV[2]; -} else { - if (!$host) { -# If we can't get a local hostname at all we can't construct a unique ID - print STDERR "Error: hostname -f returned a null string\n"; - exit 99; +} +else { + if ( !$host ) { + + # If we can't get a local hostname at all we can't construct a unique ID + print STDERR "Error: hostname -f returned a null string\n"; + exit 99; } my $check = `cksum $confile | cut -d\" \" -f 1`; chomp($check); -# Note that this may cause trouble if hostname -f does not return an fqdn, -# but I think that is normally required by other things anyway + + # Note that this may cause trouble if hostname -f does not return an fqdn, + # but I think that is normally required by other things anyway $UID = $host . "_" . $Type . "_" . $check; } @@ -270,14 +284,17 @@ $Version =~ s/\s+//g; my $minor; my $patch; my $bad; -(undef, $minor, $patch, $bad) = split /\./, $Version; -if ( defined($bad) || (length($Version) > 16) || (length($Version) == 0) ) { +( undef, $minor, $patch, $bad ) = split /\./, $Version; +if ( defined($bad) || ( length($Version) > 16 ) || ( length($Version) == 0 ) ) { print "GlueServiceVersion: 4.4.4.4\n"; -} elsif ( ! defined($minor) ) { +} +elsif ( !defined($minor) ) { print "GlueServiceVersion: $Version.0.0\n"; -} elsif ( ! defined($patch) ) { +} +elsif ( !defined($patch) ) { print "GlueServiceVersion: $Version.0\n"; -} else { +} +else { print "GlueServiceVersion: $Version\n"; } @@ -288,8 +305,8 @@ if ( defined($bad) || (length($Version) > 16) || (length($Version) == 0) ) { $Endpoint =~ s/\s+//g; # Sanity check on the length -if (length($Endpoint) > 240) { - $Endpoint = substr($Endpoint, 0, 239) . "4444"; +if ( length($Endpoint) > 240 ) { + $Endpoint = substr( $Endpoint, 0, 239 ) . "4444"; } if ($Endpoint) { @@ -300,11 +317,11 @@ if ($Endpoint) { # 0 = OK, 1 = Critical, 2 = Warning, 3 = Unknown, other = Other my $Statcode; -if ($Status == 0) { $Statcode = "OK" } -elsif ($Status == 1) { $Statcode = "Critical" } -elsif ($Status == 2) { $Statcode = "Warning" } -elsif ($Status == 3) { $Statcode = "Unknown" } -else { $Statcode = "Other" } +if ( $Status == 0 ) { $Statcode = "OK" } +elsif ( $Status == 1 ) { $Statcode = "Critical" } +elsif ( $Status == 2 ) { $Statcode = "Warning" } +elsif ( $Status == 3 ) { $Statcode = "Unknown" } +else { $Statcode = "Other" } print "GlueServiceStatus: $Statcode\n"; @@ -332,12 +349,12 @@ $Info =~ tr/\0-\x7f/?/c; $Info =~ s/\(pid\s.*?\)\s*//ig; # Truncate if necessary -if (length($Info) > 240) { - $Info = substr($Info, 0, 239) . " ..."; +if ( length($Info) > 240 ) { + $Info = substr( $Info, 0, 239 ) . " ..."; } # Too short -if (length($Info) < 2) { +if ( length($Info) < 2 ) { $Info = "??"; } @@ -350,13 +367,13 @@ print "GlueServiceStatusInfo: $Info\n"; my $WSDL = $config{WSDL_URL}; $WSDL =~ s/\s+//g; -if ($WSDL =~ m/^http/) { +if ( $WSDL =~ m/^http/ ) { print "GlueServiceWSDL: $WSDL\n"; } my $Semantics = $config{semantics_URL}; $Semantics =~ s/\s+//g; -if ($Semantics =~ m/^http/) { +if ( $Semantics =~ m/^http/ ) { print "GlueServiceSemantics: $Semantics\n"; } @@ -369,15 +386,15 @@ if ($Semantics =~ m/^http/) { # No white space, should just be a number # The error indicator here is the Unix epoch $ST =~ s/\s+//g; -if ( !($ST =~ m/^\d+$/) ) { +if ( !( $ST =~ m/^\d+$/ ) ) { $ST = 0; } # We need to munge the timezone indicator to add a colon between # the hours and minutes -my $tz = strftime("%z", localtime($ST)); +my $tz = strftime( "%z", localtime($ST) ); $tz =~ s/(\d{2})(\d{2})/$1:$2/; -my $StartTime = strftime("%Y-%m-%dT%H:%M:%S", localtime($ST)) . $tz; +my $StartTime = strftime( "%Y-%m-%dT%H:%M:%S", localtime($ST) ) . $tz; # No error checks as strftime should return something reasonable print "GlueServiceStartTime: $StartTime\n"; @@ -391,11 +408,11 @@ print "GlueServiceStartTime: $StartTime\n"; foreach (@Owner) { s/^\s+//; s/\s+$//; - if (length > 50) { - $_ = substr($_, 0, 45) . "4444"; + if ( length > 50 ) { + $_ = substr( $_, 0, 45 ) . "4444"; } if ($_) { - print "GlueServiceOwner: $_\n"; + print "GlueServiceOwner: $_\n"; } } @@ -408,11 +425,11 @@ foreach (@Owner) { foreach (@ACBR) { s/^\s+//; s/\s+$//; - if (length > 240) { - $_ = substr($_, 0, 239) . "4444"; + if ( length > 240 ) { + $_ = substr( $_, 0, 239 ) . "4444"; } if ($_) { - print "GlueServiceAccessControlBaseRule: $_\n"; + print "GlueServiceAccessControlBaseRule: $_\n"; } } @@ -422,11 +439,11 @@ foreach (@ACBR) { foreach (@ACBR) { s/^\s+//; s/\s+$//; - if (length > 240) { - $_ = substr($_, 0, 239) . "4444"; + if ( length > 240 ) { + $_ = substr( $_, 0, 239 ) . "4444"; } if (m/^VO:/) { - s/^VO://; + s/^VO://; print "GlueServiceAccessControlRule: $_\n"; } } @@ -439,8 +456,8 @@ foreach (@ACBR) { foreach (@RelatedServices) { s/\s+//g; - if (length > 240) { - $_ = substr($_, 0, 239) . "4444"; + if ( length > 240 ) { + $_ = substr( $_, 0, 239 ) . "4444"; } if ($_) { print "GlueForeignKey: GlueServiceUniqueID=$_\n"; @@ -469,43 +486,50 @@ $items{"glite-info-service_version"} = $gis_version; $items{"glite-info-service_hostname"} = $host; foreach (@ServiceData) { -# Should be key=value pairs - if ( m/=/ ){ - m/^(.*?)=\s*(.*)\s*$/; -# Split on the first =, no leading or trailing whitespace in the value - my $key=$1; - my $value=$2; - $key=~s/\s+//g; -# Just in case, zap any non-ASCII characters - $value =~ tr/\0-\x7f/?/c; -# R-GMA has varchar(100) -# R-GMA is no longer relevant! - if (length($key) > 240) { - $key = substr($key, 0, 239) . "4444"; - } - if (length($value) > 240) { - $value = substr($value, 0, 239) . "4444"; + + # Should be key=value pairs + if (m/=/) { + m/^(.*?)=\s*(.*)\s*$/; + + # Split on the first =, no leading or trailing whitespace in the value + my $key = $1; + my $value = $2; + $key =~ s/\s+//g; + + # Just in case, zap any non-ASCII characters + $value =~ tr/\0-\x7f/?/c; + + # R-GMA has varchar(100) + # R-GMA is no longer relevant! + if ( length($key) > 240 ) { + $key = substr( $key, 0, 239 ) . "4444"; + } + if ( length($value) > 240 ) { + $value = substr( $value, 0, 239 ) . "4444"; + } + + # Don't output anything if the key is null + if ( length($key) > 0 ) { + $items{$key} = $value; + } + else { + print STDERR "ServiceDataKey has 0 length, value is: " . $value + . "\n"; } -# Don't output anything if the key is null - if (length($key) > 0) { - $items{$key} = $value; - }else{ - print STDERR "ServiceDataKey has 0 length, value is: " . $value . "\n"; - } } } # Now print the objects - the order is random but it doesn't matter -while ( my ($key, $value) = each(%items) ) { +while ( my ( $key, $value ) = each(%items) ) { print "dn: GlueServiceDataKey=$key,GlueServiceUniqueID=$UID,$bind_dn\n"; print "objectClass: GlueTop\n"; print "objectClass: GlueServiceData\n"; print "objectClass: GlueKey\n"; print "objectClass: GlueSchemaVersion\n"; print "GlueServiceDataKey: $key\n"; - if (length($value) > 0) { - print "GlueServiceDataValue: $value\n"; + if ( length($value) > 0 ) { + print "GlueServiceDataValue: $value\n"; } print "GlueChunkKey: GlueServiceUniqueID=$UID\n"; print "GlueSchemaVersionMajor: 1\n"; diff --git a/src/glite-info-service-amga b/src/glite-info-service-amga index 23879f9..4cfe9b9 100755 --- a/src/glite-info-service-amga +++ b/src/glite-info-service-amga @@ -7,18 +7,16 @@ AMGA_CONF=${AMGA_CONF:-/etc/amgad.config} -AMGA_HOST=${AMGA_HOST:-`hostname -f`} +AMGA_HOST=${AMGA_HOST:-$(hostname -f)} -AMGA_PORT=`grep -m 1 ^Port $AMGA_CONF | cut -d= -f2` +AMGA_PORT=$(grep -m 1 ^Port "$AMGA_CONF" | cut -d= -f2) AMGA_PORT=${AMGA_PORT:-8822} # Write to stdout - will be imported by the info provider -echo AMGA_HOST=$AMGA_HOST -echo AMGA_PORT=$AMGA_PORT -echo AMGA_CONF=$AMGA_CONF +echo AMGA_HOST="$AMGA_HOST" +echo AMGA_PORT="$AMGA_PORT" +echo AMGA_CONF="$AMGA_CONF" echo AMGA_PID_FILE=/var/lock/subsys/amgad - - diff --git a/src/glite-info-service-argus b/src/glite-info-service-argus index 08fa677..b0d3f5e 100755 --- a/src/glite-info-service-argus +++ b/src/glite-info-service-argus @@ -4,23 +4,16 @@ # These can be overridden by external definitions of the variables, # e.g. if the advertised host name should be an alias - -ARGUS_HOST=${ARGUS_HOST:-`hostname -f`} - +ARGUS_HOST=${ARGUS_HOST:-$(hostname -f)} ARGUS_PAP_PORT=${ARGUS_PAP_PORT:-8150} ARGUS_PDP_PORT=${ARGUS_PDP_PORT:-8152} ARGUS_PEP_PORT=${ARGUS_PEP_PORT:-8154} # Write to stdout - will be imported by the info provider - -echo ARGUS_HOST=$ARGUS_HOST - -echo ARGUS_PAP_PORT=$ARGUS_PAP_PORT -echo ARGUS_PDP_PORT=$ARGUS_PDP_PORT -echo ARGUS_PEP_PORT=$ARGUS_PEP_PORT - +echo ARGUS_HOST="$ARGUS_HOST" +echo ARGUS_PAP_PORT="$ARGUS_PAP_PORT" +echo ARGUS_PDP_PORT="$ARGUS_PDP_PORT" +echo ARGUS_PEP_PORT="$ARGUS_PEP_PORT" echo ARGUS_PAP_PID_FILE=/var/run/argus-pap.pid echo ARGUS_PDP_PID_FILE=/var/run/argus-pdp.pid echo ARGUS_PEP_PID_FILE=/var/run/argus-pepd.pid - - diff --git a/src/glite-info-service-bdii b/src/glite-info-service-bdii index 802dc41..9534743 100755 --- a/src/glite-info-service-bdii +++ b/src/glite-info-service-bdii @@ -6,38 +6,31 @@ # The first two can be overridden by external definitions of the variables, # e.g. if the advertised host name should be an alias - # BDII_CONF=${BDII_CONF:-/opt/bdii/etc/bdii.conf} BDII_CONF=${BDII_CONF:-/etc/bdii/bdii.conf} - -BDII_HOST=${BDII_HOST:-`hostname -f`} +BDII_HOST=${BDII_HOST:-$(hostname -f)} # Default values - normally overridden by bdii.conf - -#BDII_PORT_READ=2170 +# BDII_PORT_READ=2170 BDII_PORT=2170 BDII_BIND=o=grid -#BDII_DIR=/opt/bdii +# BDII_DIR=/opt/bdii BDII_DIR=/usr BDII_UPDATE_LDIF="http://grid-monitoring.cern.ch/myegi/sam-pi/status_of_service_in_profile?vo_name=cms&profile_name=CMS_BLACKLIST&output=xml" - -#BDII_PID_FILE=${BDII_PID_FILE:-/var/run/bdii-update.pid} +# BDII_PID_FILE=${BDII_PID_FILE:-/var/run/bdii-update.pid} BDII_PID_FILE=${BDII_PID_FILE:-/var/run/bdii/bdii-update.pid} # NB The bdii.conf file is normally only readable by the bdii user, # but that should be OK when this is run by the info provider - if [ -r "$BDII_CONF" ]; then - . "$BDII_CONF" + . "$BDII_CONF" fi # Write to stdout - will be imported by the info provider - -#echo BDII_PORT_READ=$BDII_PORT_READ -echo BDII_PORT_READ=$BDII_PORT -echo BDII_BIND=$BDII_BIND -echo BDII_DIR=$BDII_DIR -echo BDII_UPDATE_LDIF=$BDII_UPDATE_LDIF -echo BDII_HOST=$BDII_HOST -echo BDII_PID_FILE=$BDII_PID_FILE - +# echo BDII_PORT_READ=$BDII_PORT_READ +echo BDII_PORT_READ="$BDII_PORT" +echo BDII_BIND="$BDII_BIND" +echo BDII_DIR="$BDII_DIR" +echo BDII_UPDATE_LDIF="$BDII_UPDATE_LDIF" +echo BDII_HOST="$BDII_HOST" +echo BDII_PID_FILE="$BDII_PID_FILE" diff --git a/src/glite-info-service-cream b/src/glite-info-service-cream index a9c794f..5a132a7 100755 --- a/src/glite-info-service-cream +++ b/src/glite-info-service-cream @@ -7,15 +7,12 @@ # Host and port can be overridden by setting environment variables in the # wrapper script - CREAM_PORT=${CREAM_PORT:-8443} -CREAM_HOST=${CREAM_HOST:-`hostname -f`} +CREAM_HOST=${CREAM_HOST:-$(hostname -f)} CREAM_PID_FILE=${CREAM_PID_FILE:-/var/run/tomcat5.pid} # Write to stdout - will be imported by the info provider - -echo CREAM_PORT=$CREAM_PORT -echo CREAM_HOST=$CREAM_HOST -echo CREAM_PID_FILE=$CREAM_PID_FILE - +echo CREAM_PORT="$CREAM_PORT" +echo CREAM_HOST="$CREAM_HOST" +echo CREAM_PID_FILE="$CREAM_PID_FILE" diff --git a/src/glite-info-service-dcache b/src/glite-info-service-dcache index ea65e28..ad17543 100755 --- a/src/glite-info-service-dcache +++ b/src/glite-info-service-dcache @@ -6,52 +6,52 @@ # Second argument is v1/v2 case "$1" in - init) +init) - dir=${DCACHE_DIR:-/opt/d-cache} + dir=${DCACHE_DIR:-/opt/d-cache} - host=${DCACHE_HOST:-`grep ^ADMIN_NODE $dir/etc/node_config | cut -d= -f2`} - host=${host:-`grep ^srmDatabaseHost $dir/config/dCacheSetup | cut -d= -f2`} - host=${host:-`hostname -f`} + host=${DCACHE_HOST:-$(grep ^ADMIN_NODE "$dir/etc/node_config" | cut -d= -f2)} + host=${host:-$(grep ^srmDatabaseHost "$dir/config/dCacheSetup" | cut -d= -f2)} + host=${host:-$(hostname -f)} - port=`grep ^srmPort $dir/config/dCacheSetup | cut -d= -f2` - port=${port:-8443} + port=$(grep ^srmPort "$dir/config/dCacheSetup" | cut -d= -f2) + port=${port:-8443} - case "$2" in + case "$2" in v1) - version=1.1.0 - ;; + version=1.1.0 + ;; v2) - version=2.2.0 - ;; + version=2.2.0 + ;; *) - echo "Usage: glite-info-service-dcache " - echo "Second argument must be v1 or v2" - exit 2 - ;; - esac + echo "Usage: glite-info-service-dcache " + echo "Second argument must be v1 or v2" + exit 2 + ;; + esac - echo GLITE_INFO_SERVICE_ENDPOINT=httpg://$host:$port/srm/manager$2 - echo GLITE_INFO_SERVICE_VERSION=$version - echo DCACHE_PID_FILE=$dir/config/lastPid.dCache + echo GLITE_INFO_SERVICE_ENDPOINT="httpg://$host:$port/srm/manager$2" + echo GLITE_INFO_SERVICE_VERSION="$version" + echo DCACHE_PID_FILE="$dir/config/lastPid.dCache" - exit - ;; + exit + ;; - status) +status) - if [ -r $DCACHE_PID_FILE ]; then - pid=`cat $DCACHE_PID_FILE` - if ps p $pid >/dev/null 2>&1; then - echo "The dCache server is running" - exit 0 + if [ -r "$DCACHE_PID_FILE" ]; then + pid=$(cat "$DCACHE_PID_FILE") + if ps p "$pid" >/dev/null 2>&1; then + echo "The dCache server is running" + exit 0 + fi fi - fi - echo "The dCache server is not running" - exit 1 + echo "The dCache server is not running" + exit 1 - ;; + ;; esac echo "Usage: glite-info-service-dcache " diff --git a/src/glite-info-service-dpm b/src/glite-info-service-dpm index 11496ba..6d26ec2 100755 --- a/src/glite-info-service-dpm +++ b/src/glite-info-service-dpm @@ -9,72 +9,70 @@ # More robust selection of the port, from Michel Jouvin case "$1" in - init) +init) + # host=${DPM_HOST:-`grep DPM /etc/shift.conf | cut -d" " -f3`} + host=${DPM_HOST:-$(hostname -f)} -# host=${DPM_HOST:-`grep DPM /etc/shift.conf | cut -d" " -f3`} - host=${DPM_HOST:-`hostname -f`} - - case "$2" in + case "$2" in v1) -. /etc/sysconfig/srmv1 - port=${SRMV1_PORT:-8443} -# port=`grep SRMV1 /etc/shift.conf | cut -d" " -f3` -# port=${port:-8443} - version=1.1.0 - ;; + . /etc/sysconfig/srmv1 + port=${SRMV1_PORT:-8443} + # port=`grep SRMV1 /etc/shift.conf | cut -d" " -f3` + # port=${port:-8443} + version=1.1.0 + ;; v2) -. /etc/sysconfig/srmv2.2 - port=${SRMV2_2_PORT:-8446} -# port=`grep SRMV2_2 /etc/shift.conf | cut -d" " -f3` -# port=${port:-8446} - version=2.2.0 - ;; + . /etc/sysconfig/srmv2.2 + port=${SRMV2_2_PORT:-8446} + # port=`grep SRMV2_2 /etc/shift.conf | cut -d" " -f3` + # port=${port:-8446} + version=2.2.0 + ;; *) - echo "Usage: glite-info-service-dpm " - echo "Second argument must be v1 or v2" - exit 2 - ;; - esac - - echo GLITE_INFO_SERVICE_ENDPOINT=httpg://$host:$port/srm/manager$2 - echo GLITE_INFO_SERVICE_VERSION=$version - exit - ;; + echo "Usage: glite-info-service-dpm " + echo "Second argument must be v1 or v2" + exit 2 + ;; + esac - status) + echo GLITE_INFO_SERVICE_ENDPOINT="httpg://$host:$port/srm/manager$2" + echo GLITE_INFO_SERVICE_VERSION="$version" + exit + ;; - stat1=`/sbin/service dpm status` - rc1=$? +status) + /sbin/service dpm status > /dev/null + rc1=$? - stat2=`/sbin/service dpnsdaemon status` - rc2=$? + /sbin/service dpnsdaemon status > /dev/null + rc2=$? - case "$2" in - v1) - stat3=`/sbin/service srmv1 status` - rc3=$? - ;; - v2) - stat3=`/sbin/service srmv2.2 status` - rc3=$? - ;; - *) - echo "Internal error (unknown SRM version)" - exit 3 - ;; - esac + case "$2" in + v1) + /sbin/service srmv1 status > /dev/null + rc3=$? + ;; + v2) + /sbin/service srmv2.2 status > /dev/null + rc3=$? + ;; + *) + echo "Internal error (unknown SRM version)" + exit 3 + ;; + esac - echo -n "The DPM server is " - [[ $rc1 != 0 ]] && echo -n "not " - echo -n "running, the DPNS daemon is " - [[ $rc2 != 0 ]] && echo -n "not " - echo -n "running and the SRM is " - [[ $rc3 != 0 ]] && echo -n "not " - echo "running" - [[ ($rc1 == 0) && ($rc2 == 0) && ($rc3 == 0) ]] - exit $? + echo -n "The DPM server is " + [[ $rc1 != 0 ]] && echo -n "not " + echo -n "running, the DPNS daemon is " + [[ $rc2 != 0 ]] && echo -n "not " + echo -n "running and the SRM is " + [[ $rc3 != 0 ]] && echo -n "not " + echo "running" + [[ ($rc1 == 0) && ($rc2 == 0) && ($rc3 == 0) ]] + exit $? - ;; + ;; esac echo "Usage: glite-info-service-dpm " diff --git a/src/glite-info-service-frontier b/src/glite-info-service-frontier index 037740e..804685c 100755 --- a/src/glite-info-service-frontier +++ b/src/glite-info-service-frontier @@ -3,7 +3,7 @@ # init function for the Frontier service publisher, to export some variables FRONTIER_PORT=${FRONTIER_PORT:-3128} -FRONTIER_HOST=${FRONTIER_HOST:-`hostname -f`} +FRONTIER_HOST=${FRONTIER_HOST:-$(hostname -f)} CATALINA_HOME=/data/dbfrontier/tomcat CATALINA_PID=$CATALINA_HOME/logs/tomcat.pid @@ -11,8 +11,6 @@ CATALINA_PID=$CATALINA_HOME/logs/tomcat.pid FRONTIER_PID_FILE=${FRONTIER_PID_FILE:-${CATALINA_PID}} # Write to stdout - will be imported by the info provider - -echo FRONTIER_PORT=$FRONTIER_PORT -echo FRONTIER_HOST=$FRONTIER_HOST -echo FRONTIER_PID_FILE=$FRONTIER_PID_FILE - +echo FRONTIER_PORT="$FRONTIER_PORT" +echo FRONTIER_HOST="$FRONTIER_HOST" +echo FRONTIER_PID_FILE="$FRONTIER_PID_FILE" diff --git a/src/glite-info-service-gatekeeper b/src/glite-info-service-gatekeeper deleted file mode 100755 index 5580548..0000000 --- a/src/glite-info-service-gatekeeper +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -# init function for the globus/edg gatekeeper, to export some variables - -# The first two can be overridden by external definitions of the variables, -# e.g. if the advertised host name should be an alias - -GATEKEEPER_HOST=${GATEKEEPER_HOST:-`hostname -f`} -GATEKEEPER_PORT=${GATEKEEPER_PORT:-2119} - -GATEKEEPER_LOCKFILE=/var/lock/edg-gatekeeper - -# It seems that the lockfile isn't used in more recent configurations, -# so try finding the process and using the /proc/nnn timestamp - -GATEKEEPER_PROCDIR=`/bin/ps axwww | awk '/[g]atekeeper/ { print "/proc/"$1 }' | head -n 1` - -GLOBUS_SYSCONFIG=${GLOBUS_SYSCONFIG:-/etc/sysconfig/globus} -if [ -f "$GLOBUS_SYSCONFIG" ]; then - . "$GLOBUS_SYSCONFIG" -fi - -GLOBUS_LOCATION=${GLOBUS_LOCATION:-/opt/globus} - -GATEKEEPER_SERVICES=`ls -w 255 -m $GLOBUS_LOCATION/etc/grid-services | sed 's/ //g'` - -# Write to stdout - will be imported by the info provider - -echo GATEKEEPER_PORT=$GATEKEEPER_PORT -echo GATEKEEPER_HOST=$GATEKEEPER_HOST -echo GATEKEEPER_SERVICES=$GATEKEEPER_SERVICES -echo GATEKEEPER_LOCKFILE=$GATEKEEPER_LOCKFILE -echo GATEKEEPER_PROCDIR=$GATEKEEPER_PROCDIR diff --git a/src/glite-info-service-glue2 b/src/glite-info-service-glue2 index d9a485d..0d7f217 100755 --- a/src/glite-info-service-glue2 +++ b/src/glite-info-service-glue2 @@ -4,4 +4,4 @@ # and replaced by this script which calls the plug-compatible # glite-info-glue2-simple provider. -glite-info-glue2-simple $@ +glite-info-glue2-simple "$@" diff --git a/src/glite-info-service-glue2-beta b/src/glite-info-service-glue2-beta index 5109d0b..7e3df07 100755 --- a/src/glite-info-service-glue2-beta +++ b/src/glite-info-service-glue2-beta @@ -53,61 +53,68 @@ my $validity = "3600"; # The site name (GLUE2DomainID) should be the second argument -if ($ARGV[1]){ +if ( $ARGV[1] ) { $SiteID = $ARGV[1]; -}else{ - print STDERR "Usage: glite-info-service-glue2 []\n"; +} +else { + print STDERR +"Usage: glite-info-service-glue2 []\n"; exit 1; } # Read in the configuration file (first argument) my %config = ( - init => '', - service_type => '', - get_version => '', - get_endpoint => '', - get_status => '', - WSDL_URL => '', - semantics_URL => '', - get_starttime => '', - get_owner => '', - get_acbr => '', - get_data => '', - get_services => '', - ); - -if ($ARGV[0]){ + init => '', + service_type => '', + get_version => '', + get_endpoint => '', + get_status => '', + WSDL_URL => '', + semantics_URL => '', + get_starttime => '', + get_owner => '', + get_acbr => '', + get_data => '', + get_services => '', +); + +if ( $ARGV[0] ) { $confile = $ARGV[0]; - my $fh = new FileHandle $confile - or die "Error: Can't open configuration file: $ARGV[0]\n"; - foreach (<$fh>){ - if ((! m/^\#/) & (m/=/)){ -# For lines containing an = and not starting with # + my $fh = FileHandle->new($confile) + or die "Error: Can't open configuration file: $ARGV[0]\n"; + foreach (<$fh>) { + if ( ( !m/^\#/ ) & (m/=/) ) { + + # For lines containing an = and not starting with # m/^(.*?)=\s*(.*)\s*$/; -# Split on the first =, no leading or trailing whitespace in the value - my $key=$1; - my $value=$2; - $key=~s/\s+//g; - $config{$key}=$value; + + # Split on the first =, no leading or trailing whitespace in the value + my $key = $1; + my $value = $2; + $key =~ s/\s+//g; + $config{$key} = $value; } } -}else{ - print STDERR "Usage: glite-info-service-glue2 []\n"; +} +else { + print STDERR +"Usage: glite-info-service-glue2 []\n"; exit 1; } # Check that all configuration items are set my $missing = 0; -while ( my ($key, $value) = each(%config) ) { - if ( ! $config{$key} ){ +while ( my ( $key, $value ) = each(%config) ) { + if ( !$config{$key} ) { print STDERR "Error: configuration parameter $key not set\n"; $missing += 1; } } -if ( $missing ) { - print STDERR "Error: $missing configuration parameter(s) not set in file $confile\n"; +if ($missing) { + print STDERR + "Error: $missing configuration parameter(s) not set in file $confile\n"; exit 2; } @@ -128,24 +135,26 @@ $ENV{"GLITE_INFO_SERVICE_GLUE2_SITE_ID"} = $SiteID; $command = $config{init}; my @init_result = `$command`; -my $init_rc = $? >> 8; -if ( $init_rc ){ +my $init_rc = $? >> 8; +if ($init_rc) { print STDERR "Error: init command $command failed\n"; print STDERR "@init_result\n"; exit $init_rc; } foreach (@init_result) { -# Should be key=value pairs - if ( m/=/ ){ + + # Should be key=value pairs + if (m/=/) { m/^(.*?)=\s*(.*)\s*$/; -# Split on the first =, no leading or trailing whitespace in the value - my $key=$1; - my $value=$2; - $key=~s/\s+//g; - if ($key) { - $ENV{$key} = $value; - } + + # Split on the first =, no leading or trailing whitespace in the value + my $key = $1; + my $value = $2; + $key =~ s/\s+//g; + if ($key) { + $ENV{$key} = $value; + } } } @@ -156,7 +165,7 @@ $command = $config{get_endpoint}; my $Endpoint = `$command`; $command = $config{get_status}; -my $Info = `$command`; +my $Info = `$command`; my $Status = $? >> 8; $command = $config{get_starttime}; @@ -172,7 +181,7 @@ my @ACBR = `$command`; # OtherInfo is not yet supported $command = "echo"; -my @ServiceOtherInfo = `$command`; +my @ServiceOtherInfo = `$command`; my @EndpointOtherInfo = `$command`; # Capabilities are not yet supported @@ -191,8 +200,8 @@ my @StatusInfo = ""; # Implementor, ImplementationName and ImplementationVersion are not # yet supported -my $Implementor = ""; -my $ImplementationName = ""; +my $Implementor = ""; +my $ImplementationName = ""; my $ImplementationVersion = ""; # Not clear if this should be configurable @@ -217,13 +226,15 @@ my $Type = $config{service_type}; # there may be a need to preserve a persistent ID in some cases, # hence the entire ID can be passed as an optional third argument. -if ($ARGV[2]) { +if ( $ARGV[2] ) { $UID = $ARGV[2]; -} else { +} +else { my $check = `cksum $confile | cut -d\" \" -f 1`; chomp($check); -# Note that this may cause trouble if hostname -f does not return an fqdn, -# but I think that is normally required by other things anyway + + # Note that this may cause trouble if hostname -f does not return an fqdn, + # but I think that is normally required by other things anyway $UID = $host . "_" . $Type . "_" . $check; } @@ -247,7 +258,7 @@ print "GLUE2ServiceID: $UID\n"; # Creation time and validity are standard attributes for all objects # Times are mandated to be UTC only -my $TimeNow = strftime("%Y-%m-%dT%H:%M:%SZ", gmtime()); +my $TimeNow = strftime( "%Y-%m-%dT%H:%M:%SZ", gmtime() ); print "GLUE2EntityCreationTime: $TimeNow\n"; print "GLUE2EntityValidity: $validity\n"; @@ -263,11 +274,12 @@ print "GLUE2EntityName: $Name\n"; # NB OtherInfo is not yet supported, but this would print it if defined above foreach (@ServiceOtherInfo) { -# No leading or trailing spaces, and limit to a reasonable length + + # No leading or trailing spaces, and limit to a reasonable length s/^\s+//; s/\s+$//; - if (length > 240) { - $_ = substr($_, 0, 239) . "4444"; + if ( length > 240 ) { + $_ = substr( $_, 0, 239 ) . "4444"; } if ($_) { print "GLUE2EntityOtherInfo: $_\n"; @@ -284,8 +296,9 @@ print "GLUE2EntityOtherInfo: InfoProviderHost=$host\n"; # if defined above foreach (@Capabilities) { -# Should be no need for validation as it will be fixed per service type, -# but still strip leading and trailing spaces + + # Should be no need for validation as it will be fixed per service type, + # but still strip leading and trailing spaces s/^\s+//; s/\s+$//; if ($_) { @@ -306,10 +319,11 @@ print "GLUE2ServiceQualityLevel: $QualityLevel\n"; # if defined above foreach (@StatusInfo) { -# Strip all whitespace + + # Strip all whitespace s/\s+//g; if (m/^http/) { - print "GlueServiceStatusInfo: $_\n"; + print "GlueServiceStatusInfo: $_\n"; } } @@ -328,8 +342,8 @@ print "GLUE2ServiceAdminDomainForeignKey: $SiteID\n"; foreach (@RelatedServices) { s/\s+//g; - if (length > 240) { - $_ = substr($_, 0, 239) . "4444"; + if ( length > 240 ) { + $_ = substr( $_, 0, 239 ) . "4444"; } if ($_) { print "GLUE2ServiceServiceForeignKey: $_\n"; @@ -370,11 +384,12 @@ print "GLUE2EntityName: $Name\n"; # NB OtherInfo is not yet supported, but this would print it if defined above foreach (@EndpointOtherInfo) { -# No leading or trailing spaces, and limit to a reasonable length + + # No leading or trailing spaces, and limit to a reasonable length s/^\s+//; s/\s+$//; - if (length > 240) { - $_ = substr($_, 0, 239) . "4444"; + if ( length > 240 ) { + $_ = substr( $_, 0, 239 ) . "4444"; } if ($_) { print "GLUE2EntityOtherInfo: $_\n"; @@ -394,8 +409,8 @@ print "GLUE2EntityOtherInfo: InfoProviderHost=$host\n"; $Endpoint =~ s/\s+//g; # Sanity check on the length -if (length($Endpoint) > 240) { - $Endpoint = substr($Endpoint, 0, 239) . "4444"; +if ( length($Endpoint) > 240 ) { + $Endpoint = substr( $Endpoint, 0, 239 ) . "4444"; } if ($Endpoint) { @@ -406,8 +421,9 @@ if ($Endpoint) { # if defined above foreach (@Capabilities) { -# Should be no need for validation as it will be fixed per service type, -# but still strip leading and trailing spaces + + # Should be no need for validation as it will be fixed per service type, + # but still strip leading and trailing spaces s/^\s+//; s/\s+$//; if ($_) { @@ -439,14 +455,17 @@ $Version =~ s/\s+//g; my $minor; my $patch; my $bad; -(undef, $minor, $patch, $bad) = split /\./, $Version; -if ( defined($bad) || (length($Version) > 16) || (length($Version) == 0) ) { +( undef, $minor, $patch, $bad ) = split /\./, $Version; +if ( defined($bad) || ( length($Version) > 16 ) || ( length($Version) == 0 ) ) { print "GLUE2EndpointInterfaceVersion: 4.4.4.4\n"; -} elsif ( ! defined($minor) ) { +} +elsif ( !defined($minor) ) { print "GLUE2EndpointInterfaceVersion: $Version.0.0\n"; -} elsif ( ! defined($patch) ) { +} +elsif ( !defined($patch) ) { print "GLUE2EndpointInterfaceVersion: $Version.0\n"; -} else { +} +else { print "GLUE2EndpointInterfaceVersion: $Version\n"; } @@ -460,14 +479,14 @@ if ( defined($bad) || (length($Version) > 16) || (length($Version) == 0) ) { my $WSDL = $config{WSDL_URL}; $WSDL =~ s/\s+//g; -if ($WSDL =~ m/^http/) { +if ( $WSDL =~ m/^http/ ) { print "GLUE2EndpointTechnology: webservice\n"; print "GLUE2EndpointWSDL: $WSDL\n"; } my $Semantics = $config{semantics_URL}; $Semantics =~ s/\s+//g; -if ($Semantics =~ m/^http/) { +if ( $Semantics =~ m/^http/ ) { print "GLUE2EndpointSemantics: $Semantics\n"; } @@ -499,11 +518,11 @@ print "GLUE2EndpointQualityLevel: $QualityLevel\n"; # 0 = OK, 1 = Critical, 2 = Warning, 3 = Unknown, other = Other my $Statcode; -if ($Status == 0) { $Statcode = "ok" } -elsif ($Status == 1) { $Statcode = "critical" } -elsif ($Status == 2) { $Statcode = "warning" } -elsif ($Status == 3) { $Statcode = "unknown" } -else { $Statcode = "other" } +if ( $Status == 0 ) { $Statcode = "ok" } +elsif ( $Status == 1 ) { $Statcode = "critical" } +elsif ( $Status == 2 ) { $Statcode = "warning" } +elsif ( $Status == 3 ) { $Statcode = "unknown" } +else { $Statcode = "other" } print "GLUE2EndpointHealthState: $Statcode\n"; @@ -521,12 +540,12 @@ $Info =~ s/\n+/ /g; $Info =~ s/\p{IsC}.*$//; # Truncate if necessary -if (length($Info) > 240) { - $Info = substr($Info, 0, 239) . " ..."; +if ( length($Info) > 240 ) { + $Info = substr( $Info, 0, 239 ) . " ..."; } # Too short -if (length($Info) < 2) { +if ( length($Info) < 2 ) { $Info = "??"; } @@ -546,25 +565,26 @@ print "GLUE2EndpointServingState: $ServingState\n"; # No white space, should just be a number # The error indicator here is the Unix epoch $ST =~ s/\s+//g; -if ( !($ST =~ m/^\d+$/) ) { +if ( !( $ST =~ m/^\d+$/ ) ) { $ST = 0; } # We need to munge the timezone indicator to add a colon between # the hours and minutes -my $tz = strftime("%z", localtime($ST)); +my $tz = strftime( "%z", localtime($ST) ); $tz =~ s/(\d{2})(\d{2})/$1:$2/; -my $StartTime = strftime("%Y-%m-%dT%H:%M:%S", localtime($ST)) . $tz; +my $StartTime = strftime( "%Y-%m-%dT%H:%M:%S", localtime($ST) ) . $tz; # No error checks as strftime should return something reasonable print "GLUE2EndpointStartTime: $StartTime\n"; # This should give us the host cert issuer, if any -my $Issuer = ""; +my $Issuer = ""; my $hostcert = "/etc/grid-security/hostcert.pem"; -if ( -e $hostcert) { -# $Issuer = `grid-cert-info -file $hostcert -issuer`; +if ( -e $hostcert ) { + + # $Issuer = `grid-cert-info -file $hostcert -issuer`; $Issuer = `openssl x509 -issuer -noout -in $hostcert | sed 's/^[^/]*//'`; } @@ -582,7 +602,8 @@ print "GLUE2EndpointTrustedCA: $TrustedCA\n"; # Downtimes are handled by the GOC DB in EGEE, so not published here -print "GLUE2EndpointDownTimeInfo: See the GOC DB for downtimes: https://goc.gridops.org/\n"; +print +"GLUE2EndpointDownTimeInfo: See the GOC DB for downtimes: https://goc.gridops.org/\n"; # Finally print the upward link to the parent Service @@ -597,45 +618,54 @@ print "\n"; my %items = (); foreach (@ServiceData) { -# Should be key=value pairs - if ( m/=/ ){ + + # Should be key=value pairs + if (m/=/) { m/^(.*?)=\s*(.*)\s*$/; -# Split on the first =, no leading or trailing whitespace in the value - my $key=$1; - my $value=$2; - $key=~s/\s+//g; -# R-GMA has varchar(100) - if (length($key) > 99) { - $key = substr($key, 0, 94) . "4444"; + + # Split on the first =, no leading or trailing whitespace in the value + my $key = $1; + my $value = $2; + $key =~ s/\s+//g; + + # R-GMA has varchar(100) + if ( length($key) > 99 ) { + $key = substr( $key, 0, 94 ) . "4444"; } - if (length($value) > 99) { - $value = substr($value, 0, 94) . "4444"; + if ( length($value) > 99 ) { + $value = substr( $value, 0, 94 ) . "4444"; } -# Don't output anything if the key is null - if (length($key) > 0) { + + # Don't output anything if the key is null + if ( length($key) > 0 ) { $items{$key} = $value; - }else{ - print STDERR "Extension Key has 0 length, value is: " . $value . "\n"; - } + } + else { + print STDERR "Extension Key has 0 length, value is: " . $value + . "\n"; + } } } # Now print the Extension objects - the order is random but it doesn't matter -my $ext = 0; +my $ext = 0; my $ELID = "0"; -while ( my ($key, $value) = each(%items) ) { -# Extensions only need a local ID - but note that the Key may not be unique +while ( my ( $key, $value ) = each(%items) ) { + + # Extensions only need a local ID - but note that the Key may not be unique $ext++; $ELID = $key . "_" . $ext; - print "dn: GLUE2ExtensionLocalID=$ELID,GLUE2EndpointID=$EUID,GLUE2ServiceID=$UID,$bind_dn\n"; + print +"dn: GLUE2ExtensionLocalID=$ELID,GLUE2EndpointID=$EUID,GLUE2ServiceID=$UID,$bind_dn\n"; print "objectClass: GLUE2Extension\n"; print "GLUE2ExtensionLocalID: $ELID\n"; print "GLUE2ExtensionKey: $key\n"; - if (length($value) > 0) { + if ( length($value) > 0 ) { print "GLUE2ExtensionValue: $value\n"; - }else{ -# We are required to print a value + } + else { + # We are required to print a value print "GLUE2ExtensionValue: UNDEFINEDVALUE\n"; } print "GLUE2ExtensionEntityForeignKey: $EUID\n"; @@ -656,7 +686,8 @@ my $APUID = $EUID . "_AP"; # Start with the DN ... -print "dn: GLUE2PolicyID=$APUID,GLUE2EndpointID=$EUID,GLUE2ServiceID=$UID,$bind_dn\n"; +print +"dn: GLUE2PolicyID=$APUID,GLUE2EndpointID=$EUID,GLUE2ServiceID=$UID,$bind_dn\n"; # Print the boilerplate objectclass declarations and unique ID @@ -697,17 +728,17 @@ my $rules = 0; foreach (@ACBR) { s/^\s+//; s/\s+$//; - if (length > 240) { - $_ = substr($_, 0, 239) . "4444"; + if ( length > 240 ) { + $_ = substr( $_, 0, 239 ) . "4444"; } if ($_) { - $rules++; + $rules++; print "GLUE2PolicyRule: $_\n"; } } # "ALL" is a reserved word meaning that there is no authz -if ($rules == 0) { +if ( $rules == 0 ) { print "GLUE2PolicyRule: ALL\n"; } @@ -719,19 +750,19 @@ if ($rules == 0) { $rules = 0; foreach (@Owner) { s/\s+//g; - if (length > 240) { - $_ = substr($_, 0, 239) . "4444"; + if ( length > 240 ) { + $_ = substr( $_, 0, 239 ) . "4444"; } if ($_) { - $rules++; - print "GLUE2PolicyUserDomainForeignKey: $_\n"; + $rules++; + print "GLUE2PolicyUserDomainForeignKey: $_\n"; } } # The spec says that there must be at least one UserDomain reference, # which is probably a mistake! We should try to avoid this being a valid # VO name ... -if ($rules == 0) { +if ( $rules == 0 ) { print "GLUE2PolicyUserDomainForeignKey: \$UNDEFINED\$\n"; } diff --git a/src/glite-info-service-gridice b/src/glite-info-service-gridice deleted file mode 100755 index 35bd662..0000000 --- a/src/glite-info-service-gridice +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -# init function for the gridice service publisher, to export some variables - -# The first two can be overridden by external definitions of the variables, -# e.g. if the advertised host name should be an alias - -GRIDICE_HOST=${GRIDICE_HOST:-`hostname -f`} -GRIDICE_PORT=${GRIDICE_PORT:-2136} - -# Write to stdout - will be imported by the info provider - -echo GRIDICE_PORT=$GRIDICE_PORT -echo GRIDICE_HOST=$GRIDICE_HOST - -# We seem to be stuck with having this hardwired -echo GRIDICE_PID_FILE=/opt/gridice/monitoring/gris/var/tmp/daemon-gridice-mds.pid - diff --git a/src/glite-info-service-lbserver b/src/glite-info-service-lbserver deleted file mode 100755 index c3ab28e..0000000 --- a/src/glite-info-service-lbserver +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -# SB 11/8/11 Updated for EMI paths - -# init function for the LB server service publisher, to export some variables - -# There is no config file for the LB server - -LBSERVER_PORT=${LBSERVER_PORT:-9003} -LBSERVER_HOST=${LBSERVER_HOST:-`hostname -f`} - -# GLITE_LOCATION_VAR=${GLITE_LOCATION_VAR:-/var/glite} - -# LBSERVER_PID_FILE=${LBSERVER_PID_FILE:-${GLITE_LOCATION_VAR}/glite-lb-bkserverd.pid} - -# EMI has files in standard locations - -if [ -r /var/run/glite/glite-lb-bkserverd.pid ]; then -# New location - LBSERVER_PID_FILE=${LBSERVER_PID_FILE:-/var/run/glite/glite-lb-bkserverd.pid} -else -# Old location - LBSERVER_PID_FILE=${LBSERVER_PID_FILE:-/var/glite/glite-lb-bkserverd.pid} -fi - -# Write to stdout - will be imported by the info provider - -echo LBSERVER_PORT=$LBSERVER_PORT -echo LBSERVER_HOST=$LBSERVER_HOST -echo LBSERVER_PID_FILE=$LBSERVER_PID_FILE - diff --git a/src/glite-info-service-myproxy b/src/glite-info-service-myproxy index 351d370..6a70bca 100755 --- a/src/glite-info-service-myproxy +++ b/src/glite-info-service-myproxy @@ -5,46 +5,43 @@ # status to check the status case "$1" in - init) +init) -# These can be overridden by external definitions of the variables, -# e.g. if the advertised host name should be an alias + # These can be overridden by external definitions of the variables, + # e.g. if the advertised host name should be an alias + MYPROXY_CONF=${MYPROXY_CONF:-/etc/myproxy-server.config} + MYPROXY_HOST=${MYPROXY_HOST:-$(hostname -f)} + MYPROXY_PORT=${MYPROXY_PORT:-7512} - MYPROXY_CONF=${MYPROXY_CONF:-/etc/myproxy-server.config} - MYPROXY_HOST=${MYPROXY_HOST:-`hostname -f`} - MYPROXY_PORT=${MYPROXY_PORT:-7512} + # Write to stdout - will be imported by the info provider + echo MYPROXY_CONF="$MYPROXY_CONF" + echo MYPROXY_HOST="$MYPROXY_HOST" + echo MYPROXY_PORT="$MYPROXY_PORT" -# Write to stdout - will be imported by the info provider + # myproxy doesn't seem to have a pid file, but the init.d script + # does create and remove this lock file + echo MYPROXY_PID_FILE=/var/lock/subsys/myproxy-server - echo MYPROXY_CONF=$MYPROXY_CONF - echo MYPROXY_HOST=$MYPROXY_HOST - echo MYPROXY_PORT=$MYPROXY_PORT + exit + ;; -# myproxy doesn't seem to have a pid file, but the init.d script -# does create and remove this lock file +status) - echo MYPROXY_PID_FILE=/var/lock/subsys/myproxy-server + test -f /var/lock/subsys/myproxy-server + rc1=$? - exit - ;; + netstat -an --inet --inet6 | grep -s "^tcp .* \(::\|0.0.0.0\):${MYPROXY_PORT:-7512} .*LISTEN" + rc2=$? - status) + echo -n "The MyProxy server is " + [[ $rc1 != 0 ]] && echo -n "not " + echo -n "running and is " + [[ $rc2 != 0 ]] && echo -n "not " + echo "listening" + [[ ($rc1 == 0) && ($rc2 == 0) ]] + exit $? - stat1=`test -f /var/lock/subsys/myproxy-server` - rc1=$? - - stat2=`netstat -an --inet --inet6 | grep "^tcp .* \(::\|0.0.0.0\):${MYPROXY_PORT:-7512} .*LISTEN"` - rc2=$? - - echo -n "The MyProxy server is " - [[ $rc1 != 0 ]] && echo -n "not " - echo -n "running and is " - [[ $rc2 != 0 ]] && echo -n "not " - echo "listening" - [[ ($rc1 == 0) && ($rc2 == 0) ]] - exit $? - - ;; + ;; esac echo "Usage: glite-info-service-myproxy " diff --git a/src/glite-info-service-rtepublisher b/src/glite-info-service-rtepublisher index 359c002..80fcc0d 100755 --- a/src/glite-info-service-rtepublisher +++ b/src/glite-info-service-rtepublisher @@ -3,100 +3,83 @@ # Helper script for the RTEpublisher service case "$1" in - init) - -# init function for the RTEPublisher service publisher, -# to export some variables - -# The first two can be overridden by external definitions of the variables, -# e.g. if the advertised host name should be an alias - - RTEPUBLISHER_HOST=${RTEPUBLISHER_HOST:-`hostname -f`} - RTEPUBLISHER_PORT=${RTEPUBLISHER_PORT:-2811} - -# The path is currently hardwired - should be improved! - RTEPUBLISHER_PATH=${RTEPUBLISHER_PATH:-/opt/glite/var/info} - -# Apparently there is no pid file - use the log file to get a start time? - -#GLOBUS_SYSCONFIG=${GLOBUS_SYSCONFIG:-/etc/sysconfig/globus} -#if [ -f "$GLOBUS_SYSCONFIG" ]; then -# . "$GLOBUS_SYSCONFIG" -#fi - -#GRIDFTP_SYSCONFIG=${GRIDFTP_SYSCONFIG:-/etc/sysconfig/globus-gridftp} -#if [ -f "$GRIDFTP_SYSCONFIG" ]; then -# . "$GRIDFTP_SYSCONFIG" -#fi - -#GRIDFTP_LOCK_FILE=${GRIDFTP_TRANSFER_LOG:-/var/log/globus-gridftp.log} - -# This seems to have changed since the last time I looked at it ... - -# GRIDFTP_LOCK_FILE=/var/lock/subsys/globus-gridftp - -# Third try: get the pid for the ftpd process and use the timestamp -# on the /proc file - -# GRIDFTP_PROC_FILE=`/bin/ps axwww | awk '/[f]tpd/ { print "/proc/"$1 }' | head -n 1` - -# Fourth try: recent versions still have no pid/lock file and a different -# process name. - -# GRIDFTP_PROC_FILE=`/bin/ps axwww | awk '/globus-gridftp-server/ { print "/proc/"$1 }' | head -n 1` - -# Fifth try: the previous line could pick up the awk line itself ... - - GRIDFTP_PROC_FILE=`/bin/ps axwww | grep -v awk | awk '/globus-gridftp-server/ { print "/proc/"$1 }' | head -n 1` - -# Write to stdout - will be imported by the info provider - - echo RTEPUBLISHER_HOST=$RTEPUBLISHER_HOST - echo RTEPUBLISHER_PORT=$RTEPUBLISHER_PORT - echo RTEPUBLISHER_PATH=$RTEPUBLISHER_PATH - echo GRIDFTP_PROC_FILE=$GRIDFTP_PROC_FILE - echo SUBCLUSTERID=$SUBCLUSTERID - - exit - ;; - - subclusters) - -# SubCluster IDs are the names of the directories in the path -# The expression below should list them in a form which will create -# one ServiceData entry per directory with a Key of the form -# GlueSubClusterUniqueID: and no Value. - - ls -pQ $RTEPUBLISHER_PATH | grep /$ | cut -d\" -f2 | sed s/^/GlueSubClusterUniqueID:/ | sed s/$/=/ - - exit $? - - ;; - - executionenvironments) - -# This is a GLUE 2 equivalent for the subcluster publication. It's -# assumed that the ID (GLUE2ResourceID) is the same as the SubCluster ID. -# Also in GLUE 2 we can have multiple Extension objects with the same -# Key, so we can publish them more sensibly. - - ls -pQ $RTEPUBLISHER_PATH | grep /$ | cut -d\" -f2 | sed s/^/GLUE2ResourceID=/ - - exit $? - - ;; - - - vos) - -# VO names are the names of directories one level below the subcluster -# directories. The expression below should list all the VO names. - - ls -pQ $RTEPUBLISHER_PATH/* | grep /$ | cut -d\" -f2 | sort | uniq - - exit $? - - ;; +init) + # init function for the RTEPublisher service publisher, + # to export some variables + + # The first two can be overridden by external definitions of the variables, + # e.g. if the advertised host name should be an alias + RTEPUBLISHER_HOST=${RTEPUBLISHER_HOST:-$(hostname -f)} + RTEPUBLISHER_PORT=${RTEPUBLISHER_PORT:-2811} + + # The path is currently hardwired - should be improved! + RTEPUBLISHER_PATH=${RTEPUBLISHER_PATH:-/opt/glite/var/info} + + # Apparently there is no pid file - use the log file to get a start time? + # GLOBUS_SYSCONFIG=${GLOBUS_SYSCONFIG:-/etc/sysconfig/globus} + # if [ -f "$GLOBUS_SYSCONFIG" ]; then + # . "$GLOBUS_SYSCONFIG" + # fi + # GRIDFTP_SYSCONFIG=${GRIDFTP_SYSCONFIG:-/etc/sysconfig/globus-gridftp} + # if [ -f "$GRIDFTP_SYSCONFIG" ]; then + # . "$GRIDFTP_SYSCONFIG" + # fi + # GRIDFTP_LOCK_FILE=${GRIDFTP_TRANSFER_LOG:-/var/log/globus-gridftp.log} + + # This seems to have changed since the last time I looked at it ... + # GRIDFTP_LOCK_FILE=/var/lock/subsys/globus-gridftp + # Third try: get the pid for the ftpd process and use the timestamp + # on the /proc file + # GRIDFTP_PROC_FILE=`/bin/ps axwww | awk '/[f]tpd/ { print "/proc/"$1 }' | head -n 1` + # Fourth try: recent versions still have no pid/lock file and a different + # process name. + # GRIDFTP_PROC_FILE=`/bin/ps axwww | awk '/globus-gridftp-server/ { print "/proc/"$1 }' | head -n 1` + # Fifth try: the previous line could pick up the awk line itself ... + GRIDFTP_PROC_FILE=$(/bin/ps axwww | grep -v awk | awk '/globus-gridftp-server/ { print "/proc/"$1 }' | head -n 1) + + # Write to stdout - will be imported by the info provider + echo RTEPUBLISHER_HOST="$RTEPUBLISHER_HOST" + echo RTEPUBLISHER_PORT="$RTEPUBLISHER_PORT" + echo RTEPUBLISHER_PATH="$RTEPUBLISHER_PATH" + echo GRIDFTP_PROC_FILE="$GRIDFTP_PROC_FILE" + echo SUBCLUSTERID="$SUBCLUSTERID" + + exit + ;; + +subclusters) + # SubCluster IDs are the names of the directories in the path + # The expression below should list them in a form which will create + # one ServiceData entry per directory with a Key of the form + # GlueSubClusterUniqueID: and no Value. + # This ls is specially crafted to handle spaces, so disabling SC2010 + # shellcheck disable=SC2010 + ls -pQ "$RTEPUBLISHER_PATH" | grep /$ | cut -d\" -f2 | sed s/^/GlueSubClusterUniqueID:/ | sed s/$/=/ + + exit $? + ;; + +executionenvironments) + # This is a GLUE 2 equivalent for the subcluster publication. It's + # assumed that the ID (GLUE2ResourceID) is the same as the SubCluster ID. + # Also in GLUE 2 we can have multiple Extension objects with the same + # Key, so we can publish them more sensibly. + # This ls is specially crafted to handle spaces, so disabling SC2010 + # shellcheck disable=SC2010 + ls -pQ "$RTEPUBLISHER_PATH" | grep /$ | cut -d\" -f2 | sed s/^/GLUE2ResourceID=/ + + exit $? + ;; + +vos) + # VO names are the names of directories one level below the subcluster + # directories. The expression below should list all the VO names. + # This ls is specially crafted to handle spaces, so disabling SC2010 + # shellcheck disable=SC2010 + ls -pQ "$RTEPUBLISHER_PATH"/* | grep /$ | cut -d\" -f2 | sort | uniq + + exit $? + ;; esac diff --git a/src/glite-info-service-squid b/src/glite-info-service-squid index 8b8911c..fe1da65 100755 --- a/src/glite-info-service-squid +++ b/src/glite-info-service-squid @@ -3,13 +3,12 @@ # init function for the squid service publisher, to export some variables SQUID_PORT=${SQUID_PORT:-3128} -SQUID_HOST=${SQUID_HOST:-`hostname -f`} +SQUID_HOST=${SQUID_HOST:-$(hostname -f)} SQUID_PID_FILE=${SQUID_PID_FILE:-/var/run/squid/squid.pid} # Write to stdout - will be imported by the info provider -echo SQUID_PORT=$SQUID_PORT -echo SQUID_HOST=$SQUID_HOST -echo SQUID_PID_FILE=$SQUID_PID_FILE - +echo SQUID_PORT="$SQUID_PORT" +echo SQUID_HOST="$SQUID_HOST" +echo SQUID_PID_FILE="$SQUID_PID_FILE" diff --git a/src/glite-info-service-status b/src/glite-info-service-status index a91e41a..94647ba 100755 --- a/src/glite-info-service-status +++ b/src/glite-info-service-status @@ -5,10 +5,10 @@ # and also to attempt to remove pids from the output as some people # don't like them and they anyway don't add any information -if [ "x$1" == "x" ]; then - echo Service name missing -# Returning 3 will give Unknown - exit 3 +if [ "$1" == "" ]; then + echo Service name missing + # Returning 3 will give Unknown + exit 3 fi service=$1 @@ -18,23 +18,22 @@ shift export LANG=C # Collect the stdout and return code from service status -string=`/sbin/service $service status $@` +string=$(/sbin/service "$service" status "$@") rc=$? # Strip out the standard representation of pids -echo $string | sed 's/(pid .*) //' +echo "${string/(pid *) /}" if [ $rc -eq 0 ]; then - exit 0 + exit 0 elif [ $rc -lt 4 ]; then -# Values of 1 to 3 all indicate that the service is not running, -# so return as 1 = Critical - exit 1 + # Values of 1 to 3 all indicate that the service is not running, + # so return as 1 = Critical + exit 1 elif [ $rc -eq 4 ]; then -# 4 means Unknown, translated to 3 - exit 3 + # 4 means Unknown, translated to 3 + exit 3 else -# Larger values returned as-is, which will translate to Other - exit $rc + # Larger values returned as-is, which will translate to Other + exit $rc fi - diff --git a/src/glite-info-service-test b/src/glite-info-service-test index e609fbf..19d8bde 100755 --- a/src/glite-info-service-test +++ b/src/glite-info-service-test @@ -7,15 +7,15 @@ # Define a variable GLITE_INFO_SERVICE_STATUS_XXX with a message string # where XXX is the service name -if [ "x$1" == "x" ]; then - exit +if [ "$1" == "" ]; then + exit fi -eval SERVICE_STATUS=\$GLITE_INFO_SERVICE_STATUS_$1 +eval SERVICE_STATUS=\$GLITE_INFO_SERVICE_STATUS_"$1" -if [ "x$SERVICE_STATUS" == "x" ]; then - exit +if [ "$SERVICE_STATUS" == "" ]; then + exit else - echo $SERVICE_STATUS - exit 2 + echo "$SERVICE_STATUS" + exit 2 fi diff --git a/src/glite-info-service-vobox b/src/glite-info-service-vobox index a44c9cc..23627ee 100755 --- a/src/glite-info-service-vobox +++ b/src/glite-info-service-vobox @@ -1,41 +1,39 @@ #!/bin/bash case $1 in - status) - if [ -r $VOBOX_PID_FILE ]; then - pid=`cat $VOBOX_PID_FILE` - if ps p $pid >/dev/null 2>&1; then - echo "gsissh process is running" - exit 0 +status) + if [ -r "$VOBOX_PID_FILE" ]; then + pid=$(cat "$VOBOX_PID_FILE") + if ps p "$pid" >/dev/null 2>&1; then + echo "gsissh process is running" + exit 0 + fi fi - fi + echo "gsissh process is not running" + exit 1 + ;; - echo "gsissh process is not running" - exit 1 - ;; +init) + # init function for the VOBOX service publisher, to export some variables - init) -# init function for the VOBOX service publisher, to export some variables + # The first two can be overridden by external definitions of the variables, + # e.g. if the advertised host name should be an alias + VOBOX_HOST=${VOBOX_HOST:-$(hostname -f)} + VOBOX_PORT=${VOBOX_PORT:-1975} -# The first two can be overridden by external definitions of the variables, -# e.g. if the advertised host name should be an alias - - VOBOX_HOST=${VOBOX_HOST:-`hostname -f`} - VOBOX_PORT=${VOBOX_PORT:-1975} - - GLOBUS_LOCATION=${GLOBUS_LOCATION:-/opt/globus} - if [ -r ${GLOBUS_LOCATION}/libexec/globus-script-initializer ]; then - . ${GLOBUS_LOCATION}/libexec/globus-script-initializer - fi - - VOBOX_PID_FILE=${localstatedir}/sshd.pid - -# Write to stdout - will be imported by the info provider + GLOBUS_LOCATION=${GLOBUS_LOCATION:-/opt/globus} + if [ -r "${GLOBUS_LOCATION}"/libexec/globus-script-initializer ]; then + . "${GLOBUS_LOCATION}/libexec/globus-script-initializer" + fi - echo VOBOX_PID_FILE=$VOBOX_PID_FILE - echo VOBOX_PORT=$VOBOX_PORT - echo VOBOX_HOST=$VOBOX_HOST + # this code is probably buggy + # shellcheck disable=SC2154 + VOBOX_PID_FILE=${localstatedir}/sshd.pid -;; + # Write to stdout - will be imported by the info provider + echo VOBOX_PID_FILE="$VOBOX_PID_FILE" + echo VOBOX_PORT="$VOBOX_PORT" + echo VOBOX_HOST="$VOBOX_HOST" + ;; esac diff --git a/src/glite-info-service-voms b/src/glite-info-service-voms index 952500f..3669a95 100755 --- a/src/glite-info-service-voms +++ b/src/glite-info-service-voms @@ -3,30 +3,28 @@ # Helper script for the VOMS service publisher # Argument is the VO name -if [ x$1 == "x" ]; then - echo No VO name defined - exit 1 +if [ "$1" == "" ]; then + echo No VO name defined + exit 1 fi VOMS_VO=$1 VOMS_CONF=/etc/voms/$VOMS_VO/voms.conf -if [ -r $VOMS_CONF ]; then - VOMS_PORT=`grep [\-]-port $VOMS_CONF | cut -d= -f2` - VOMS_PORT=${VOMS_PORT:-UNDEFINEDVALUE} +if [ -r "$VOMS_CONF" ]; then + VOMS_PORT=$(grep '[\-]-port' "$VOMS_CONF" | cut -d= -f2) + VOMS_PORT=${VOMS_PORT:-UNDEFINEDVALUE} else - echo No configuration file $VOMS_CONF found for VO $VOMS_VO - exit 2 + echo "No configuration file $VOMS_CONF found for VO $VOMS_VO" + exit 2 fi -VOMS_HOST=${VOMS_HOST:-`hostname -f`} +VOMS_HOST=${VOMS_HOST:-$(hostname -f)} VOMS_LOCK_FILE=/var/lock/subsys/voms.$VOMS_VO -echo VOMS_HOST=$VOMS_HOST -echo VOMS_PORT=$VOMS_PORT -echo VOMS_VO=$VOMS_VO -echo VOMS_LOCK_FILE=$VOMS_LOCK_FILE - - +echo VOMS_HOST="$VOMS_HOST" +echo VOMS_PORT="$VOMS_PORT" +echo VOMS_VO="$VOMS_VO" +echo VOMS_LOCK_FILE="$VOMS_LOCK_FILE" diff --git a/src/glite-info-service-voms-admin b/src/glite-info-service-voms-admin index e3592cc..5085f9f 100755 --- a/src/glite-info-service-voms-admin +++ b/src/glite-info-service-voms-admin @@ -4,15 +4,12 @@ # Host and port can be overridden by setting environment variables in the # wrapper script - -VOMS_ADMIN_HOST=${VOMS_ADMIN_HOST:-`hostname -f`} - +VOMS_ADMIN_HOST=${VOMS_ADMIN_HOST:-$(hostname -f)} VOMS_ADMIN_PORT=${VOMS_ADMIN_PORT:-8443} VOMS_ADMIN_PID_FILE=${VOMS_ADMIN_PID_FILE:-/var/run/tomcat5.pid} # Write to stdout - will be imported by the info provider - -echo VOMS_ADMIN_PORT=$VOMS_ADMIN_PORT -echo VOMS_ADMIN_HOST=$VOMS_ADMIN_HOST -echo VOMS_ADMIN_PID_FILE=$VOMS_ADMIN_PID_FILE +echo VOMS_ADMIN_PORT="$VOMS_ADMIN_PORT" +echo VOMS_ADMIN_HOST="$VOMS_ADMIN_HOST" +echo VOMS_ADMIN_PID_FILE="$VOMS_ADMIN_PID_FILE" diff --git a/src/glite-info-service-voms-wrapper b/src/glite-info-service-voms-wrapper index 5b9af0a..3a58448 100755 --- a/src/glite-info-service-voms-wrapper +++ b/src/glite-info-service-voms-wrapper @@ -3,23 +3,23 @@ # This is a wrapper for use on a VOMS server; it calls the info provider # once for each configured VO -if [ x$2 == "x" ]; then - echo Not enough arguments - echo "Usage: glite-info-service-voms-wrapper []" - exit 1 +if [ "$2" == "" ]; then + echo Not enough arguments + echo "Usage: glite-info-service-voms-wrapper []" + exit 1 fi config=$1 sitename=$2 # Construct the base UniqueID in the same format as the info provider -host=`hostname -f` -if [ x$host == "x" ]; then - echo "Error: hostname -f returned a null string" - exit 99 +host=$(hostname -f) +if [ "$host" == "" ]; then + echo "Error: hostname -f returned a null string" + exit 99 fi -check=`cksum $config | cut -d" " -f 1` +check=$(cksum "$config" | cut -d" " -f 1) uniqueid=${3:-${host}_org.glite.voms_${check}} # The arguments are the same as for the info provider itself, i.e. @@ -28,19 +28,14 @@ uniqueid=${3:-${host}_org.glite.voms_${check}} # Get the list of configured VOs (plus any other directories which happen # to be in the voms directory!) -vos=`find /etc/voms/ -type d -printf "%f "` - -for vo in $vos ; do - -# Real VOs will have a voms.conf file in the directory - if test -f /etc/voms/$vo/voms.conf ; then - -# Set a variable to define the VO for this invocation - export GLITE_INFO_SERVICE_VO=$vo -# The UniqueID needs to have the VO name appended to make it unique - glite-info-service $config $sitename ${uniqueid}_$vo - - fi +vos=$(find /etc/voms/ -type d -printf "%f ") +for vo in $vos; do + # Real VOs will have a voms.conf file in the directory + if test -f "/etc/voms/$vo/voms.conf"; then + # Set a variable to define the VO for this invocation + export GLITE_INFO_SERVICE_VO="$vo" + # The UniqueID needs to have the VO name appended to make it unique + glite-info-service "$config" "$sitename" "${uniqueid}_${vo}" + fi done - diff --git a/src/glite-info-service-wmproxy b/src/glite-info-service-wmproxy deleted file mode 100755 index c4cb6dc..0000000 --- a/src/glite-info-service-wmproxy +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -# init function for the WMProxy service publisher, to export some variables - -# Updated for EMI locations: SB 20/7/11 (will no longer work with a gLite WMS) - -WMPROXY_PORT_DEFAULT=${WMPROXY_PORT:-7443} -WMPROXY_HOST_DEFAULT=${WMPROXY_HOST:-`hostname -f`} - -WMPROXY_CONF=${WMPROXY_CONF:-/etc/glite-wms/glite_wms_wmproxy_httpd.conf} - -WMS_LOCATION_VAR=${WMS_LOCATION_VAR:-/var} - -# The greps here may be fragile - -# eval here for safety, not currently needed -eval WMPROXY_PORT=`grep ^Listen $WMPROXY_CONF | cut -d" " -f2` -WMPROXY_PORT=${WMPROXY_PORT:-${WMPROXY_PORT_DEFAULT}} - -eval WMPROXY_HOST=`grep ^ServerName $WMPROXY_CONF | cut -d" " -f2 | cut -d: -f1` -WMPROXY_HOST=${WMPROXY_HOST:-${WMPROXY_HOST_DEFAULT}} - -# eval needed here because it needs a variable substitution -eval WMPROXY_PID_FILE=`grep ^PidFile $WMPROXY_CONF | cut -d" " -f2` -WMPROXY_PID_FILE=${WMPROXY_PID_FILE:-/var/httpd-wmproxy.pid} - -# The rpm to supply the version has changed -WMPROXY_RPM=glite-wms-wmproxy -rpm -q glite-wms-interface > /dev/null && WMPROXY_RPM=glite-wms-interface - -# Write to stdout - will be imported by the info provider - -echo WMPROXY_PORT=$WMPROXY_PORT -echo WMPROXY_HOST=$WMPROXY_HOST -echo WMPROXY_PID_FILE=$WMPROXY_PID_FILE -echo WMPROXY_RPM=$WMPROXY_RPM -