summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2014-01-04 20:40:04 +0400
committerIgor Pashev <pashev.igor@gmail.com>2014-01-04 20:40:04 +0400
commit9abd6d2acd8db4b6c05436ac0b2a0369f64013c2 (patch)
tree2e0587be7aa8895e12022e28daf6d409a3cc1e6b
parentcf7532377154ad1069796cc5cdfb6cde013843c6 (diff)
downloadexim4-9abd6d2acd8db4b6c05436ac0b2a0369f64013c2.tar.gz
SMF service is ready
-rw-r--r--debian/exim4-base.smf/manifest/network/smtp/exim4.xml6
-rw-r--r--debian/exim4-base.smf/method/smtp-exim473
-rw-r--r--debian/exim4-config.postinst26
-rwxr-xr-xdebian/rules15
4 files changed, 115 insertions, 5 deletions
diff --git a/debian/exim4-base.smf/manifest/network/smtp/exim4.xml b/debian/exim4-base.smf/manifest/network/smtp/exim4.xml
index b3bf93c..87f407e 100644
--- a/debian/exim4-base.smf/manifest/network/smtp/exim4.xml
+++ b/debian/exim4-base.smf/manifest/network/smtp/exim4.xml
@@ -40,7 +40,7 @@
</dependent>
<exec_method type="method" name="start" exec="/lib/svc/method/smtp-exim4 start" timeout_seconds="120"/>
<exec_method type="method" name="stop" exec="/lib/svc/method/smtp-exim4 stop %{restarter/contract}" timeout_seconds="60"/>
- <exec_method type="method" name="refresh" exec="/lib/svc/method/smtp-exim4 refresh" timeout_seconds="60"/>
+ <exec_method type="method" name="refresh" exec="/lib/svc/method/smtp-exim4 refresh %{restarter/contract}" timeout_seconds="60"/>
<property_group name="startd" type="framework">
<propval name="ignore_error" type="astring" value="core,signal"/>
</property_group>
@@ -54,6 +54,10 @@
<property_group name="config" type="application">
<propval name="value_authorization" type="astring" value="solaris.smf.value.sendmail"/>
</property_group>
+ <property_group name="options" type="application">
+ <propval name="queuerunner" type="astring" value="combined"/>
+ <propval name="queueinterval" type="astring" value="30m"/>
+ </property_group>
<template>
<common_name>
<loctext xml:lang="C">
diff --git a/debian/exim4-base.smf/method/smtp-exim4 b/debian/exim4-base.smf/method/smtp-exim4
index 02341f3..68dfbbc 100644
--- a/debian/exim4-base.smf/method/smtp-exim4
+++ b/debian/exim4-base.smf/method/smtp-exim4
@@ -1,31 +1,96 @@
#!/bin/sh
-set -e
+. /lib/svc/share/smf_include.sh
+DAEMON='/usr/sbin/exim4'
+PIDFILE='/var/run/exim4/exim.pid'
+QRPIDFILE='/var/run/exim4/eximqr.pid'
+
+SMF_FMRI=${SMF_FMRI:-'svc:/network/smtp:exim4'}
+
+getprop()
+{
+ val=`svcprop -p $1 $SMF_FMRI`
+ if [ -n "$val" ] && [ "$val" != '""' ]; then
+ echo "$val"
+ else
+ echo "$2"
+ fi
+}
+
+QUEUERUNNER="`getprop options/queuerunner combined`"
+QUEUEINTERVAL="`getprop options/queueinterval 30m`"
exim4_start()
{
+ set -e
+
+ if ! [ -e /var/run/exim4 ]; then
+ install -d -oDebian-exim -gDebian-exim -m750 /var/run/exim4
+ fi
+
+ case "${QUEUERUNNER}" in
+ combined)
+ "$DAEMON" -bd "-q${QFLAGS}${QUEUEINTERVAL}" \
+ -oP "$PIDFILE" \
+ ${COMMONOPTIONS} \
+ ${QUEUERUNNEROPTIONS} \
+ ${SMTPLISTENEROPTIONS}
+ ;;
+ separate)
+ "$DAEMON" -bd \
+ -oP "$PIDFILE" \
+ ${COMMONOPTIONS} \
+ ${SMTPLISTENEROPTIONS}
+
+ "$DAEMON" -oP "$QRPIDFILE" \
+ "-q${QFLAGS}${QUEUEINTERVAL}" \
+ ${COMMONOPTIONS} \
+ ${QUEUERUNNEROPTIONS}
+ ;;
+ queueonly)
+ "$DAEMON" -oP "$QRPIDFILE" \
+ "-q${QFLAGS}${QUEUEINTERVAL}" \
+ ${COMMONOPTIONS} \
+ ${QUEUERUNNEROPTIONS}
+ ;;
+ *)
+ echo "Value of options/queuerunner is invalid: \`$QUEUERUNNER'" >&2
+ echo "Valid are: combined, separate, queueonly" >&2
+ exit 3
+ esac
}
exim4_stop()
{
+ smf_kill_contract $2 TERM 1 30
+ rc=$?
+ case $rc in
+ 1) # invalid contract ($2)
+ exit 2
+ ;;
+ 2) # TERM timeouted, use KILL
+ smf_kill_contract $2 KILL 1
+ ;;
+ esac
}
exim4_refresh()
{
+ smf_kill_contract $2 HUP
}
case "$1" in
start)
- exim4_start
+ exim4_start "$@"
;;
stop)
- exim4_stop
+ exim4_stop "$@"
;;
refresh)
- exim4_refresh
+ exim4_refresh "$@"
;;
*)
echo "$0: unknown command: $1" >&2
diff --git a/debian/exim4-config.postinst b/debian/exim4-config.postinst
index 6034437..0424ac2 100644
--- a/debian/exim4-config.postinst
+++ b/debian/exim4-config.postinst
@@ -363,6 +363,32 @@ case "$1" in
# If dpkg-reconfigure was used implement the changes by restarting
# the daemon.
if [ "${DEBCONF_RECONFIGURE}" = "1" ] ; then
+ if [ -x /usr/bin/smf_present ] && /usr/bin/smf_present ; then
+ db_stop
+ exim4_fmri='svc:/network/smtp:exim4'
+ # XXX we need a standalone helper for such things:
+ exim4_svcstatus=`svcstatus $exim4_fmri`
+ case $exim4_svcstatus in
+ online)
+ svcadm -v restart $exim4_fmri
+ ;;
+ offline)
+ svcadm -v refresh $exim4_fmri
+ ;;
+ disabled|temporary-disabled)
+ svcadm -v enable $exim4_fmri
+ ;;
+ maintenance)
+ svcadm -v clear $exim4_fmri
+ ;;
+ none)
+ echo "Service $exim4_fmri does not exist" >&2
+ ;;
+ *)
+ echo "Unknown status of $exim4_fmri: \`$exim4_svcstatus'" >&2
+ ;;
+ esac
+ fi
if [ -x /etc/init.d/exim4 ]; then
# use restart instead of reload, as changing listening
# interfaces cannot be done with HUP.
diff --git a/debian/rules b/debian/rules
index 274083c..7919914 100755
--- a/debian/rules
+++ b/debian/rules
@@ -9,6 +9,13 @@ include /usr/share/dpkg/architecture.mk
buildname := $(shell scripts/os-type)-$(shell scripts/arch-type)
DEBIAN := $(shell pwd)/debian
+
+ifeq (illumos,$(DEB_HOST_ARCH_OS))
+smf_fmri := svc:/network/smtp:exim4
+dh_smf_prerm := /usr/share/debhelper/autoscripts/prerm-smf-stop
+dh_smf_postinst := /usr/share/debhelper/autoscripts/postinst-smf-start
+endif
+
ifeq ($(wildcard /usr/share/dpkg/buildflags.mk),)
CFLAGS := -g
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
@@ -456,7 +463,15 @@ binary-arch: build $(install)
dh_installpam $(dhbuildpackages)
dh_installmime $(dhbuildpackages)
ifeq (illumos,$(DEB_HOST_ARCH_OS))
+ # SMF service is in exim4-base package,
+ # but management (enable/disable) is done in exim4-daemon-*.
+ # This is the first time we have such a configuration, so there are
+ # not helpers, and we hack a bit.
dh_smf -p exim4-base
+ set -x; for p in exim4-daemon-light exim4-daemon-heavy; do \
+ sed 's,#SERVICES#,$(smf_fmri),' $(dh_smf_prerm) >> debian/$$p.prerm.debhelper; \
+ sed 's,#SERVICES#,$(smf_fmri),' $(dh_smf_postinst) >> debian/$$p.postinst.debhelper; \
+ done
else
#dh_installinit $(dhbuildpackages) --noscripts --name=exim4
# work around #347577 (fixed in debhelper 5.0.15)