From: František Dvořák Date: Thu, 13 Dec 2012 13:35:51 +0000 (+0000) Subject: Starting unit files on Fedora: X-Git-Tag: merge_32_head_take_5_dst~6 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=47c8da8340d0ff75d89fef4c506d845b71c083a1;p=jra1mw.git Starting unit files on Fedora: - unit files for all deamons (user glite, requiring network for bind()) - proxy setup and certificate paths setup by changing the unit files - generate different setup script for each distribution (it simplifies the script) --- diff --git a/org.glite.lb.harvester/Makefile b/org.glite.lb.harvester/Makefile index 71a3587..e2e6da7 100644 --- a/org.glite.lb.harvester/Makefile +++ b/org.glite.lb.harvester/Makefile @@ -18,7 +18,7 @@ CC=gcc VPATH=${top_srcdir}/src:${top_srcdir}/doc SOURCES=\ - config/startup \ + config/systemd.* config/startup \ doc/* \ examples/test.* \ project/.post* project/.pre* \ @@ -48,6 +48,10 @@ else sysdefaultdir=${sysconfdir}/sysconfig endif +ifeq ($(os_type),fedora) +unitdir=`pkg-config systemd --variable=systemdsystemunitdir` +endif + ifneq ($(GLITE_LB_HARVESTER_WITH_LBU_DB),no) CPPFLAGS:=$(CPPFLAGS) -DWITH_LBU_DB=1 LIBS:=$(LIBS) -lglite_lbu_db @@ -91,7 +95,6 @@ install: compile ${DESTDIR}${PREFIX}${prefix}/share/doc/${package}-${version} \ ${DESTDIR}${PREFIX}${prefix}/share/glite \ ${DESTDIR}${PREFIX}${prefix}/share/man/man1 \ - ${DESTDIR}${PREFIX}${sysconfdir}/init.d \ ${DESTDIR}${PREFIX}${sysconfdir}/glite-lb ${INSTALL} -m 755 harvester ${DESTDIR}${PREFIX}${prefix}/bin/glite-lb-harvester ${INSTALL} -m 755 harvester-dbg ${DESTDIR}${PREFIX}${prefix}/${libdir}/glite-lb/examples/glite-lb-harvester-dbg @@ -99,7 +102,13 @@ install: compile ${INSTALL} -m 444 ${top_srcdir}/examples/test.sql ${DESTDIR}${PREFIX}${prefix}/share/glite/glite-lb-harvester-test-dbsetup.sql ${INSTALL} -m 444 ${top_srcdir}/doc/README ${DESTDIR}${PREFIX}${prefix}/share/doc/${package}-${version} ${INSTALL} -m 444 glite-lb-harvester.1 ${DESTDIR}${PREFIX}${prefix}/share/man/man1 +ifeq ($(os_type),fedora) + mkdir -p ${DESTDIR}${PREFIX}${unitdir} + ${INSTALL} -m 644 ${top_srcdir}/config/systemd.harvester ${DESTDIR}${PREFIX}${unitdir}/glite-lb-harvester.service +else + mkdir -p ${DESTDIR}${PREFIX}${sysconfdir}/init.d ${INSTALL} -m 755 startup ${DESTDIR}${PREFIX}${sysconfdir}/init.d/glite-lb-harvester +endif clean: rm -rfv *.o *.lo *.loT .libs/ manpage.links manpage.refs *.log diff --git a/org.glite.lb.harvester/config/systemd.harvester b/org.glite.lb.harvester/config/systemd.harvester new file mode 100644 index 0000000..d719cb5 --- /dev/null +++ b/org.glite.lb.harvester/config/systemd.harvester @@ -0,0 +1,21 @@ +[Unit] +Description=Enhanced gLite Logging and Bookkeeping notification client +Documentation=man:glite-lb-setup(8) http://egee.cesnet.cz/en/JRA1/LB/documentation.php + +[Service] +Type=forking +User=glite +Group=glite +Environment=KRB5_KTNAME=FILE:/var/glite/krb5kt_lb +Environment=KRB5CCNAME=FILE:/var/glite/krb5cc_lb +Environment=LOG4C_RCPATH=/etc/glite-lb +Environment=X509_USER_CERT=/var/glite/.certs/hostcert.pem +Environment=X509_USER_KEY=/var/glite/.certs/hostkey.pem +EnvironmentFile=-/etc/profile.d/grid-env.sh +EnvironmentFile=-/etc/sysconfig/glite-lb +PIDFile=/var/run/glite/glite-lb-harvester.pid +# '-m $GLITE_LB_HARVESTER_DBCS' or '-c /etc/glite-lb-harvester.conf' in $GLITE_LB_HARVESTER_OPTIONS required if we want to do something +ExecStart=/usr/bin/glite-lb-harvester $GLITE_LB_HARVESTER_OPTIONS + +[Install] +WantedBy=multi-user.target diff --git a/org.glite.lb.harvester/project/glite-lb-harvester.spec b/org.glite.lb.harvester/project/glite-lb-harvester.spec index cccd592..36a1e2d 100644 --- a/org.glite.lb.harvester/project/glite-lb-harvester.spec +++ b/org.glite.lb.harvester/project/glite-lb-harvester.spec @@ -21,9 +21,16 @@ BuildRequires: glite-lbjp-common-log-devel BuildRequires: glite-lbjp-common-trio-devel BuildRequires: libtool BuildRequires: pkgconfig +%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 %description @DESCRIPTION@ @@ -47,9 +54,11 @@ rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT install -m 0644 LICENSE project/ChangeLog $RPM_BUILD_ROOT/usr/share/doc/%{name}-%{version} +%if ! 0%{?fedora} sed -i 's,\(lockfile=/var/lock\),\1/subsys,' $RPM_BUILD_ROOT/etc/init.d/glite-lb-harvester 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 '*' -print | xargs -I {} -i bash -c "chrpath -d {} > /dev/null 2>&1" || echo 'Stripped RPATH' mkdir -p $RPM_BUILD_ROOT/var/glite mkdir -p $RPM_BUILD_ROOT/var/run/glite @@ -67,23 +76,49 @@ exit 0 %post +%if 0%{?fedora} +# Fedora 18: systemd_post glite-lb-harvester.service +if [ $1 -eq 1 ] ; then + # Initial installation + /bin/systemctl daemon-reload >/dev/null 2>&1 || : +fi +%else /sbin/chkconfig --add glite-lb-harvester if [ $1 -eq 1 ] ; then /sbin/chkconfig glite-lb-harvester off fi +%endif %preun +%if 0%{?fedora} +# Fedora 18: systemd_preun glite-lb-harvester.service +if [ $1 -eq 0 ] ; then + # Package removal, not upgrade + /bin/systemctl --no-reload disable glite-lb-harvester.service > /dev/null 2>&1 || : + /bin/systemctl stop glite-lb-harvester.service > /dev/null 2>&1 || : +fi +%else if [ $1 -eq 0 ] ; then /sbin/service glite-lb-harvester stop >/dev/null 2>&1 /sbin/chkconfig --del glite-lb-harvester fi +%endif %postun +%if 0%{?fedora} +# Fedora 18: systemd_postun_with_restart glite-lb-harvester.service +/bin/systemctl daemon-reload >/dev/null 2>&1 || : +if [ $1 -ge 1 ] ; then + # Package upgrade, not uninstall + /bin/systemctl try-restart glite-lb-harvester.service >/dev/null 2>&1 || : +fi +%else if [ "$1" -ge "1" ] ; then /sbin/service glite-lb-harvester condrestart >/dev/null 2>&1 || : fi +%endif %files @@ -96,7 +131,11 @@ fi %dir %{_libdir}/glite-lb/examples/ %dir %{_datadir}/glite/ %ghost %{_localstatedir}/run/glite/glite-lb-harvester.pid +%if 0%{?fedora} +%{_unitdir}/glite-lb-harvester.service +%else %{_initrddir}/glite-lb-harvester +%endif %{_bindir}/glite-lb-harvester %{_libdir}/glite-lb/examples/glite-lb-harvester-test.sh %{_libdir}/glite-lb/examples/glite-lb-harvester-dbg diff --git a/org.glite.lb.logger/Makefile b/org.glite.lb.logger/Makefile index a284f2b..0ab0db8 100644 --- a/org.glite.lb.logger/Makefile +++ b/org.glite.lb.logger/Makefile @@ -21,7 +21,7 @@ CC=gcc VPATH:=${top_srcdir}/src:${top_srcdir}/test:${top_srcdir}/doc SOURCES=\ - config/startup config/glite-lb-logger.* \ + config/startup config/glite-lb-logger.* config/systemd.* \ doc/*.8 \ interface/*.h \ project/.post* project/.pre* \ @@ -74,6 +74,10 @@ else sysdefaultdir=${sysconfdir}/sysconfig endif +ifeq ($(os_type),fedora) +unitdir=`pkg-config systemd --variable=systemdsystemunitdir` +endif + DEBUG:=-g -O0 CFLAGS:=${DEBUG} \ -I${stagedir}${prefix}/include -I${top_srcdir}/src -I${top_srcdir}/interface \ @@ -218,7 +222,6 @@ check.il: ${INTERLOG_TEST_OBJS} install: -mkdir -p ${DESTDIR}${PREFIX}${prefix}/bin - -mkdir -p ${DESTDIR}${PREFIX}${sysconfdir}/init.d -mkdir -p ${DESTDIR}${PREFIX}${prefix}/share/man/man8 -mkdir -p ${DESTDIR}${PREFIX}${prefix}/include/glite/lb ${INSTALL} -m 755 ${LOGD} ${DESTDIR}${PREFIX}${prefix}/bin @@ -230,9 +233,18 @@ ifdef LB_PERF ${INSTALL} -m 755 ${top_srcdir}/src/perftest_ll.sh ${DESTDIR}${PREFIX}${prefix}/sbin ${INSTALL} -m 755 ${top_srcdir}/src/perftest_il.sh ${DESTDIR}${PREFIX}${prefix}/sbin endif - ${INSTALL} -m 755 startup ${DESTDIR}${PREFIX}${sysconfdir}/init.d/glite-lb-locallogger ( cd ${top_srcdir}/interface && ${INSTALL} -m 644 ${HDRS} ${DESTDIR}${PREFIX}${prefix}/include/${globalprefix}/${lbprefix} ) ${INSTALL} -m 644 ${MAN_GZ} ${DESTDIR}${PREFIX}${prefix}/share/man/man8 +ifeq ($(os_type),fedora) + mkdir -p ${DESTDIR}${PREFIX}${unitdir} + install -m 644 ${top_srcdir}/config/systemd.logd ${DESTDIR}${PREFIX}${unitdir}/glite-lb-logd.service + install -m 644 ${top_srcdir}/config/systemd.interlogd ${DESTDIR}${PREFIX}${unitdir}/glite-lb-interlogd.service + install -m 644 ${top_srcdir}/config/systemd.notif-interlogd ${DESTDIR}${PREFIX}${unitdir}/glite-lb-notif-interlogd.service + install -m 644 ${top_srcdir}/config/systemd.proxy-interlogd ${DESTDIR}${PREFIX}${unitdir}/glite-lb-proxy-interlogd.service +else + -mkdir -p ${DESTDIR}${PREFIX}${sysconfdir}/init.d + ${INSTALL} -m 755 startup ${DESTDIR}${PREFIX}${sysconfdir}/init.d/glite-lb-locallogger +endif ${INTERLOG_NOTIF_OBJS}: %.notif.lo: %.c ${COMPILE} ${CFLAGS} -DIL_NOTIFICATIONS -c $< -o $@ diff --git a/org.glite.lb.logger/config/systemd.interlogd b/org.glite.lb.logger/config/systemd.interlogd new file mode 100644 index 0000000..1bfe52b --- /dev/null +++ b/org.glite.lb.logger/config/systemd.interlogd @@ -0,0 +1,20 @@ +[Unit] +Description=gLite Logging and Bookkeeping interlogger +Documentation=man:glite-lb-setup(8) http://egee.cesnet.cz/en/JRA1/LB/documentation.php + +[Service] +Type=forking +User=glite +Group=glite +Environment=KRB5_KTNAME=FILE:/var/glite/krb5kt_lb +Environment=KRB5CCNAME=FILE:/var/glite/krb5cc_lb +Environment=LOG4C_RCPATH=/etc/glite-lb +Environment=X509_USER_CERT=/var/glite/.certs/hostcert.pem +Environment=X509_USER_KEY=/var/glite/.certs/hostkey.pem +EnvironmentFile=-/etc/profile.d/grid-env.sh +EnvironmentFile=-/etc/sysconfig/glite-lb +PIDFile=/var/run/glite/glite-lb-interlogd.pid +ExecStart=/usr/bin/glite-lb-interlogd $GLITE_LB_INTERLOGD_OPTIONS + +[Install] +WantedBy=multi-user.target diff --git a/org.glite.lb.logger/config/systemd.logd b/org.glite.lb.logger/config/systemd.logd new file mode 100644 index 0000000..447f76a --- /dev/null +++ b/org.glite.lb.logger/config/systemd.logd @@ -0,0 +1,21 @@ +[Unit] +Description=gLite Logging and Bookkeeping local logger +Documentation=man:glite-lb-setup(8) http://egee.cesnet.cz/en/JRA1/LB/documentation.php +After=network.target + +[Service] +Type=forking +User=glite +Group=glite +Environment=KRB5_KTNAME=FILE:/var/glite/krb5kt_lb +Environment=KRB5CCNAME=FILE:/var/glite/krb5cc_lb +Environment=LOG4C_RCPATH=/etc/glite-lb +Environment=X509_USER_CERT=/var/glite/.certs/hostcert.pem +Environment=X509_USER_KEY=/var/glite/.certs/hostkey.pem +EnvironmentFile=-/etc/profile.d/grid-env.sh +EnvironmentFile=-/etc/sysconfig/glite-lb +PIDFile=/var/run/glite/glite-lb-logd.pid +ExecStart=/usr/bin/glite-lb-logd $GLITE_LB_LOGD_OPTIONS + +[Install] +WantedBy=multi-user.target diff --git a/org.glite.lb.logger/config/systemd.notif-interlogd b/org.glite.lb.logger/config/systemd.notif-interlogd new file mode 100644 index 0000000..7f9cd61 --- /dev/null +++ b/org.glite.lb.logger/config/systemd.notif-interlogd @@ -0,0 +1,20 @@ +[Unit] +Description=gLite Logging and Bookkeeping notification interlogger +Documentation=man:glite-lb-setup(8) http://egee.cesnet.cz/en/JRA1/LB/documentation.php + +[Service] +Type=forking +User=glite +Group=glite +Environment=KRB5_KTNAME=FILE:/var/glite/krb5kt_lb +Environment=KRB5CCNAME=FILE:/var/glite/krb5cc_lb +Environment=LOG4C_RCPATH=/etc/glite-lb +Environment=X509_USER_CERT=/var/glite/.certs/hostcert.pem +Environment=X509_USER_KEY=/var/glite/.certs/hostkey.pem +EnvironmentFile=-/etc/profile.d/grid-env.sh +EnvironmentFile=-/etc/sysconfig/glite-lb +PIDFile=/var/run/glite/glite-lb-notif-interlogd.pid +ExecStart=/usr/bin/glite-lb-notif-interlogd -M 10485760 $GLITE_LB_NOTIF_IL_OPTIONS + +[Install] +WantedBy=multi-user.target diff --git a/org.glite.lb.logger/config/systemd.proxy-interlogd b/org.glite.lb.logger/config/systemd.proxy-interlogd new file mode 100644 index 0000000..6248bf7 --- /dev/null +++ b/org.glite.lb.logger/config/systemd.proxy-interlogd @@ -0,0 +1,20 @@ +[Unit] +Description=gLite Logging and Bookkeeping interlogger for proxy +Documentation=man:glite-lb-setup(8) http://egee.cesnet.cz/en/JRA1/LB/documentation.php + +[Service] +Type=forking +User=glite +Group=glite +Environment=KRB5_KTNAME=FILE:/var/glite/krb5kt_lb +Environment=KRB5CCNAME=FILE:/var/glite/krb5cc_lb +Environment=LOG4C_RCPATH=/etc/glite-lb +Environment=X509_USER_CERT=/var/glite/.certs/hostcert.pem +Environment=X509_USER_KEY=/var/glite/.certs/hostkey.pem +EnvironmentFile=-/etc/profile.d/grid-env.sh +EnvironmentFile=-/etc/sysconfig/glite-lb +PIDFile=/var/run/glite/glite-lb-proxy-interlogd.pid +ExecStart=/usr/bin/glite-lb-proxy-interlogd $GLITE_LB_PROXY_IL_OPTIONS + +[Install] +WantedBy=multi-user.target diff --git a/org.glite.lb.logger/project/glite-lb-logger.spec b/org.glite.lb.logger/project/glite-lb-logger.spec index 061ffa1..83c08f3 100644 --- a/org.glite.lb.logger/project/glite-lb-logger.spec +++ b/org.glite.lb.logger/project/glite-lb-logger.spec @@ -19,9 +19,15 @@ BuildRequires: glite-lbjp-common-trio-devel%{?_isa} BuildRequires: glite-lbjp-common-log-devel%{?_isa} BuildRequires: libtool BuildRequires: pkgconfig +%if 0%{?fedora} Requires(post): chkconfig Requires(preun): chkconfig Requires(preun): initscripts +%else +Requires(post): chkconfig +Requires(preun): chkconfig +Requires(preun): initscripts +%endif %description @DESCRIPTION@ @@ -56,9 +62,11 @@ make check rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT +%if ! 0%{?fedora} sed -i 's,\(lockfile=/var/lock\),\1/subsys,' $RPM_BUILD_ROOT/etc/init.d/glite-lb-locallogger 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 '*' -print | xargs -I {} -i bash -c "chrpath -d {} > /dev/null 2>&1" || echo 'Stripped RPATH' mkdir -p $RPM_BUILD_ROOT/var/glite mkdir -p $RPM_BUILD_ROOT/var/run/glite @@ -85,23 +93,64 @@ exit 0 %post +%if 0%{?fedora} +# Fedora 18: systemd_post glite-lb-....service +if [ $1 -eq 1 ] ; then + # Initial installation + /bin/systemctl daemon-reload >/dev/null 2>&1 || : +fi +%else /sbin/chkconfig --add glite-lb-locallogger if [ $1 -eq 1 ] ; then /sbin/chkconfig glite-lb-locallogger off fi +%endif %preun +%if 0%{?fedora} +# Fedora 18: systemd_preun glite-lb-logd.service +# Fedora 18: systemd_preun glite-lb-interlogd.service +# Fedora 18: systemd_preun glite-lb-notif-interlogd.service +# Fedora 18: systemd_preun glite-lb-proxy-interlogd.service +if [ $1 -eq 0 ] ; then + # Package removal, not upgrade + /bin/systemctl --no-reload disable glite-lb-logd.service > /dev/null 2>&1 || : + /bin/systemctl --no-reload disable glite-lb-interlogd.service > /dev/null 2>&1 || : + /bin/systemctl --no-reload disable glite-lb-notif-interlogd.service > /dev/null 2>&1 || : + /bin/systemctl --no-reload disable glite-lb-proxy-interlogd.service > /dev/null 2>&1 || : + /bin/systemctl stop glite-lb-logd.service > /dev/null 2>&1 || : + /bin/systemctl stop glite-lb-interlogd.service > /dev/null 2>&1 || : + /bin/systemctl stop glite-lb-notif-interlogd.service > /dev/null 2>&1 || : + /bin/systemctl stop glite-lb-proxy-interlogd.service > /dev/null 2>&1 || : +fi +%else if [ $1 -eq 0 ] ; then /sbin/service glite-lb-locallogger stop >/dev/null 2>&1 /sbin/chkconfig --del glite-lb-locallogger fi +%endif %postun +%if 0%{?fedora} +# Fedora 18: systemd_postun_with_restart glite-lb-logd.service +# Fedora 18: systemd_postun_with_restart glite-lb-interlogd.service +# Fedora 18: systemd_postun_with_restart glite-lb-notif-interlogd.service +# Fedora 18: systemd_postun_with_restart glite-lb-proxy-interlogd.service +/bin/systemctl daemon-reload >/dev/null 2>&1 || : +if [ $1 -ge 1 ] ; then + # Package upgrade, not uninstall + /bin/systemctl try-restart glite-lb-logd.service >/dev/null 2>&1 || : + /bin/systemctl try-restart glite-lb-interlogd.service >/dev/null 2>&1 || : + /bin/systemctl try-restart glite-lb-notif-interlogd.service >/dev/null 2>&1 || : + /bin/systemctl try-restart glite-lb-proxy-interlogd.service >/dev/null 2>&1 || : +fi +%else if [ "$1" -ge "1" ] ; then /sbin/service glite-lb-locallogger condrestart >/dev/null 2>&1 || : fi +%endif %files @@ -120,7 +169,14 @@ fi %ghost %{_localstatedir}/run/glite/glite-lb-logd.pid %ghost %{_localstatedir}/run/glite/glite-lb-notif-interlogd.pid %ghost %{_localstatedir}/run/glite/glite-lb-proxy-interlogd.pid +%if 0%{?fedora} +%{_unitdir}//glite-lb-logd.service +%{_unitdir}//glite-lb-interlogd.service +%{_unitdir}//glite-lb-notif-interlogd.service +%{_unitdir}//glite-lb-proxy-interlogd.service +%else %{_initrddir}/glite-lb-locallogger +%endif %{_bindir}/glite-lb-interlogd %{_bindir}/glite-lb-logd %{_bindir}/glite-lb-notif-interlogd diff --git a/org.glite.lb.server/Makefile b/org.glite.lb.server/Makefile index 5cfd082..f0d55ef 100644 --- a/org.glite.lb.server/Makefile +++ b/org.glite.lb.server/Makefile @@ -27,7 +27,7 @@ default: all version=${module.version} SOURCES=\ - config/glite-lb* config/my.cnf config/*.conf config/startup config/setup \ + config/glite-lb* config/my.cnf config/*.conf config/startup config/setup config/systemd.* \ doc/*.1 doc/*.8 \ interface/*.h \ src/*.c src/*.cpp src/*.h src/*.c.T src/*.l src/*.y src/*.sh src/*.sh.in src/ws_typemap.dat \ @@ -66,6 +66,10 @@ else sysdefaultdir=${sysconfdir}/sysconfig endif +ifeq ($(os_type),fedora) +unitdir=`pkg-config systemd --variable=systemdsystemunitdir` +endif + GSOAP_FILES_PREFIX:= bk_ws_ YACC=bison -y @@ -333,6 +337,9 @@ ${SCRIPTS}: ${SCRIPTS_SRC} ifneq ($(os_type),debian) sed -i 's/# \(Default-Start\|Default-Stop\):.*/# \1:/' $@ endif + sed "s/^@$(os_type)@//" $@ > $@.tmp + grep -v '^@' $@.tmp > $@ + rm $@.tmp %.sh: %.sh.in glite_var="${localstatedir}/glite"; \ @@ -420,7 +427,7 @@ stage: compile $(MAKE) install PREFIX=${stagedir} DOSTAGE=yes install: - -mkdir -p ${DESTDIR}${PREFIX}${prefix}/bin ${DESTDIR}${PREFIX}${sysconfdir}/glite-lb ${DESTDIR}${PREFIX}${sysconfdir}/init.d + -mkdir -p ${DESTDIR}${PREFIX}${prefix}/bin ${DESTDIR}${PREFIX}${sysconfdir}/glite-lb -mkdir -p ${DESTDIR}${PREFIX}${prefix}/sbin -mkdir -p ${DESTDIR}${PREFIX}${prefix}/share/doc/${package}-${version} -mkdir -p ${DESTDIR}${PREFIX}${prefix}/share/glite @@ -450,7 +457,6 @@ install: ${INSTALL} -m 755 ${top_srcdir}/config/glite-lb-migrate_db2version40 ${DESTDIR}${PREFIX}${prefix}/sbin ${INSTALL} -m 644 ${top_srcdir}/config/site-notif.conf ${DESTDIR}${PREFIX}${sysconfdir}/glite-lb - ${INSTALL} -m 755 startup ${DESTDIR}${PREFIX}${sysconfdir}/init.d/glite-lb-bkserverd ${INSTALL} -m 755 setup ${DESTDIR}${PREFIX}${prefix}/sbin/glite-lb-setup ${INSTALL} -m 644 glite-lb-server-purge.cron ${DESTDIR}${PREFIX}${sysconfdir}/cron.d/glite-lb-server-purge ${INSTALL} -m 644 glite-lb-proxy-purge.cron ${DESTDIR}${PREFIX}${sysconfdir}/cron.d/glite-lb-proxy-purge @@ -464,6 +470,13 @@ install: ifdef LB_PERF ${INSTALL} -m 755 ${top_srcdir}/src/perftest_proxy.sh ${DESTDIR}${PREFIX}${prefix}/sbin endif +ifeq ($(os_type),fedora) + mkdir -p ${DESTDIR}${PREFIX}${unitdir} + install -m 644 ${top_srcdir}/config/systemd.bkserverd ${DESTDIR}${PREFIX}${unitdir}/glite-lb-bkserverd.service +else + mkdir -p ${DESTDIR}${PREFIX}${sysconfdir}/init.d + ${INSTALL} -m 755 startup ${DESTDIR}${PREFIX}${sysconfdir}/init.d/glite-lb-bkserverd +endif clean: rm -rvf *.c *.cpp *.h *.ch *.xh *.xml *.nsmap *.o *.lo .libs glite-lb-bkindex glite-lb-bkserverd glite-lb-mon-db ${STATIC_LIB_BK} ${LCAS_PLUGIN_LIB} ${TESTS} ${MAN_GZ} ${EXAMPLES} ${SCRIPTS} ${SCRIPTS2} ${MAN_GZ} diff --git a/org.glite.lb.server/config/setup b/org.glite.lb.server/config/setup index 7b96f26..4171608 100755 --- a/org.glite.lb.server/config/setup +++ b/org.glite.lb.server/config/setup @@ -17,7 +17,10 @@ GLITE_LB_AUTHZ_LOG_WMS_EVENTS=${GLITE_LB_AUTHZ_LOG_WMS_EVENTS:-'.*'} GLITE_LB_AUTHZ_LOG_CE_EVENTS=${GLITE_LB_AUTHZ_LOG_CE_EVENTS:-'.*'} GLITE_LB_AUTHZ_LOG_GENERAL_EVENTS=${GLITE_LB_AUTHZ_LOG_GENERAL_EVENTS:-'.*'} -GLITE_HOME_DIR=`getent passwd ${GLITE_USER} | cut -d: -f6` +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"} + ACTIONS="db certs msg authz harvester bdii emir upgrade crl startup krb krbgsi" @@ -234,7 +237,7 @@ if test "$setup_list" = "1"; then exit 0 fi -if test -z "$GLITE_HOME_DIR"; then +if test -z "$GLITE_HOME"; then echo "glite-lb-setup: ERROR: The home directory of ${GLITE_USER} doesn't exist. Check whether the user ${GLITE_USER} was properly created" exit 2 fi @@ -259,11 +262,9 @@ if test "$setup_db" = 1; then fi # restart for the new options - if test -x /sbin/service; then - out="`/sbin/service mysqld restart 2>&1`" - else - out="`/etc/init.d/mysql restart 2>&1`" - fi +@fedora@ out="`systemctl restart mysqld.service 2>&1`" +@redhat@ out="`/sbin/service mysqld restart 2>&1`" +@debian@ out="`/etc/init.d/mysql restart 2>&1`" if test $? -ne 0; then echo "$out" echo "glite-lb-setup: ERROR: starting MySQL failed" @@ -350,20 +351,20 @@ fi # ==== certificates ==== if test "$setup_certs" = "1"; then - if test ! -d $GLITE_HOME_DIR/.certs; then - mkdir -p $GLITE_HOME_DIR/.certs - chown $GLITE_USER:$GLITE_USER $GLITE_HOME_DIR/.certs + if test ! -d $GLITE_HOME/.certs; then + mkdir -p $GLITE_HOME/.certs + chown $GLITE_USER:$GLITE_USER $GLITE_HOME/.certs fi - cp -fp /etc/grid-security/hostcert.pem /etc/grid-security/hostkey.pem $GLITE_HOME_DIR/.certs/ + cp -fp /etc/grid-security/hostcert.pem /etc/grid-security/hostkey.pem $GLITE_HOME/.certs/ if test $? -eq 0; then - chown $GLITE_USER:$GLITE_USER $GLITE_HOME_DIR/.certs/hostcert.pem $GLITE_HOME_DIR/.certs/hostkey.pem - chmod 0644 $GLITE_HOME_DIR/.certs/hostcert.pem - chmod 0400 $GLITE_HOME_DIR/.certs/hostkey.pem - qecho "Certificates copied to $GLITE_HOME_DIR/.certs/" + chown $GLITE_USER:$GLITE_USER $GLITE_HOME/.certs/hostcert.pem $GLITE_HOME/.certs/hostkey.pem + chmod 0644 $GLITE_HOME/.certs/hostcert.pem + chmod 0400 $GLITE_HOME/.certs/hostkey.pem + qecho "Certificates copied to $GLITE_HOME/.certs/" else echo "glite-lb-setup: WARNING: Please copy host certificate and key into /etc/grid-security and" - echo " $GLITE_HOME_DIR/.certs/, change the owner of the ones in" - echo " $GLITE_HOME_DIR/.certs/ to $GLITE_USER" + echo " $GLITE_HOME/.certs/, change the owner of the ones in" + echo " $GLITE_HOME/.certs/ to $GLITE_USER" error="$error certs" fi fi @@ -415,7 +416,9 @@ fi if test "$setup_bdii" = "1"; then export INFO_SERVICE_CONFIG='/etc/glite/info/service' - if test -x /etc/init.d/bdii; then +@fedora@ if systemctl --all | grep bdii.service >/dev/null 2>&1; then +@redhat@ if test -x /etc/init.d/bdii; then +@debian@ if test -x /etc/init.d/bdii; then if test -f ${INFO_SERVICE_CONFIG}/glite-info-service-lbserver.conf.template -a -f ${INFO_SERVICE_CONFIG}/glite-info-glue2-lbserver.conf.template; then if test -n "`which sudo 2>/dev/null`"; then bdii=1 @@ -445,12 +448,11 @@ BDII_RAM_DISK= EOF sed -i "s#.*rootpw.*#rootpw ${BDII_PASSWD}#" /etc/bdii/bdii-slapd.conf - if test -x /sbin/service; then - /sbin/chkconfig bdii on - out="`/sbin/service bdii restart 2>&1`" - else - out="`/etc/init.d/bdii restart 2>&1`" - fi +@fedora@ systemctl enable bdii.service +@fedora@ out="`systemctl restart bdii.service 2>&1`" +@redhat@ /sbin/chkconfig bdii on +@redhat@ out="`/sbin/service bdii restart 2>&1`" +@debian@ out="`/etc/init.d/bdii restart 2>&1`" if test $? -eq 0; then qecho "BDII configured" else @@ -469,16 +471,9 @@ if test "$setup_emir" = "1"; then fi if test -n "`which emir-serp 2>/dev/null`"; then emir_daemon=emir-serp - emir_conf=emir-serp - emir_mult=1 - fi - if test -n "`which emird 2>/dev/null`"; then - emir_daemon=emird - emir_conf=emir - emir_mult=60 fi if test "$emir" != "0" -a -z "$emir_daemon"; then - echo "glite-lb-setup: WARNING: emir-serp (emird) not installed, EMIR won't be configured" + echo "glite-lb-setup: WARNING: emir-serp not installed, EMIR won't be configured" emir=0 fi fi @@ -539,14 +534,14 @@ $json "Service_ID": "`hostname -f`_lbserver", } EOF - period=$((4*$emir_mult)) - validity=$((24*$emir_mult)) + period=4 + validity=24 inifile=/etc/emi/$emir_daemon/$emir_daemon.ini if test ! -f $inifile.orig -a -f $inifile; then cp $inifile $inifile.orig fi cat > /etc/emi/$emir_daemon/$emir_daemon.ini << EOF -[$emir_conf] +[$emir_daemon] url = $EMIR_URL period = $period validity = $validity @@ -567,18 +562,11 @@ EOF fi # start the beast - if test -x /sbin/service; then - /sbin/chkconfig $emir_daemon on 2>/dev/null - # emird doesn't support chkconfig - if test $? -ne 0 && ! grep "$emir_daemon start" /etc/rc.local >/dev/null 2>&1; then - echo "/etc/init.d/$emir_daemon start" >> /etc/rc.local - chmod +x /etc/rc.local - qecho "$emir_daemon added to /etc/rc.local" - fi - out="`/sbin/service $emir_daemon restart 2>&1`" - else - out="`/etc/init.d/$emir_daemon restart 2>&1`" - fi +@fedora@ systemctl enable ${emir_daemon}.service +@fedora@ out="`systemctl restart ${emir_daemon}.service 2>&1`" +@redhat@ /sbin/chkconfig $emir_daemon on 2>/dev/null +@redhat@ out="`/sbin/service $emir_daemon restart 2>&1`" +@debian@ out="`/etc/init.d/$emir_daemon restart 2>&1`" if test $? -eq 0; then qecho "EMIR configured" else @@ -730,31 +718,95 @@ if test "$setup_startup" = "1"; then fi fi if test "$setup_startup" = "1" -a "$startup_error" != "1"; then - if egrep -i "Debian|Ubuntu" /etc/issue >/dev/null; then - update-rc.d glite-lb-bkserverd defaults - update-rc.d glite-lb-locallogger defaults - if test x"$GLITE_LB_HARVESTER_ENABLED" = x"true"; then - update-rc.d glite-lb-harvester defaults - fi - else - /sbin/chkconfig mysqld on - /sbin/chkconfig glite-lb-bkserverd on - /sbin/chkconfig glite-lb-locallogger on - if test x"$GLITE_LB_HARVETER_ENABLED" = x"true"; then - /sbin/chkconfig glite-lb-harvester on - fi - fi - - startup_error=0 - $GLITE_LOCATION_ETC/init.d/glite-lb-bkserverd restart || startup_error=1 - $GLITE_LOCATION_ETC/init.d/glite-lb-locallogger restart || startup_error=1 - if test x"$GLITE_LB_HARVESTER_ENABLED" = x"true"; then - $GLITE_LOCATION_ETC/init.d/glite-lb-harvester restart || startup_error=1 - else - if test -x $GLITE_LOCATION/bin/glite-lb-harvester; then - $GLITE_LOCATION_ETC/init.d/glite-lb-harvester stop >/dev/null - fi - fi +@fedora@ case "$GLITE_LB_TYPE" in +@fedora@ proxy) +@fedora@ GLITE_LB_SERVER_PROXY_OPTIONS="-P " +@fedora@ ;; +@fedora@ both) +@fedora@ GLITE_LB_SERVER_PROXY_OPTIONS="-B " +@fedora@ ;; +@fedora@ *) +@fedora@ GLITE_LB_SERVER_PROXY_OPTIONS="" +@fedora@ ;; +@fedora@ esac +@fedora@ +@fedora@ systemd_unitdir=`pkg-config systemd --variable=systemdsystemunitdir` +@fedora@ systemd_confdir=`pkg-config systemd --variable=systemdsystemconfdir` +@fedora@ for i in bkserverd logd interlogd notif-interlogd proxy-interlogd harvester; do +@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-lb-$i.service > $systemd_confdir/glite-lb-$i.service +@fedora@ done +@fedora@ sed -i -e "s|\$GLITE_LB_SERVER_PROXY_OPTIONS |$GLITE_LB_SERVER_PROXY_OPTIONS|" $systemd_confdir/glite-lb-bkserverd.service +@fedora@ systemctl --system daemon-reload +@fedora@ +@fedora@ systemctl enable mysqld.service +@fedora@ systemctl enable glite-lb-bkserverd.service +@fedora@ systemctl enable glite-lb-logd.service +@fedora@ systemctl enable glite-lb-interlogd.service +@fedora@ systemctl enable glite-lb-notif-interlogd.service +@fedora@ if test x"$GLITE_LB_TYPE" = x"proxy" -o x"$GLITE_LB_TYPE" = x"both"; then +@fedora@ systemctl enable glite-lb-proxy-interlogd.service +@fedora@ else +@fedora@ systemctl disable glite-lb-proxy-interlogd.service +@fedora@ fi +@fedora@ if test x"$GLITE_LB_HARVESTER_ENABLED" = x"true"; then +@fedora@ systemctl enable glite-lb-harvester.service +@fedora@ else +@fedora@ systemctl disable glite-lb-harvester.service +@fedora@ fi +@fedora@ +@fedora@ startup_error=0 +@fedora@ systemctl restart glite-lb-bkserverd.service || startup_error=1 +@fedora@ systemctl restart glite-lb-logd.service || startup_error=1 +@fedora@ systemctl restart glite-lb-interlogd.service || startup_error=1 +@fedora@ systemctl restart glite-lb-notif-interlogd.service || startup_error=1 +@fedora@ if test x"$GLITE_LB_TYPE" = x"proxy" -o x"$GLITE_LB_TYPE" = x"both"; then +@fedora@ systemctl restart glite-lb-proxy-interlogd.service || startup_error=1 +@fedora@ else +@fedora@ systemctl stop glite-lb-proxy-interlogd.service >/dev/null 2>&1 +@fedora@ fi +@fedora@ if test x"$GLITE_LB_HARVESTER_ENABLED" = x"true"; then +@fedora@ systemctl restart glite-lb-harvester.service || startup_error=1 +@fedora@ else +@fedora@ systemctl stop glite-lb-harvester.service >/dev/null 2>&1 +@fedora@ fi +@debian@ update-rc.d glite-lb-bkserverd defaults +@debian@ update-rc.d glite-lb-locallogger defaults +@debian@ update-rc.d glite-lb-harvester defaults +@debian@ update-rc.d glite-lb-bkserverd enable +@debian@ update-rc.d glite-lb-locallogger enable +@debian@ if test x"$GLITE_LB_HARVESTER_ENABLED" = x"true"; then +@debian@ update-rc.d glite-lb-harvester enable +@debian@ else +@debian@ update-rc.d glite-lb-harvester disable +@debian@ fi +@debian@ +@debian@ startup_error=0 +@debian@ $GLITE_LOCATION_ETC/init.d/glite-lb-bkserverd restart || startup_error=1 +@debian@ $GLITE_LOCATION_ETC/init.d/glite-lb-locallogger restart || startup_error=1 +@debian@ if test x"$GLITE_LB_HARVESTER_ENABLED" = x"true"; then +@debian@ $GLITE_LOCATION_ETC/init.d/glite-lb-harvester restart || startup_error=1 +@debian@ else +@debian@ $GLITE_LOCATION_ETC/init.d/glite-lb-harvester stop >/dev/null 2>&1 +@debian@ fi +@redhat@ /sbin/chkconfig mysqld on +@redhat@ /sbin/chkconfig glite-lb-bkserverd on +@redhat@ /sbin/chkconfig glite-lb-locallogger on +@redhat@ if test x"$GLITE_LB_HARVETER_ENABLED" = x"true"; then +@redhat@ /sbin/chkconfig glite-lb-harvester on +@redhat@ else +@redhat@ /sbin/chkconfig glite-lb-harvester off +@redhat@ fi +@redhat@ +@redhat@ startup_error=0 +@redhat@ /sbin/service glite-lb-bkserverd restart || startup_error=1 +@redhat@ /sbin/service glite-lb-locallogger restart || startup_error=1 +@redhat@ if test x"$GLITE_LB_HARVESTER_ENABLED" = x"true"; then +@redhat@ /sbin/service glite-lb-harvester restart || startup_error=1 +@redhat@ else +@redhat@ /sbin/service glite-lb-harvester stop >/dev/null 2>&1 +@redhat@ fi if test "$startup_error" = "0"; then qecho "Services started successfully" diff --git a/org.glite.lb.server/config/systemd.bkserverd b/org.glite.lb.server/config/systemd.bkserverd new file mode 100644 index 0000000..903384a --- /dev/null +++ b/org.glite.lb.server/config/systemd.bkserverd @@ -0,0 +1,22 @@ +[Unit] +Description=gLite Logging and Bookkeeping server +Documentation=man:glite-lb-setup(8) http://egee.cesnet.cz/en/JRA1/LB/documentation.php +After=network.target mysqld.service + +[Service] +Type=forking +User=glite +Group=glite +Environment=KRB5_KTNAME=FILE:/var/glite/krb5kt_lb +Environment=KRB5CCNAME=FILE:/var/glite/krb5cc_lb +Environment=LOG4C_RCPATH=/etc/glite-lb +Environment=X509_USER_CERT=/var/glite/.certs/hostcert.pem +Environment=X509_USER_KEY=/var/glite/.certs/hostkey.pem +EnvironmentFile=-/etc/profile.d/grid-env.sh +EnvironmentFile=-/etc/sysconfig/glite-lb +PIDFile=/var/run/glite/glite-lb-bkserverd.pid +ExecStartPre=/bin/rm -f /tmp/lb_proxy_serve.sock /tmp/lb_proxy_store.sock +ExecStart=/usr/bin/glite-lb-bkserverd --dump-prefix=/var/glite/dump --purge-prefix=/var/glite/purge --policy /etc/glite-lb/glite-lb-authz.conf $GLITE_LB_SERVER_PROXY_OPTIONS $GLITE_LB_SERVER_OPTIONS + +[Install] +WantedBy=multi-user.target diff --git a/org.glite.lb.server/project/glite-lb-server.spec b/org.glite.lb.server/project/glite-lb-server.spec index f5b5ab4..c6e22fc 100644 --- a/org.glite.lb.server/project/glite-lb-server.spec +++ b/org.glite.lb.server/project/glite-lb-server.spec @@ -48,9 +48,16 @@ Requires: mysql-server Requires: glite-lbjp-common-server-bones%{?_isa} >= 2.2.0 Requires: glite-lb-client-progs Requires: glite-lb-utils +%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 %description @DESCRIPTION@ @@ -73,14 +80,17 @@ make check rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT +%if ! 0%{?fedora} sed -i 's,\(lockfile=/var/lock\),\1/subsys,' $RPM_BUILD_ROOT/etc/init.d/glite-lb-bkserverd mkdir $RPM_BUILD_ROOT/etc/rc.d mv $RPM_BUILD_ROOT/etc/init.d $RPM_BUILD_ROOT/etc/rc.d +%endif install -m 0644 LICENSE project/ChangeLog $RPM_BUILD_ROOT/usr/share/doc/%{name}-%{version} 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' -mkdir -p $RPM_BUILD_ROOT/var/glite +mkdir -p $RPM_BUILD_ROOT/var/glite/dump +mkdir -p $RPM_BUILD_ROOT/var/glite/purge mkdir -p $RPM_BUILD_ROOT/var/run/glite mkdir -p $RPM_BUILD_ROOT/var/spool/glite/lb-locallogger mkdir -p $RPM_BUILD_ROOT/var/spool/glite/lb-notif @@ -99,28 +109,56 @@ exit 0 %post +%if 0%{?fedora} +# Fedora 18: systemd_post glite-lb-bkserverd.service +if [ $1 -eq 1 ] ; then + # Initial installation + /bin/systemctl daemon-reload >/dev/null 2>&1 || : +fi +%else /sbin/chkconfig --add glite-lb-bkserverd if [ $1 -eq 1 ] ; then /sbin/chkconfig glite-lb-bkserverd off fi +%endif %preun +%if 0%{?fedora} +# Fedora 18: systemd_preun glite-lb-bkserverd.service +if [ $1 -eq 0 ] ; then + # Package removal, not upgrade + /bin/systemctl --no-reload disable glite-lb-bkserverd.service > /dev/null 2>&1 || : + /bin/systemctl stop glite-lb-bkserverd.service > /dev/null 2>&1 || : +fi +%else if [ $1 -eq 0 ] ; then /sbin/service glite-lb-bkserverd stop >/dev/null 2>&1 /sbin/chkconfig --del glite-lb-bkserverd fi +%endif %postun +%if 0%{?fedora} +# Fedora 18: systemd_postun_with_restart glite-lb-bkserverd.service +/bin/systemctl daemon-reload >/dev/null 2>&1 || : +if [ $1 -ge 1 ] ; then + # Package upgrade, not uninstall + /bin/systemctl try-restart glite-lb-bkserverd.service >/dev/null 2>&1 || : +fi +%else if [ "$1" -ge "1" ] ; then /sbin/service glite-lb-bkserverd condrestart >/dev/null 2>&1 || : fi +%endif %files %defattr(-,root,root) %dir %attr(0755, glite, glite) %{_localstatedir}/glite +%dir %attr(0755, glite, glite) %{_localstatedir}/glite/dump +%dir %attr(0755, glite, glite) %{_localstatedir}/glite/purge %dir %attr(0755, glite, glite) %{_localstatedir}/run/glite %dir %attr(0755, glite, glite) %{_localstatedir}/spool/glite %dir %attr(0755, glite, glite) %{_localstatedir}/spool/glite/lb-locallogger @@ -139,7 +177,11 @@ fi %{_docdir}/%{name}-%{version}/ChangeLog %{_docdir}/%{name}-%{version}/LICENSE %{_docdir}/%{name}-%{version}/glite-lb +%if 0%{?fedora} +%{_unitdir}/glite-lb-bkserverd.service +%else %{_initrddir}/glite-lb-bkserverd +%endif %{_bindir}/* %{_sbindir}/* %{_datadir}/glite/* diff --git a/org.glite.lb/configure b/org.glite.lb/configure index 848c2be..a024047 100755 --- a/org.glite.lb/configure +++ b/org.glite.lb/configure @@ -2177,13 +2177,10 @@ sub os_type { close FH; if (/Debian|Ubuntu/i) { return "debian"; } - elsif (/Scientific|Redhat|Centos/i) { return "redhat"; } - elsif (/Fedora/i) { - $ver = `rpm -q --queryformat '%{version}' fedora-release 2>/dev/null`; - if ($ver and $ver >= 15) { return "fedora"; } + elsif (/Scientific|Redhat|Centos|Fedora/i) { + `pkg-config --exists systemd`; + if ($? == 0) { return "fedora"; } else { return "redhat"; } - } else { - return "redhat"; } }