From e618c8295d6a01df3f150830365ccc084f358393 Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Thu, 21 Mar 2013 00:50:28 +0000 Subject: SMF service needs active management --- debian/changelog | 6 ++++++ debian/mysql-server-5.5.postinst | 38 +++++++++++++++++++++++++++++++++----- debian/mysql-server-5.5.postrm | 14 +++++++++++++- debian/mysql-server-5.5.preinst | 23 +++++++++++++++++++++-- debian/smf/mysql.xml | 3 ++- 5 files changed, 75 insertions(+), 9 deletions(-) diff --git a/debian/changelog b/debian/changelog index 03ac240..ff1a686 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +mysql-5.5 (5.5.30+dfsg-1+dyson2) UNRELEASED; urgency=low + + * SMF service needs active management + + -- Igor Pashev Thu, 21 Mar 2013 00:49:09 +0000 + mysql-5.5 (5.5.30+dfsg-1+dyson1) unstable; urgency=low [ Clint Byrum ] diff --git a/debian/mysql-server-5.5.postinst b/debian/mysql-server-5.5.postinst index d13f9be..375e310 100644 --- a/debian/mysql-server-5.5.postinst +++ b/debian/mysql-server-5.5.postinst @@ -9,14 +9,25 @@ ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin +HAVE_SMF=no +SMF_INCLUDE=/lib/svc/share/smf_include.sh +if [ -f $SMF_INCLUDE ]; then + source $SMF_INCLUDE + if smf_present; then + HAVE_SMF=yes + fi +fi + # This command can be used as pipe to syslog. With "-s" it also logs to stderr. ERR_LOGGER="logger -p daemon.err -t mysqld_safe -i" -invoke() { - if [ -x /usr/sbin/invoke-rc.d ]; then - invoke-rc.d mysql $1 +stop_server() { + if [ $HAVE_SMF = yes ]; then + svcadm disable -t mysql:default >/dev/null 2>&1 + elif [ -x /usr/sbin/invoke-rc.d ]; then + invoke-rc.d mysql stop else - /etc/init.d/mysql $1 + /etc/init.d/mysql stop fi } @@ -60,7 +71,7 @@ EOF # and because changed configuration options should take effect immediately. # In case the server wasn't running at all it should be ok if the stop # script fails. I can't tell at this point because of the cleaned /var/run. -set +e; invoke stop; set -e +set +e; stop_server; set -e case "$1" in configure) @@ -278,6 +289,23 @@ fi db_stop # in case invoke failes +if [ $HAVE_SMF = yes ]; then + service=mysql:default + case `svcs -Ho STATE $service 2>/dev/null` in + online) + svcadm -v restart $service || true + ;; + + maintenance) + svcadm -v clear $service || true + ;; + + disabled) + svcadm -v enable $service || true + ;; + esac +fi + #DEBHELPER# exit 0 diff --git a/debian/mysql-server-5.5.postrm b/debian/mysql-server-5.5.postrm index c292652..6ea71df 100644 --- a/debian/mysql-server-5.5.postrm +++ b/debian/mysql-server-5.5.postrm @@ -12,12 +12,24 @@ ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf" +HAVE_SMF=no +SMF_INCLUDE=/lib/svc/share/smf_include.sh +if [ -f $SMF_INCLUDE ]; then + source $SMF_INCLUDE + if smf_present; then + HAVE_SMF=yes + fi +fi + + # Try to stop the server in a sane way. If it does not success let the admin # do it himself. No database directories should be removed while the server # is running! stop_server() { set +e - if [ -x /usr/sbin/invoke-rc.d ]; then + if [ $HAVE_SMF = yes ]; then + svcadm disable -t mysql:default >/dev/null 2>&1 + elif [ -x /usr/sbin/invoke-rc.d ]; then invoke-rc.d mysql stop else /etc/init.d/mysql stop diff --git a/debian/mysql-server-5.5.preinst b/debian/mysql-server-5.5.preinst index 7ab1518..edbd7e0 100644 --- a/debian/mysql-server-5.5.preinst +++ b/debian/mysql-server-5.5.preinst @@ -14,6 +14,16 @@ set -e if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } +HAVE_SMF=no +SMF_INCLUDE=/lib/svc/share/smf_include.sh +if [ -f $SMF_INCLUDE ]; then + source $SMF_INCLUDE + if smf_present; then + HAVE_SMF=yes + fi +fi + + export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf" DATADIR=/var/lib/mysql @@ -24,9 +34,18 @@ UPGRADEDIR=/var/lib/mysql-upgrade # do it himself. No database directories should be removed while the server # is running! Another mysqld in e.g. a different chroot is fine for us. stop_server() { - if [ ! -x /etc/init.d/mysql ]; then return; fi - set +e + + if [ $HAVE_SMF = yes ]; then + if [ x"`svcs -Ho state mysql:default`" != xdisabled ]; then + cmd="svcadm disable -t mysql:default >/dev/null 2>&1" + else + cmd=true + fi + elif [ ! -x /etc/init.d/mysql ]; then + return + fi + if [ -x /usr/sbin/invoke-rc.d ]; then cmd="invoke-rc.d mysql stop" else diff --git a/debian/smf/mysql.xml b/debian/smf/mysql.xml index 72878d3..8687438 100644 --- a/debian/smf/mysql.xml +++ b/debian/smf/mysql.xml @@ -8,7 +8,8 @@ - + + -- cgit v1.2.3