Skip to content

Commit

Permalink
NMS-6137 add systemd launch file
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Reed committed Jul 16, 2014
1 parent 548ce99 commit e473ebe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
13 changes: 13 additions & 0 deletions opennms-base-assembly/src/main/filtered/etc/opennms.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=OpenNMS server
After=postgresql.target

[Service]
Type=forking
User=root
PIDFile=${install.daemonlogs.dir}/opennms.pid
ExecStart=${install.dir}/bin/opennms -Q start
ExecStop=${install.dir}/bin/opennms stop

[Install]
WantedBy=multi-user.target
8 changes: 6 additions & 2 deletions tools/packages/opennms/opennms.spec
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ tar zxvf $RPM_BUILD_DIR/%{name}-%{version}-%{release}/target$RPM_BUILD_ROOT.tar.

echo "=== UNTAR BUILD COMPLETED ==="

### XXX is this needed? (Most of) the current scripts don't use OPENNMS_HOME.
### Set this so users can refer to $OPENNMS_HOME easily.
### /etc/profile.d

mkdir -p $RPM_BUILD_ROOT%{profiledir}
Expand Down Expand Up @@ -551,6 +551,9 @@ rm -rf $RPM_BUILD_ROOT%{instprefix}/contrib/remote-poller

rm -rf $RPM_BUILD_ROOT%{instprefix}/lib/*.tar.gz

install -d -m 755 $RPM_BUILD_ROOT%{_libdir}/systemd/system
install -m 655 $RPM_BUILD_ROOT%{instprefix}/etc/opennms.service $RPM_BUILD_ROOT%{_libdir}/systemd/system/

cd $RPM_BUILD_ROOT

# core package files
Expand Down Expand Up @@ -681,7 +684,8 @@ rm -rf $RPM_BUILD_ROOT
%files core -f %{_tmppath}/files.main
%defattr(664 root root 775)
%attr(755,root,root) %{profiledir}/%{name}.sh
%attr(755,root,root) %{logdir}
%attr(755,root,root) %{_libdir}/systemd/system/opennms.service
%attr(755,root,root) %{logdir}
%{logdir}/controller
%{logdir}/daemon
%{logdir}/webapp
Expand Down

2 comments on commit e473ebe

@corey-hammerton
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should replace %{_libdir}/systemd/system/opennms.service with %{_unitdir}/opennms.service

This macro is available in CentOS 7 installs under /usr/lib/rpm/macros.d/macros.systemd

@RangerRick
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't build on CentOS 7, so that would probably be an issue. I guess we could define %{_unitdir} if it's not set? Then it'll work as expected when building on centos7, but fall back on others...

Please sign in to comment.