now using systemd

This commit is contained in:
Michal Hlavinka 2011-04-04 17:10:19 +02:00
parent 66faec9255
commit 41d9d318b6
3 changed files with 82 additions and 13 deletions

38
cyr_systemd_helper Executable file
View File

@ -0,0 +1,38 @@
#!/bin/sh
# get_config [config default]
# extracts config option from config file
get_config() {
if conf=$(grep "^$1" /etc/imapd.conf); then
echo $conf | cut -d: -f2
else
echo $2
fi
}
CONFIGDIRECTORY=$(get_config configdirectory /var/lib/imap)
RETVAL=0
start() {
cd $CONFIGDIRECTORY
runuser - cyrus -s /bin/sh -c "umask 166 ; /usr/lib/cyrus-imapd/cvt_cyrusdb_all > ${CONFIGDIRECTORY}/rpm/db_import.log 2>&1" < /dev/null
RETVAL=$?
}
stop() {
cd $CONFIGDIRECTORY
runuser - cyrus -s /bin/sh -c "umask 166 ; /usr/lib/cyrus-imapd/cvt_cyrusdb_all export > ${CONFIGDIRECTORY}/rpm/db_export.log 2>&1" < /dev/null
RETVAL=$?
}
case "$1" in
start)
start
;;
stop)
stop
;;
*)
;;
esac
exit $RETVAL

13
cyrus-imapd.service Normal file
View File

@ -0,0 +1,13 @@
[Unit]
Description=Cyrus-imapd IMAP/POP3 email server
After=local-fs.target network.target
[Service]
Type=simple
EnvironmentFile=/etc/sysconfig/cyrus-imapd
ExecStartPre=/usr/lib/cyrus-imapd/cyr_systemd_helper start
ExecStart=/usr/lib/cyrus-imapd/cyrus-master $CYRUSOPTIONS
ExecStopPost=/usr/lib/cyrus-imapd/cyr_systemd_helper stop
[Install]
WantedBy=multi-user.target

View File

@ -1,6 +1,6 @@
Name: cyrus-imapd Name: cyrus-imapd
Version: 2.4.7 Version: 2.4.7
Release: 1%{?dist} Release: 2%{?dist}
%define ssl_pem_file %{_sysconfdir}/pki/%{name}/%{name}.pem %define ssl_pem_file %{_sysconfdir}/pki/%{name}/%{name}.pem
@ -22,13 +22,16 @@ Source2: cyrus-imapd.imap-2.3.x-conf
Source3: cyrus-imapd.pam-config Source3: cyrus-imapd.pam-config
Source4: http://email.uoa.gr/projects/cyrus/autocreate/README.autocreate-cyrus-2.3 Source4: http://email.uoa.gr/projects/cyrus/autocreate/README.autocreate-cyrus-2.3
Source5: http://email.uoa.gr/projects/cyrus/autosievefolder/README.autosievefolder Source5: http://email.uoa.gr/projects/cyrus/autosievefolder/README.autosievefolder
Source6: cyrus-imapd.init
Source7: cyrus-imapd.sysconfig Source7: cyrus-imapd.sysconfig
Source8: cyrus-imapd.cvt_cyrusdb_all Source8: cyrus-imapd.cvt_cyrusdb_all
Source9: cyrus-imapd.magic Source9: cyrus-imapd.magic
Source10: cyrus-imapd.cron-daily Source10: cyrus-imapd.cron-daily
Source11: README.rpm Source11: README.rpm
#systemd support
Source12: cyrus-imapd.service
Source13: cyr_systemd_helper
# inclusion requested: # inclusion requested:
# http://bugzilla.cyrusimap.org/bugzilla3/show_bug.cgi?id=3182 # http://bugzilla.cyrusimap.org/bugzilla3/show_bug.cgi?id=3182
# http://bugzilla.cyrusimap.org/bugzilla3/show_bug.cgi?id=3212 # http://bugzilla.cyrusimap.org/bugzilla3/show_bug.cgi?id=3212
@ -59,9 +62,9 @@ BuildRequires: krb5-devel
BuildRequires: net-snmp-devel BuildRequires: net-snmp-devel
BuildRequires: transfig BuildRequires: transfig
Requires(post): e2fsprogs, chkconfig, initscripts, perl, grep, coreutils, findutils Requires(post): e2fsprogs, perl, grep, coreutils, findutils, systemd-units
Requires(preun): chkconfig, initscripts, coreutils Requires(preun): systemd-units, coreutils
Requires(postun): initscripts Requires(postun): systemd-units
Requires: %{name}-utils = %{version}-%{release} Requires: %{name}-utils = %{version}-%{release}
Requires: file, db4-utils Requires: file, db4-utils
@ -229,10 +232,12 @@ install -p -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/pam.d/lmtp
install -p -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/pam.d/nntp install -p -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/pam.d/nntp
install -p -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/pam.d/csync install -p -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/pam.d/csync
install -p -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/%{name} install -p -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
install -p -m 755 %{SOURCE6} %{buildroot}%{_sysconfdir}/rc.d/init.d/%{name}
install -p -m 644 %{SOURCE7} %{buildroot}%{_sysconfdir}/sysconfig/%{name} install -p -m 644 %{SOURCE7} %{buildroot}%{_sysconfdir}/sysconfig/%{name}
install -p -m 755 %{SOURCE10} %{buildroot}%{_sysconfdir}/cron.daily/%{name} install -p -m 755 %{SOURCE10} %{buildroot}%{_sysconfdir}/cron.daily/%{name}
install -p -D -m 644 %{SOURCE12} %{buildroot}/lib/systemd/system/cyrus-imapd.service
install -p -D -m 755 %{SOURCE13} %{buildroot}%{_cyrexecdir}/cyr_systemd_helper
# Cleanup of doc dir # Cleanup of doc dir
find doc perl -name CVS -type d -prune -exec rm -rf {} \; find doc perl -name CVS -type d -prune -exec rm -rf {} \;
find doc perl -name .cvsignore -type f -exec rm -f {} \; find doc perl -name .cvsignore -type f -exec rm -f {} \;
@ -296,7 +301,10 @@ rm -rf %{buildroot}
-G saslauth -s /sbin/nologin -u %{uid} -r %{_cyrususer} 2> /dev/null || : -G saslauth -s /sbin/nologin -u %{uid} -r %{_cyrususer} 2> /dev/null || :
%post %post
/sbin/chkconfig --add %{name} /sbin/service cyrus-imapd condrestart >/dev/null 2>&1 ||:
if [ $1 -eq 1 ]; then
/bin/systemctl enable cyrus-imapd.service >/dev/null 2>&1 || :
fi
# Force synchronous updates, usually only on ext2 filesystems # Force synchronous updates, usually only on ext2 filesystems
for i in %{_var}/lib/imap/{user,quota} %{_var}/spool/imap for i in %{_var}/lib/imap/{user,quota} %{_var}/spool/imap
@ -328,23 +336,28 @@ popd
fi fi
%preun %preun
if [ $1 = 0 ]; then if [ $1 -eq 0 ] ; then
/sbin/service %{name} stop >/dev/null 2>&1 || : # Package removal, not upgrade
/sbin/chkconfig --del %{name} /bin/systemctl disable cyrus-imapd.service >/dev/null 2>&1 || :
/bin/systemctl stop cyrus-imapd.service > /dev/null 2>&1 || :
fi fi
%postun %postun
if [ $1 != 0 ]; then /bin/systemctl daemon-reload >/dev/null 2>&1 || :
/sbin/service %{name} condrestart >/dev/null 2>&1 || : if [ $1 -ge 1 ] ; then
# Package upgrade, not uninstall
/bin/systemctl try-restart cyrus-imapd.service >/dev/null 2>&1 || :
fi fi
%triggerun -- smartmontools < 2.4.7-2
/sbin/chkconfig smartd && /bin/systemctl enable smartd.service >/dev/null 2>&1 || :
%files %files
%defattr(-,root,root,-) %defattr(-,root,root,-)
%doc COPYRIGHT README %doc COPYRIGHT README
%doc doc/* %doc doc/*
%config(noreplace) %{_sysconfdir}/cyrus.conf %config(noreplace) %{_sysconfdir}/cyrus.conf
%config(noreplace) %{_sysconfdir}/imapd.conf %config(noreplace) %{_sysconfdir}/imapd.conf
%{_sysconfdir}/rc.d/init.d/%{name}
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name} %config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%config(noreplace) %{_sysconfdir}/sysconfig/%{name} %config(noreplace) %{_sysconfdir}/sysconfig/%{name}
%config(noreplace) %{_sysconfdir}/pam.d/pop %config(noreplace) %{_sysconfdir}/pam.d/pop
@ -355,7 +368,9 @@ fi
%config(noreplace) %{_sysconfdir}/pam.d/csync %config(noreplace) %{_sysconfdir}/pam.d/csync
%config(noreplace) %{_sysconfdir}/pam.d/nntp %config(noreplace) %{_sysconfdir}/pam.d/nntp
%{_sysconfdir}/cron.daily/%{name} %{_sysconfdir}/cron.daily/%{name}
/lib/systemd/system/cyrus-imapd.service
%dir %{_cyrexecdir} %dir %{_cyrexecdir}
%{_cyrexecdir}/cyr_systemd_helper
%{_cyrexecdir}/arbitron %{_cyrexecdir}/arbitron
%{_cyrexecdir}/arbitronsort.pl %{_cyrexecdir}/arbitronsort.pl
%{_cyrexecdir}/chk_cyrus %{_cyrexecdir}/chk_cyrus
@ -474,6 +489,9 @@ fi
%{_mandir}/man1/* %{_mandir}/man1/*
%changelog %changelog
* Mon Apr 04 2011 Michal Hlaivnka <mhlavink@redhat.com> - 2.4.7-2
- now using systemd
* Thu Mar 31 2011 Michal Hlavinka <mhlavink@redhat.com> - 2.4.7-1 * Thu Mar 31 2011 Michal Hlavinka <mhlavink@redhat.com> - 2.4.7-1
- updated to 2.4.7 - updated to 2.4.7