From 587e28300913fc7d125df4f6297af00a5365cff8 Mon Sep 17 00:00:00 2001 From: Steve Traylen Date: Mon, 11 Aug 2008 13:05:33 +0000 Subject: [PATCH] Working version. --- org.glite.myproxy-config/Makefile | 35 ++++++ org.glite.myproxy-config/myproxy-config.spec | 45 ++++++++ org.glite.myproxy-config/myproxy-initd | 164 +++++++++++++++++++++++++++ 3 files changed, 244 insertions(+) create mode 100644 org.glite.myproxy-config/Makefile create mode 100644 org.glite.myproxy-config/myproxy-config.spec create mode 100644 org.glite.myproxy-config/myproxy-initd diff --git a/org.glite.myproxy-config/Makefile b/org.glite.myproxy-config/Makefile new file mode 100644 index 0000000..9ac7d65 --- /dev/null +++ b/org.glite.myproxy-config/Makefile @@ -0,0 +1,35 @@ +prefix=/ +package=myproxy-config +name=$Name$ +tag:=$(shell echo $(name) | sed 's/^[^:]*: //' ) +version:=$(shell echo "$(tag)" | sed 's/^.*R_//' | sed 's/_/\./g') +release:=$(shell echo "$(version)" | sed 's/.*\.//') +version:=$(shell echo "$(version)" | sed 's/\(.*\)\.[0-9]*/\1/') + +.PHONY: configure install clean rpm + +all: configure + +install: + @echo installing ... + @install -D -m 0755 myproxy-initd $(prefix)/etc/init.d/myproxy + +clean:: + rm -f *~ test/*~ etc/*~ doc/*~ src/*~ + rm -rf rpmbuild + +rpm: + @mkdir -p rpmbuild/RPMS/noarch + @mkdir -p rpmbuild/SRPMS/ + @mkdir -p rpmbuild/SPECS/ + @mkdir -p rpmbuild/SOURCES/ + @mkdir -p rpmbuild/BUILD/ + +ifneq ("$(tag)","ame:") + @sed -i 's/^Version:.*/Version: $(version)/' $(package).spec + @sed -i 's/^Release:.*/Release: $(release)/' $(package).spec +endif + @tar --gzip --exclude='*CVS*' -cf rpmbuild/SOURCES/${package}.tgz * + @rpmbuild -ba ${package}.spec + + diff --git a/org.glite.myproxy-config/myproxy-config.spec b/org.glite.myproxy-config/myproxy-config.spec new file mode 100644 index 0000000..01f8462 --- /dev/null +++ b/org.glite.myproxy-config/myproxy-config.spec @@ -0,0 +1,45 @@ +%define topdir %(pwd)/rpmbuild +%define _topdir %{topdir} +Summary: Provides an init.d script for MyProxy +Name: myproxy-config +Version: 2.0.0 +Release: 1 +License: EDG +Group: EGEE +Source0: %{name}.tgz +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root +BuildArch: noarch +Packager: Steve Traylen + +%description +Provides a startup init.d script for myproxy and nothing +else basically. + +%prep +%setup -c %{name} + +%build + + +%install +make install prefix=%{buildroot} + + +%clean +[ $RPM_BUILD_ROOT != / ] && rm -rf $RPM_BUILD_ROOT + + +%files +%defattr(-,root,root,-) +/etc/init.d/myproxy + + +%doc + + +%changelog +* Mon Aug 11 2008 Steve Tralyne +- Rewrite a little for Makefile and etics. +* Wed May 21 2008 Ulrich Schwickerath - config-1 +- Initial build. + diff --git a/org.glite.myproxy-config/myproxy-initd b/org.glite.myproxy-config/myproxy-initd new file mode 100644 index 0000000..8b311b6 --- /dev/null +++ b/org.glite.myproxy-config/myproxy-initd @@ -0,0 +1,164 @@ +#!/bin/bash +# +# SysV-style boot script for MyProxy +# +# chkconfig: 345 99 06 +# description: MyProxy online credential repository + +# source function library +. /etc/rc.d/init.d/functions + +### configuration + +GLOBUS_SYSCONFIG=${GLOBUS_SYSCONFIG:-/etc/sysconfig/globus} +if [ -f "$GLOBUS_SYSCONFIG" ]; then + . "$GLOBUS_SYSCONFIG" +fi + +GLOBUS_LOCATION=${GLOBUS_LOCATION:-/opt/globus} +if [ ! -d "$GLOBUS_LOCATION" ]; then + echo "GLOBUS_LOCATION not found" + exit 1 +fi +export GLOBUS_LOCATION +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GLOBUS_LOCATION/lib + +GLITE_LOCATION=${GLITE_LOCATION:-/opt/glite} +if [ ! -d "$GLITE_LOCATION" ]; then + echo "GLITE_LOCATION not found" + exit 1 +fi +export GLITE_LOCATION + +# Optional server configuration arguments, defaults shown commented out. +# Any parameter can be overridden in $MYPROXY_SYSCONFIG defined below. +#PORT="-p 7512" +PORT= +#CONFIG= +CONFIG=$GLITE_LOCATION/etc/myproxy-server.conf +#STORE="-s /var/myproxy" +STORE= +#VERBOSE= +VERBOSE=--verbose + +MYPROXY_SYSCONFIG=${MYPROXY_SYSCONFIG:-/etc/sysconfig/myproxy} +if [ -f "$MYPROXY_SYSCONFIG" ]; then + . "$MYPROXY_SYSCONFIG" +fi + +### main script + +prog="myproxy-server" +MYPROXY=$GLOBUS_LOCATION/sbin/$prog + +# check if executable exists +if [ ! -x $MYPROXY ] +then + echo "ERROR: $MYPROXY not present or not executable" + exit 2 +fi + +dn=` + openssl x509 -noout -subject -in \ + /etc/grid-security/hostcert.pem | sed 's-[^/]*--' +` +test=test-`date +%Y%m%d-%H%M%S`-$$ + +check_response() +{ + TIMEOUT=5 + check="MYPROXY_SERVER_DN=$dn ${GLOBUS_LOCATION}/bin/myproxy-info \ + -s `hostname` $PORT -l $test 2>&1 | grep -i credential > /dev/null" + + ( + perl -e ' + $SIG{"TTIN"} = "IGNORE"; + $SIG{"TTOU"} = "IGNORE"; + setpgrp(0, 0); + exec(@ARGV); + warn "could not exec $ARGV[0]: $!\n"; + exit(127); + ' sh -c "$check" & + ping=$! + + exec 2> /dev/null + + perl -e ' + sleep('"$TIMEOUT"'); + kill(-9, '"$ping"'); + ' & + watchdog=$! + + wait $ping + status=$? + # the bash kill command does not work properly on process groups + /bin/kill -9 $watchdog $ping -$ping + exit $status + ) +} + +case $1 in +start) + echo "Starting $prog" + + # the myproxy-server assumes it is started from inetd if its + # stdin is connected to a socket; by connecting stdin to /dev/null + # we avoid problems if stdin happened to be a socket by accident, + # as observed with actuators in the Lemon fabric monitoring system + + server="'$MYPROXY $PORT -c $CONFIG $STORE $VERBOSE < /dev/null'" + + for i in 1 2 3 + do + daemon sh -c "$server" + echo attempt $i - checking server response + + for j in 1 2 3 4 5 + do + sleep 1 + check_response && exit 0 + echo check $j failed + done + done + + echo "ERROR: $prog not responsive - check /var/log/messages" + exit 1 + ;; +stop) + echo -n "Shutting down $prog" + killproc ${prog} + rc=$? + echo + exit $rc + ;; +reload) + echo "Reconfiguring $prog" + + # as of version v4.2 the myproxy-server rereads its configuration file + # automatically on changes, so we do not have to do anything, besides + # ensuring that it actually is running + + $0 status && exit + $0 restart + exit + ;; +restart) + $0 stop + $0 start + exit + ;; +status) + status ${prog} + rc=$? + test $rc = 0 || exit $rc + + check_response && exit 0 + + echo "ERROR: $prog not responsive!" + exit 1 + ;; +*) + echo "Usage: $0 {start|stop|reload|restart|status}" + exit 2 +esac + -- 1.8.2.3