Skip to content

Commit

Permalink
add rpm/deb packaging in systemd files + rename lsc and lsc-oneshot s…
Browse files Browse the repository at this point in the history
…ervices and corresponding default files (#50)
  • Loading branch information
David Coutadeur committed Jan 12, 2024
1 parent 527a318 commit 6b9afd7
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/install/debian/compat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8
11
2 changes: 2 additions & 0 deletions src/install/debian/lsc.install
Original file line number Diff line number Diff line change
Expand Up @@ -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

18 changes: 18 additions & 0 deletions src/install/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected] debian/
cp -f lib/systemd/system/lsc-sync.service debian/
cp -f lib/systemd/system/lsc-sync.timer debian/
cp -f lib/systemd/system/[email protected] 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
52 changes: 37 additions & 15 deletions src/install/lsc-core.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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/[email protected] %{buildroot}%{_unitdir}/
install -p -m 0644 lib/systemd/system/lsc-sync.service %{buildroot}%{_unitdir}/
install -p -m 0644 lib/systemd/system/[email protected] %{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

Expand All @@ -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

This comment has been minimized.

Copy link
@xavierba

xavierba Jan 12, 2024

Contributor

Can you please split long lines ?

sed -i 's:^LSC_BIN.*:LSC_BIN="/usr/bin/lsc":'  \
  %{buildroot}%{_sysconfdir}/default/lsc \
...
%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 [email protected]
%systemd_post lsc-sync.service
%systemd_post [email protected]

# Always do this
# Create user and group if needed
Expand All @@ -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 [email protected]
%systemd_preun lsc-sync.service
%systemd_preun [email protected]

%postun
#=================================================
# Post uninstallation
Expand Down Expand Up @@ -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}/[email protected]
%{_unitdir}/lsc-sync.service
%{_unitdir}/[email protected]
%{_unitdir}/lsc-sync.timer
/etc/init.d/lsc

This comment has been minimized.

Copy link
@xavierba

xavierba Jan 12, 2024

Contributor

You cannot have both systemd and sysvinit support. Please drop sysvinit at the same time you are introducing systemd.
Also, there might be some scriptlets to add in order to transition from sysvinit to systemd seamlessly, I need to check on that.

/usr/%{_lib}/lsc/
/usr/share/doc/lsc
Expand Down
14 changes: 7 additions & 7 deletions src/main/assembly/dist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@
<fileSet>
<directory>src/install/lib/systemd/system</directory>
<includes>
<include>lsc.service</include>
<include>[email protected]</include>
<include>lsc-oneshot.service</include>
<include>lsc-oneshot@.service</include>
<include>lsc-oneshot.timer</include>
<include>lsc-async.service</include>
<include>lsc-async@.service</include>
<include>lsc-sync.service</include>
<include>lsc-sync@.service</include>
<include>lsc-sync.timer</include>
</includes>
<outputDirectory>lib/systemd/system</outputDirectory>
<fileMode>0644</fileMode>
Expand All @@ -165,8 +165,8 @@
<directory>src/install/etc/default</directory>
<includes>
<include>lsc</include>
<include>lsc-examplesynctask</include>
<include>lsc-exampleasynctask</include>
<include>lsc-sync</include>
<include>lsc-async</include>
</includes>
<outputDirectory>etc/default</outputDirectory>
<fileMode>0644</fileMode>
Expand Down

0 comments on commit 6b9afd7

Please sign in to comment.