diff --git a/src/install/debian/compat b/src/install/debian/compat index 45a4fb75..b4de3947 100644 --- a/src/install/debian/compat +++ b/src/install/debian/compat @@ -1 +1 @@ -8 +11 diff --git a/src/install/debian/lsc.install b/src/install/debian/lsc.install index 83ea2cea..a11a9dda 100644 --- a/src/install/debian/lsc.install +++ b/src/install/debian/lsc.install @@ -11,6 +11,8 @@ sample/* usr/share/doc/lsc ## init etc/init.d/lsc etc/init.d etc/default/lsc etc/default +etc/default/lsc-sync etc/default +etc/default/lsc-async etc/default ## nagios bin/check_lsc* var/lib/lsc/nagios diff --git a/src/install/debian/rules b/src/install/debian/rules index 5aafa88f..0c88dc43 100644 --- a/src/install/debian/rules +++ b/src/install/debian/rules @@ -7,3 +7,21 @@ dh $@ override_dh_compress: + +override_dh_testdir: +## systemd + cp -f lib/systemd/system/lsc-async.service debian/ + cp -f lib/systemd/system/lsc-async@.service debian/ + cp -f lib/systemd/system/lsc-sync.service debian/ + cp -f lib/systemd/system/lsc-sync.timer debian/ + cp -f lib/systemd/system/lsc-sync@.service debian/ + cp -f etc/default/lsc-async debian/lsc-async.default + cp -f etc/default/lsc-sync debian/lsc-sync.default + dh_testdir + +override_dh_installsystemd: + dh_installsystemd --no-start --no-enable --no-stop-on-upgrade --name=lsc-async + dh_installsystemd --no-start --no-enable --no-stop-on-upgrade --name=lsc-async@ + dh_installsystemd --no-start --no-enable --no-stop-on-upgrade --name=lsc-sync + dh_installsystemd --no-start --no-enable --no-stop-on-upgrade --name=lsc-sync@ + dh_installsystemd --name=lsc-sync.timer diff --git a/src/install/etc/default/lsc-exampleasynctask b/src/install/etc/default/lsc-async similarity index 100% rename from src/install/etc/default/lsc-exampleasynctask rename to src/install/etc/default/lsc-async diff --git a/src/install/etc/default/lsc-examplesynctask b/src/install/etc/default/lsc-sync similarity index 100% rename from src/install/etc/default/lsc-examplesynctask rename to src/install/etc/default/lsc-sync diff --git a/src/install/lib/systemd/system/lsc.service b/src/install/lib/systemd/system/lsc-async.service similarity index 100% rename from src/install/lib/systemd/system/lsc.service rename to src/install/lib/systemd/system/lsc-async.service diff --git a/src/install/lib/systemd/system/lsc@.service b/src/install/lib/systemd/system/lsc-async@.service similarity index 100% rename from src/install/lib/systemd/system/lsc@.service rename to src/install/lib/systemd/system/lsc-async@.service diff --git a/src/install/lib/systemd/system/lsc-oneshot.service b/src/install/lib/systemd/system/lsc-sync.service similarity index 100% rename from src/install/lib/systemd/system/lsc-oneshot.service rename to src/install/lib/systemd/system/lsc-sync.service diff --git a/src/install/lib/systemd/system/lsc-oneshot.timer b/src/install/lib/systemd/system/lsc-sync.timer similarity index 100% rename from src/install/lib/systemd/system/lsc-oneshot.timer rename to src/install/lib/systemd/system/lsc-sync.timer diff --git a/src/install/lib/systemd/system/lsc-oneshot@.service b/src/install/lib/systemd/system/lsc-sync@.service similarity index 100% rename from src/install/lib/systemd/system/lsc-oneshot@.service rename to src/install/lib/systemd/system/lsc-sync@.service diff --git a/src/install/lsc-core.spec b/src/install/lsc-core.spec index 19e4b0d8..9540ecaa 100644 --- a/src/install/lsc-core.spec +++ b/src/install/lsc-core.spec @@ -33,6 +33,11 @@ URL: https://lsc-project.org Source: %{lsc_name}-core-%{lsc_version}-dist.zip BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +%if 0%{?fedora}%{?el9} +BuildRequires: systemd-rpm-macros +%else +BuildRequires: systemd +%endif Requires(pre): coreutils Requires: which @@ -69,6 +74,8 @@ mkdir -p %{buildroot}/etc/default mkdir -p %{buildroot}/usr/share/doc/lsc/bin mkdir -p %{buildroot}%{lsc_logdir} mkdir -p %{buildroot}/var/lib/lsc/nagios +mkdir -p %{buildroot}%{_unitdir} +mkdir -p %{buildroot}%{_sysconfdir}/default # Copy files ## bin @@ -92,6 +99,14 @@ cp -a etc/cron.d/lsc.cron %{buildroot}/etc/cron.d/lsc ## init cp -a etc/init.d/lsc %{buildroot}/etc/init.d/lsc cp -a etc/default/lsc %{buildroot}/etc/default/lsc +## systemd +cp -a etc/default/lsc-async %{buildroot}%{_sysconfdir}/default/lsc-async +cp -a etc/default/lsc-sync %{buildroot}%{_sysconfdir}/default/lsc-sync +install -p -m 0644 lib/systemd/system/lsc-async.service %{buildroot}%{_unitdir}/ +install -p -m 0644 lib/systemd/system/lsc-async@.service %{buildroot}%{_unitdir}/ +install -p -m 0644 lib/systemd/system/lsc-sync.service %{buildroot}%{_unitdir}/ +install -p -m 0644 lib/systemd/system/lsc-sync@.service %{buildroot}%{_unitdir}/ +install -p -m 0644 lib/systemd/system/lsc-sync.timer %{buildroot}%{_unitdir}/ ## nagios cp -a bin/check_lsc* %{buildroot}/var/lib/lsc/nagios @@ -108,23 +123,17 @@ sed -i 's:^LIB_DIR.*:LIB_DIR="/usr/%{_lib}/lsc":' %{buildroot}/usr/bin/lsc %{bui sed -i 's:^LOG_DIR.*:LOG_DIR="%{lsc_logdir}":' %{buildroot}/usr/bin/lsc %{buildroot}/usr/bin/lsc-agent %{buildroot}/usr/bin/hsqldb sed -i 's:^VAR_DIR.*:VAR_DIR="/var/lsc":' %{buildroot}/usr/bin/hsqldb ## init -sed -i 's:^LSC_BIN.*:LSC_BIN="/usr/bin/lsc":' %{buildroot}/etc/default/lsc -sed -i 's:^LSC_CFG_DIR.*:LSC_CFG_DIR="/etc/lsc":' %{buildroot}/etc/default/lsc -sed -i 's:^LSC_USER.*:LSC_USER="lsc":' %{buildroot}/etc/default/lsc -sed -i 's:^LSC_GROUP.*:LSC_GROUP="lsc":' %{buildroot}/etc/default/lsc -sed -i 's:^LSC_PID_FILE.*:LSC_PID_FILE="/var/run/lsc.pid":' %{buildroot}/etc/default/lsc +sed -i 's:^LSC_BIN.*:LSC_BIN="/usr/bin/lsc":' %{buildroot}%{_sysconfdir}/default/lsc %{buildroot}%{_sysconfdir}/default/lsc-async %{buildroot}%{_sysconfdir}/default/lsc-sync +sed -i 's:^LSC_CFG_DIR.*:LSC_CFG_DIR="/etc/lsc":' %{buildroot}%{_sysconfdir}/default/lsc %{buildroot}%{_sysconfdir}/default/lsc-async %{buildroot}%{_sysconfdir}/default/lsc-sync +sed -i 's:^LSC_USER.*:LSC_USER="lsc":' %{buildroot}%{_sysconfdir}/default/lsc %{buildroot}%{_sysconfdir}/default/lsc-async %{buildroot}%{_sysconfdir}/default/lsc-sync +sed -i 's:^LSC_GROUP.*:LSC_GROUP="lsc":' %{buildroot}%{_sysconfdir}/default/lsc %{buildroot}%{_sysconfdir}/default/lsc-async %{buildroot}%{_sysconfdir}/default/lsc-sync +sed -i 's:^LSC_PID_FILE.*:LSC_PID_FILE="/var/run/lsc.pid":' %{buildroot}%{_sysconfdir}/default/lsc %{buildroot}%{_sysconfdir}/default/lsc-async %{buildroot}%{_sysconfdir}/default/lsc-sync %post -#================================================= -# Post Installation -#================================================= - -# Do this at first install -if [ $1 -eq 1 ] -then - # Set lsc as service - /sbin/chkconfig --add lsc -fi +%systemd_post lsc-async.service +%systemd_post lsc-async@.service +%systemd_post lsc-sync.service +%systemd_post lsc-sync@.service # Always do this # Create user and group if needed @@ -137,6 +146,12 @@ getent passwd %{lsc_user} > /dev/null 2>&1 || useradd --system --gid %{lsc_group ln -sf /usr/%{_lib}/lsc/ /usr/share/doc/lsc/%{_lib} ln -sf /usr/bin/lsc /usr/share/doc/lsc/bin/ +%preun +%systemd_preun lsc-async.service +%systemd_preun lsc-async@.service +%systemd_preun lsc-sync.service +%systemd_preun lsc-sync@.service + %postun #================================================= # Post uninstallation @@ -167,9 +182,16 @@ rm -rf %{buildroot} %config(noreplace) /etc/lsc/ %config(noreplace) /etc/cron.d/lsc %config(noreplace) /etc/default/lsc +%config(noreplace) /etc/default/lsc-sync +%config(noreplace) /etc/default/lsc-async /usr/bin/lsc /usr/bin/lsc-agent /usr/bin/hsqldb +%{_unitdir}/lsc-async.service +%{_unitdir}/lsc-async@.service +%{_unitdir}/lsc-sync.service +%{_unitdir}/lsc-sync@.service +%{_unitdir}/lsc-sync.timer /etc/init.d/lsc /usr/%{_lib}/lsc/ /usr/share/doc/lsc diff --git a/src/main/assembly/dist.xml b/src/main/assembly/dist.xml index f503c6d3..dc81fa4b 100644 --- a/src/main/assembly/dist.xml +++ b/src/main/assembly/dist.xml @@ -149,11 +149,11 @@ src/install/lib/systemd/system - lsc.service - lsc@.service - lsc-oneshot.service - lsc-oneshot@.service - lsc-oneshot.timer + lsc-async.service + lsc-async@.service + lsc-sync.service + lsc-sync@.service + lsc-sync.timer lib/systemd/system 0644 @@ -165,8 +165,8 @@ src/install/etc/default lsc - lsc-examplesynctask - lsc-exampleasynctask + lsc-sync + lsc-async etc/default 0644