From fb5277dfec7c168d03bcb5a8d79ce4e4e08372bd Mon Sep 17 00:00:00 2001 From: Jason Tibbitts Date: Fri, 24 Feb 2012 23:43:18 -0600 Subject: [PATCH] COnvert to systemd. --- README.Fedora | 2 +- zoneminder.service | 11 +++++++++++ zoneminder.spec | 47 +++++++++++++++++++++++++++++++--------------- 3 files changed, 44 insertions(+), 16 deletions(-) create mode 100644 zoneminder.service diff --git a/README.Fedora b/README.Fedora index 438ef7f..f1a4b58 100644 --- a/README.Fedora +++ b/README.Fedora @@ -57,7 +57,7 @@ New installs systemctl start httpd.service 9. You should immediately visit http://localhost/zm and secure the system if - you wish for it to be network facing. To do this: + it is network facing. To do this: a) click Options, then System. b) check OPT_USE_AUTH. diff --git a/zoneminder.service b/zoneminder.service new file mode 100644 index 0000000..a4bd277 --- /dev/null +++ b/zoneminder.service @@ -0,0 +1,11 @@ +[Unit] +Description=Video security and surveillance system + +[Service] +Type=forking +ExecStart=/usr/bin/zmpkg.pl start +PIDFile=/run/zoneminder/zm.pid + +[Install] +WantedBy=multi-user.target + diff --git a/zoneminder.spec b/zoneminder.spec index 7fa76e4..e551b6b 100644 --- a/zoneminder.spec +++ b/zoneminder.spec @@ -5,7 +5,7 @@ Name: zoneminder Version: 1.25.0 -Release: 3%{?dist} +Release: 4%{?dist} Summary: A camera monitoring and analysis tool Group: System Environment/Daemons # jscalendar is LGPL (any version): http://www.dynarch.com/projects/calendar/ @@ -18,6 +18,7 @@ Source2: zoneminder.conf Source3: redalert.wav Source4: README.Fedora Source5: http://downloads.sourceforge.net/jscalendar/jscalendar-1.0.zip +Source6: zoneminder.service # Need to unravel the proper mootools files to grab from upstream, since the # number of them keeps multiplying. In the meantime, rely on the ones bundled # with zoneminder. As these are javascript, there is no guideline violation @@ -43,10 +44,9 @@ Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version)) Requires: perl(DBD::mysql) perl(Archive::Tar) perl(Archive::Zip) Requires: perl(MIME::Entity) perl(MIME::Lite) perl(Net::SMTP) perl(Net::FTP) -Requires(post): /sbin/chkconfig -Requires(preun): /sbin/chkconfig -Requires(preun): /sbin/service -Requires(postun): /sbin/service +Requires(post): systemd-units systemd-sysv +Requires(preun): systemd-units +Requires(postun): systemd-units %description @@ -136,9 +136,9 @@ install -m 755 -d %{buildroot}/%{_localstatedir}/lib/zoneminder/sock install -m 755 -d %{buildroot}/%{_localstatedir}/lib/zoneminder/swap install -m 755 -d %{buildroot}/%{_localstatedir}/spool/zoneminder-upload -install -D -m 755 scripts/zm %{buildroot}/%{_initrddir}/zoneminder install -D -m 644 %{SOURCE2} %{buildroot}/%{_sysconfdir}/httpd/conf.d/zoneminder.conf install -D -m 755 %{SOURCE3} %{buildroot}/%{_datadir}/%{name}/www/sounds/redalert.wav +install -D -m 644 %{SOURCE6} %{buildroot}/%{_unitdir}/zoneminder.service # Install jscalendar - this really should be in its own package install -d -m 755 %{buildroot}/%{_datadir}/%{name}/www/jscalendar @@ -157,28 +157,41 @@ popd %post -/sbin/chkconfig --add zoneminder - +if [ $1 -eq 1 ] ; then + # Initial installation + /bin/systemctl daemon-reload >/dev/null 2>&1 || : +fi %preun -if [ $1 -eq 0 ]; then - /sbin/service zoneminder stop > /dev/null 2>&1 || : - /sbin/chkconfig --del zoneminder +if [ $1 -eq 0 ] ; then + # Package removal, not upgrade + /bin/systemctl --no-reload disable zoneminder.service > /dev/null 2>&1 || : + /bin/systemctl stop zoneminder.service > /dev/null 2>&1 || : fi - %postun -if [ $1 -ge 1 ]; then - /sbin/service zoneminder condrestart > /dev/null 2>&1 || : +/bin/systemctl daemon-reload >/dev/null 2>&1 || : +if [ $1 -ge 1 ] ; then + # Package upgrade, not uninstall + /bin/systemctl try-restart zoneminder.service >/dev/null 2>&1 || : fi +%triggerun -- zoneminder < 2.6-25 +# Save the current service runlevel info +# User must manually run systemd-sysv-convert --apply zoneminder +# to migrate them to systemd targets +/usr/bin/systemd-sysv-convert --save zoneminder >/dev/null 2>&1 ||: + +# Run these because the SysV package being removed won't do them +/sbin/chkconfig --del zoneminder >/dev/null 2>&1 || : +/bin/systemctl try-restart zoneminder.service >/dev/null 2>&1 || : + %files %defattr(-,root,root,-) %doc AUTHORS COPYING README README.Fedora jscalendar-doc %config(noreplace) %attr(640,root,%{zmgid_final}) %{_sysconfdir}/zm.conf %config(noreplace) %attr(644,root,root) %{_sysconfdir}/httpd/conf.d/zoneminder.conf -%attr(755,root,root) %{_initrddir}/zoneminder %{_bindir}/zma %{_bindir}/zmaudit.pl @@ -214,8 +227,12 @@ fi %dir %attr(755,%{zmuid_final},%{zmgid_final}) %{_localstatedir}/log/zoneminder %dir %attr(755,%{zmuid_final},%{zmgid_final}) %{_localstatedir}/spool/zoneminder-upload +%{_unitdir}/zoneminder.service %changelog +* Fri Feb 24 2012 Jason L Tibbitts III - 1.25.0-4 +- Convert to systemd. + * Wed Feb 22 2012 Jason L Tibbitts III - 1.25.0-3 - Update README.Fedora to reference systemctl and mention timezone info in php.ini.