Systemd files for mcollective #41

Closed
wants to merge 2 commits into
from
@@ -0,0 +1,14 @@
+[Unit]
+Description=The Marionette Collective
+After=network.target
+
+[Service]
+Type=forking
@haus
haus Aug 6, 2012 Member

Unless daemonize is set to 1 in server.cfg starting the service with this service file will hang. If the type is set to simple it behaves as expected, even with the default daemonize of 0.

Edit: never mind, server.cfg has daemonize of 1, so this will work fine.

+StandardOutput=syslog
+StandardError=syslog
+ExecStart=/usr/sbin/mcollectived --config=/etc/mcollective/server.cfg --pidfile=/var/run/mcollective.pid
+ExecReload=/bin/kill -USR1 $MAINPID
+PIDFile=/var/run/mcollective.pid
+
+[Install]
+WantedBy=multi-user.target
@@ -54,7 +54,11 @@ rm -rf %{buildroot}
%{__install} -d -m0755 %{buildroot}/%{ruby_sitelib}/mcollective
%{__install} -d -m0755 %{buildroot}%{_bindir}
%{__install} -d -m0755 %{buildroot}%{_sbindir}
+%if 0%{?fedora} >= 17
+%{__install} -d -m0755 %{buildroot}%{_unitdir}
+%else
%{__install} -d -m0755 %{buildroot}%{_sysconfdir}/init.d
+%endif
%{__install} -d -m0755 %{buildroot}%{_libexecdir}/mcollective/
%{__install} -d -m0755 %{buildroot}%{_sysconfdir}/mcollective
%{__install} -d -m0755 %{buildroot}%{_sysconfdir}/mcollective/plugin.d
@@ -69,8 +73,12 @@ rm -rf %{buildroot}
%if 0%{?suse_version}
%{__install} -m0755 mcollective.init %{buildroot}%{_sysconfdir}/init.d/mcollective
%else
+%if 0%{?fedora} >= 17
+%{__install} -m0755 ext/redhat/mcollective.service %{buildroot}%{_unitdir}/mcollective.service
@haus
haus Aug 6, 2012 Member

The standard for services on fedora seem to be 0644, not 0755, probably because they are loaded by systemctl, and not designed to be invoked directly.

+%else
%{__install} -m0755 ext/redhat/mcollective.init %{buildroot}%{_sysconfdir}/init.d/mcollective
%endif
+%endif
cp -R lib/* %{buildroot}/%{ruby_sitelib}/
@@ -83,18 +91,39 @@ chmod 0755 %{buildroot}%{_sbindir}/*
rm -rf %{buildroot}
%post
+%if 0%{?fedora} >= 17
+if [ $1 -eq 1 ] ; then
+ /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
+%else
/sbin/chkconfig --add mcollective || :
+%endif
%postun
+%if 0%{?fedora} >= 17
+if [ $1 -ge 1 ] ; then
+ # Package upgrade, not uninstall
+ /bin/systemctl try-restart mcollective.service >/dev/null 2>&1 || :
+fi
+%else
if [ "$1" -ge 1 ]; then
/sbin/service mcollective condrestart &>/dev/null || :
fi
+%endif
%preun
+%if 0%{?fedora} >= 17
+if [ $1 -eq 0 ] ; then
+ # Package removal, not upgrade
+ /bin/systemctl --no-reload disable mcollective.service > /dev/null 2>&1 || :
+ /bin/systemctl stop mcollective.service > /dev/null 2>&1 || :
+fi
+%else
if [ "$1" = 0 ] ; then
/sbin/service mcollective stop > /dev/null 2>&1
/sbin/chkconfig --del mcollective || :
fi
+%endif
%files common
%doc COPYING
@@ -123,7 +152,11 @@ fi
%files
%doc COPYING
%{_sbindir}/mcollectived
+%if 0%{?fedora} >= 17
+%{_unitdir}/mcollective.service
+%else
%{_sysconfdir}/init.d/mcollective
+%endif
%config(noreplace)%{_sysconfdir}/mcollective/server.cfg
%config(noreplace)%{_sysconfdir}/mcollective/facts.yaml
%dir %{_sysconfdir}/mcollective/ssl/clients