From: František Dvořák Date: Fri, 14 Dec 2012 15:04:07 +0000 (+0000) Subject: Proxyrenewal for Fedora - setup script and startup unit file. X-Git-Tag: merge_32_head_take_5_dst~3 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=f2e144fe1c5e770bf829dced0ce99146418fc47d;p=jra1mw.git Proxyrenewal for Fedora - setup script and startup unit file. --- diff --git a/org.glite.px.proxyrenewal/Makefile b/org.glite.px.proxyrenewal/Makefile index cf1eb7a..4a4dd0a 100644 --- a/org.glite.px.proxyrenewal/Makefile +++ b/org.glite.px.proxyrenewal/Makefile @@ -44,12 +44,22 @@ version=${module.version} VPATH:=${top_srcdir}/src:${top_srcdir}/examples SOURCES=\ - config/startup \ + config/glite-px config/setup config/startup config/systemd.* \ examples/*.c interface/*.h \ project/.post* project/.pre* project/doc_proxyrenewal.pl \ src/*.1 src/*.8 src/*.c src/*.h \ Makefile README -SOURCES_EXEC=config/startup project/doc_proxyrenewal.pl +SOURCES_EXEC=config/setup config/startup project/doc_proxyrenewal.pl + +ifeq ($(os_type),debian) +sysdefaultdir=${sysconfdir}/default +else +sysdefaultdir=${sysconfdir}/sysconfig +endif + +ifeq ($(os_type),fedora) +unitdir=`pkg-config systemd --variable=systemdsystemunitdir` +endif GLOBUS_NOTHR_INC:= -I${globus_prefix}/include/${nothrflavour} GLOBUS_THR_INC:= -I${globus_prefix}/include/${thrflavour} @@ -103,6 +113,7 @@ MAN1_GZ:=glite-proxy-renew.1.gz MAN8_GZ:=glite-proxy-renewd.8.gz MAN_GZ = ${MAN1_GZ} ${MAN8_GZ} MAN = $(MAN_GZ:.gz=) +SCRIPTS=glite-px setup startup THRLIBOBJ:=${LIBOBJ:.o=.thr.o} LIBLOBJ:=${LIBOBJ:.o=.lo} @@ -139,14 +150,20 @@ DAEMON:=glite-proxy-renewd CLIENT:=glite-proxy-renew EXAMPLES := renew_core -compile all: startup ${lib_LTLIBRARIES} ${DAEMON} ${CLIENT} ${MAN_GZ} +compile all: ${SCRIPTS} ${lib_LTLIBRARIES} ${DAEMON} ${CLIENT} ${MAN_GZ} -startup: ${top_srcdir}/config/startup +${SCRIPTS}: ${top_srcdir}/config/glite-px ${top_srcdir}/config/startup ${top_srcdir}/config/setup glite_var="${localstatedir}/glite"; \ if echo "${localstatedir}" | grep 'glite'>/dev/null; then \ glite_var="${localstatedir}"; \ fi; \ - sed -e 's:@glite_prefix@:${sysroot}${prefix}:' -e 's:@glite_etc@:${sysroot}${sysconfdir}:' -e "s:@glite_var@:$$glite_var:" $< > $@ + sed -e 's:@glite_prefix@:${sysroot}${prefix}:' -e 's:@glite_etc@:${sysroot}${sysconfdir}:' -e "s:@glite_var@:$$glite_var:" -e 's:@defaultdir@:${sysdefaultdir}:g' ${top_srcdir}/config/$@ > $@ +ifneq ($(os_type),debian) + sed -i 's/# \(Default-Start\|Default-Stop\):.*/# \1:/' $@ +endif + sed "s/^@$(os_type)@//" $@ > $@.tmp + grep -v '^@' $@.tmp > $@ + rm $@.tmp chmod +x $@ ifeq (${thrflavour},) @@ -197,16 +214,25 @@ check: examples: ${EXAMPLES} install: - -mkdir -p ${DESTDIR}${PREFIX}${prefix}/bin ${DESTDIR}${PREFIX}${prefix}/${libdir} ${DESTDIR}${PREFIX}${prefix}/include/glite/security/proxyrenewal ${DESTDIR}${PREFIX}${sysconfdir}/init.d ${DESTDIR}${PREFIX}${prefix}/share/man/man1 ${DESTDIR}${PREFIX}${prefix}/share/man/man8 + -mkdir -p ${DESTDIR}${PREFIX}${prefix}/bin ${DESTDIR}${PREFIX}${prefix}/sbin ${DESTDIR}${PREFIX}${prefix}/${libdir} ${DESTDIR}${PREFIX}${prefix}/include/glite/security/proxyrenewal ${DESTDIR}${PREFIX}${prefix}/share/man/man1 ${DESTDIR}${PREFIX}${prefix}/share/man/man8 ${DESTDIR}${PREFIX}${sysdefaultdir} ${DESTDIR}${PREFIX}${prefix}/share/doc/${package}-${version} ${INSTALL} -m 755 ${lib_LTLIBRARIES} ${DESTDIR}${PREFIX}${prefix}/${libdir} ${INSTALL} -m 755 ${DAEMON} ${CLIENT} ${DESTDIR}${PREFIX}${prefix}/bin + ${INSTALL} -m 755 setup ${DESTDIR}${PREFIX}${prefix}/sbin/glite-proxy-setup cd ${top_srcdir}/interface && ${INSTALL} -m 644 renewal.h renewal_core.h ${DESTDIR}${PREFIX}${prefix}/include/glite/security/proxyrenewal - ${INSTALL} -m 755 startup ${DESTDIR}${PREFIX}${sysconfdir}/init.d/glite-proxy-renewald ${INSTALL} -m 644 ${MAN1_GZ} ${DESTDIR}${PREFIX}${prefix}/share/man/man1 ${INSTALL} -m 644 ${MAN8_GZ} ${DESTDIR}${PREFIX}${prefix}/share/man/man8 + ${INSTALL} -m 644 glite-px ${DESTDIR}${PREFIX}${prefix}/share/doc/${package}-${version}/glite-px + ${INSTALL} -m 644 glite-px ${DESTDIR}${PREFIX}${sysdefaultdir} +ifeq ($(os_type),fedora) + mkdir -p ${DESTDIR}${PREFIX}${unitdir} + ${INSTALL} -m 644 ${top_srcdir}/config/systemd.proxy-renewd ${DESTDIR}${PREFIX}${unitdir}/glite-proxy-renewd.service +else + mkdir -p ${DESTDIR}${PREFIX}${sysconfdir}/init.d + ${INSTALL} -m 755 startup ${DESTDIR}${PREFIX}${sysconfdir}/init.d/glite-proxy-renewald +endif clean: - $(RM) ${lib_LTLIBRARIES} $(DAEMON) $(CLIENT) $(EXAMPLES) *.o *.lo core startup + $(RM) ${lib_LTLIBRARIES} $(DAEMON) $(CLIENT) $(EXAMPLES) *.o *.lo core ${SCRIPTS} $(RM) ${MAN1_GZ} ${MAN8_GZ} $(RM) -rf .libs $(RM) -rvf dist ${package}-*.tar.gz diff --git a/org.glite.px.proxyrenewal/config/glite-px b/org.glite.px.proxyrenewal/config/glite-px new file mode 100644 index 0000000..0511d38 --- /dev/null +++ b/org.glite.px.proxyrenewal/config/glite-px @@ -0,0 +1,28 @@ +# +# setting for proxyrenewal +# +# 1. copy this file to @defaultdir@ +# 2. launch glite-proxy-setup when changing certificates locations +# +# + +# +# system settings +# + +#GLITE_LOCATION=@glite_prefix@ +#GLITE_LOCATION_ETC='@glite_etc@' +#GLITE_PX_LOCATION_VAR='@glite_var@' + +# CA certificates directory +#X509_CERT_DIR='/etc/grid-security/certificates' +# VOMS directory +#X509_VOMS_DIR='/etc/grid-security/vomsdir' +#GLITE_HOST_CERT='/var/glite/.certs/hostcert.pem' +#GLITE_HOST_KEY='/var/glite/.certs/hostkey.pem' + +# +# additional options +# + +#GLITE_PROXY_RENEWD_OPTIONS= diff --git a/org.glite.px.proxyrenewal/config/setup b/org.glite.px.proxyrenewal/config/setup new file mode 100755 index 0000000..33aa098 --- /dev/null +++ b/org.glite.px.proxyrenewal/config/setup @@ -0,0 +1,193 @@ +#!/bin/sh + +[ -f /etc/profile.d/grid-env.sh ] && . /etc/profile.d/grid-env.sh +[ -f @defaultdir@/glite-lb ] && . @defaultdir@/glite-lb + +GLITE_LOCATION=${GLITE_LOCATION:-'@glite_prefix@'} +GLITE_LOCATION_ETC=${GLITE_LOCATION_ETC:-'@glite_etc@'} +GLITE_USER=${GLITE_USER:-'glite'} + +GLITE_HOME=`getent passwd ${GLITE_USER} | cut -d: -f6` +GLITE_HOST_CERT=${GLITE_HOST_CERT:-"$GLITE_HOME/.certs/hostcert.pem"} +GLITE_HOST_KEY=${GLITE_HOST_KEY:-"$GLITE_HOME/.certs/hostkey.pem"} + + +NAME="glite-px-setup" +ACTIONS="certs crl startup" + + +qecho() { + if test "$quiet" != "1"; then + echo "$NAME: $@" + fi +} + + +setup_all() { + setup_certs=1 + setup_emir=1 + setup_crl=1 + setup_startup=1 +} + + +while test -n "$1"; do + case "$1" in + -h|--help|help) + cat </dev/null; then + : + else + /sbin/service fetch-crl-cron start + /sbin/chkconfig fetch-crl-cron on + fi + else + echo "$NAME: WARNING: fetch-crl not found, fetching won't be configured" + fi +fi + + +# ==== startup ==== + +if test "$setup_startup" = "1"; then + if test ! -x $GLITE_LOCATION/bin/glite-proxy-renewd; then + echo "$NAME: ERROR: glite-proxy-renewd not installed" + startup_error=1 + fi + if test "$startup_error" = "1"; then + error="$error startup" + fi +fi +if test "$setup_startup" = "1" -a "$startup_error" != "1"; then +@fedora@ systemd_unitdir=`pkg-config systemd --variable=systemdsystemunitdir` +@fedora@ systemd_confdir=`pkg-config systemd --variable=systemdsystemconfdir` +@fedora@ sed -e "s|\(X509_USER_CERT\).*|\1=$GLITE_HOST_CERT|" \ +@fedora@ -e "s|\(X509_USER_KEY\).*|\1=$GLITE_HOST_KEY|" \ +@fedora@ $systemd_unitdir/glite-proxy-renewd.service > $systemd_confdir/glite-proxy-renewd.service +@fedora@ systemctl --system daemon-reload +@fedora@ +@fedora@ systemctl enable glite-proxy-renewd.service +@fedora@ +@fedora@ startup_error=0 +@fedora@ systemctl restart glite-proxy-renewd.service || startup_error=1 +@debian@ update-rc.d glite-proxy-renewd defaults +@debian@ +@debian@ startup_error=0 +@debian@ $GLITE_LOCATION_ETC/init.d/glite-proxy-renewald restart || startup_error=1 +@redhat@ /sbin/chkconfig glite-proxy-renewald on +@redhat@ +@redhat@ startup_error=0 +@redhat@ /sbin/service glite-proxy-renewald restart || startup_error=1 + + if test "$startup_error" = "0"; then + qecho "Services started successfully" + else + echo "$NAME: ERROR: Some services failed to start" + error="$error startup" + fi +fi + + +# ==== the end ==== + +if test -z "$error"; then + true +else + echo "$NAME: ERROR: $error" + false +fi diff --git a/org.glite.px.proxyrenewal/config/startup b/org.glite.px.proxyrenewal/config/startup index 6509410..e261cdb 100755 --- a/org.glite.px.proxyrenewal/config/startup +++ b/org.glite.px.proxyrenewal/config/startup @@ -26,14 +26,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -GLITE_PX_LOCATION=${GLITE_PX_LOCATION:-'@glite_prefix@'} -GLITE_PX_LOCATION_ETC=${GLITE_PX_LOCATION_ETC:-'@glite_etc@'} -GLITE_PX_LOCATION_VAR=${GLITE_PX_LOCATION_VAR:-'@glite_var@'} - [ -f /etc/profile.d/grid-env.sh ] && . /etc/profile.d/grid-env.sh -[ -f /etc/glite.conf ] && . /etc/glite.conf -[ -f $GLITE_PX_LOCATION_ETC/glite-wms.conf ] && . $GLITE_PX_LOCATION_ETC/glite-wms.conf -[ -f $HOME/.glite.conf ] && . $HOME/.glite.conf +[ -f @defaultdir@/glite-px ] && . @defaultdir@/glite-px + +GLITE_LOCATION=${GLITE_LOCATION:-'@glite_prefix@'} +GLITE_LOCATION_ETC=${GLITE_LOCATION_ETC:-'@glite_etc@'} +GLITE_PX_LOCATION_VAR=${GLITE_PX_LOCATION_VAR:-'@glite_var@'} PROXY_REPOSITORY="$GLITE_PX_LOCATION_VAR/spool/glite-renewd" @@ -79,8 +77,8 @@ start() fi su - $GLITE_USER -c "VOMS_USERCONF=$user_voms_config \ - $GLITE_PX_LOCATION/bin/glite-proxy-renewd \ - -r $PROXY_REPOSITORY $creds -A" + $GLITE_LOCATION/bin/glite-proxy-renewd \ + -r $PROXY_REPOSITORY $creds -A $GLITE_PROXY_RENEWD_OPTIONS" if [ $? -eq 0 ]; then echo " done" diff --git a/org.glite.px.proxyrenewal/config/systemd.proxy-renewd b/org.glite.px.proxyrenewal/config/systemd.proxy-renewd new file mode 100644 index 0000000..8dfc40a --- /dev/null +++ b/org.glite.px.proxyrenewal/config/systemd.proxy-renewd @@ -0,0 +1,21 @@ +[Unit] +Description=Proxy renewal daemon +Documentation=man:glite-proxy-renewd(8) +After=network.target + +[Service] +Type=forking +User=glite +Group=glite +Environment=X509_USER_CERT=/var/glite/.certs/hostcert.pem +Environment=X509_USER_KEY=/var/glite/.certs/hostkey.pem +# workaround for VOMS_FindByVO that seems to always require user's own VOMS config file (savannach bug #7511) +Environment=VOMS_USERCONF=/tmp/renewal_vomses +EnvironmentFile=-/etc/profile.d/grid-env.sh +EnvironmentFile=-/etc/sysconfig/glite-px +ExecStartPre=/usr/bin/touch /tmp/renewal_vomses +ExecStartPre=/usr/bin/chmod 644 /tmp/renewal_vomses +ExecStart=/usr/bin/glite-proxy-renewd -A $GLITE_PROXY_RENEWD_OPTIONS + +[Install] +WantedBy=multi-user.target diff --git a/org.glite.px.proxyrenewal/project/debian.glite-px-proxyrenewal-progs.install b/org.glite.px.proxyrenewal/project/debian.glite-px-proxyrenewal-progs.install index 8f693dc..bb77eb3 100644 --- a/org.glite.px.proxyrenewal/project/debian.glite-px-proxyrenewal-progs.install +++ b/org.glite.px.proxyrenewal/project/debian.glite-px-proxyrenewal-progs.install @@ -1,3 +1,5 @@ +etc/default/* etc/init.d/* usr/bin/* +usr/sbin/* usr/share/man/man*/* diff --git a/org.glite.px.proxyrenewal/project/debian.rules b/org.glite.px.proxyrenewal/project/debian.rules index 9fc4fda..ffdc8ad 100644 --- a/org.glite.px.proxyrenewal/project/debian.rules +++ b/org.glite.px.proxyrenewal/project/debian.rules @@ -7,6 +7,7 @@ p_base=glite-px-proxyrenewal p_dbg=glite-px-proxyrenewal-dbg p_dev=libglite-security-proxyrenewal-dev p_lib=libglite-security-proxyrenewal1 +p_progs=glite-px-proxyrenewal-progs # Uncomment this to turn on verbose mode. export DH_VERBOSE=1 @@ -46,9 +47,11 @@ install: build-stamp mkdir -p debian/$(p_base)/usr/share/doc mkdir -p debian/$(p_dbg)/usr/share/doc mkdir -p debian/$(p_dev)/usr/share/doc + mkdir -p debian/$(p_progs)/usr/share/doc ln -s $(p_lib) debian/$(p_base)/usr/share/doc/$(p_base) ln -s $(p_lib) debian/$(p_dbg)/usr/share/doc/$(p_dbg) ln -s $(p_lib) debian/$(p_dev)/usr/share/doc/$(p_dev) + mv debian/tmp/usr/share/doc/glite-px-proxyrenewal-@MAJOR@.@MINOR@.@REVISION@ debian/$(p_progs)/usr/share/doc/$(p_progs) binary-indep: diff --git a/org.glite.px.proxyrenewal/project/glite-px-proxyrenewal.spec b/org.glite.px.proxyrenewal/project/glite-px-proxyrenewal.spec index aedfa2d..8bd4500 100644 --- a/org.glite.px.proxyrenewal/project/glite-px-proxyrenewal.spec +++ b/org.glite.px.proxyrenewal/project/glite-px-proxyrenewal.spec @@ -18,6 +18,16 @@ BuildRequires: pkgconfig BuildRequires: voms-devel%{?_isa} Requires: %{name}-devel%{?_isa} Requires: %{name}-progs +%if 0%{?fedora} +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd +BuildRequires: systemd +%else +Requires(post): chkconfig +Requires(preun): chkconfig +Requires(preun): initscripts +%endif Obsoletes: glite-security-proxyrenewal%{?_isa} <= 1.3.11-4 %description @@ -68,11 +78,14 @@ make check %install rm -rf $RPM_BUILD_ROOT -mkdir -p $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT +# documentation installed by %doc +rm -rf $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version} +%if ! 0%{?fedora} sed -i 's,\(lockfile=/var/lock\),\1/subsys,' $RPM_BUILD_ROOT/etc/init.d/glite-proxy-renewald mkdir $RPM_BUILD_ROOT/etc/rc.d mv $RPM_BUILD_ROOT/etc/init.d $RPM_BUILD_ROOT/etc/rc.d +%endif find $RPM_BUILD_ROOT -name '*.la' -exec rm -rf {} \; find $RPM_BUILD_ROOT -name '*.a' -exec rm -rf {} \; find $RPM_BUILD_ROOT -name '*' -print | xargs -I {} -i bash -c "chrpath -d {} > /dev/null 2>&1" || echo 'Stripped RPATH' @@ -97,23 +110,46 @@ exit 0 %post progs +%if 0%{?fedora} +if [ $1 -eq 1 ] ; then + # Initial installation + /bin/systemctl daemon-reload >/dev/null 2>&1 || : +fi +%else /sbin/chkconfig --add glite-proxy-renewald if [ $1 -eq 1 ] ; then /sbin/chkconfig glite-proxy-renewald off fi +%endif %preun progs +%if 0%{?fedora} +if [ $1 -eq 0 ] ; then + # Package removal, not upgrade + /bin/systemctl --no-reload disable glite-proxy-renewd.service > /dev/null 2>&1 || : + /bin/systemctl stop glite-proxy-renewd.service > /dev/null 2>&1 || : +fi +%else if [ $1 -eq 0 ] ; then /sbin/service glite-proxy-renewald stop >/dev/null 2>&1 /sbin/chkconfig --del glite-proxy-renewald fi +%endif %postun progs +%if 0%{?fedora} +/bin/systemctl daemon-reload >/dev/null 2>&1 || : +if [ $1 -ge 1 ] ; then + # Package upgrade, not uninstall + /bin/systemctl try-restart glite-proxy-renewd.service >/dev/null 2>&1 || : +fi +%else if [ "$1" -ge "1" ] ; then /sbin/service glite-proxy-renewald condrestart >/dev/null 2>&1 || : fi +%endif %files @@ -140,10 +176,16 @@ fi %defattr(-,root,root) %dir %attr(0755, glite, glite) %{_localstatedir}/glite %dir %attr(0700, glite, glite) %{_localstatedir}/spool/glite-renewd -%doc LICENSE project/ChangeLog README +%doc LICENSE project/ChangeLog README config/glite-px +%config(noreplace missingok) %{_sysconfdir}/sysconfig/glite-px +%if 0%{?fedora} +%{_unitdir}/glite-proxy-renewd.service +%else %{_initrddir}/glite-proxy-renewald +%endif %{_bindir}/glite-proxy-renew %{_bindir}/glite-proxy-renewd +%{_sbindir}/glite-proxy-setup %{_mandir}/man1/glite-proxy-renew.1.gz %{_mandir}/man8/glite-proxy-renewd.8.gz diff --git a/org.glite.px.proxyrenewal/src/renewal_locl.h b/org.glite.px.proxyrenewal/src/renewal_locl.h index 1fd483c..9fe0e7f 100644 --- a/org.glite.px.proxyrenewal/src/renewal_locl.h +++ b/org.glite.px.proxyrenewal/src/renewal_locl.h @@ -80,7 +80,7 @@ typedef enum { #define EDG_WLPR_MYPROXY_PORT 7512 -#define EDG_WLPR_REPOSITORY_ROOT "/var/spool/edg-wl-renewd" +#define EDG_WLPR_REPOSITORY_ROOT "/var/spool/glite-renewd" #define EDG_WLPR_BUF_SIZE 4096