summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2013-03-20 13:15:54 +0000
committerIgor Pashev <pashev.igor@gmail.com>2013-03-20 13:15:54 +0000
commit5267519989d3d2c7931faf45bde352664fdecde7 (patch)
tree3f531c8f1158cb2c8b34febd96c85529d5d3e5eb
parentd7612bd69aa082a7c9430ebb17a948f400b2cab9 (diff)
downloadmysql-5.5-5267519989d3d2c7931faf45bde352664fdecde7.tar.gz
Add SMF service
-rw-r--r--debian/changelog5
-rwxr-xr-xdebian/rules9
-rwxr-xr-xdebian/smf/mysql76
-rw-r--r--debian/smf/mysql.xml4
4 files changed, 89 insertions, 5 deletions
diff --git a/debian/changelog b/debian/changelog
index cda8760..7d2ef5b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-mysql-5.5 (5.5.30+dfsg-1+dyson1) UNRELEASED; urgency=low
+mysql-5.5 (5.5.30+dfsg-1+dyson1) unstable; urgency=low
[ Clint Byrum ]
* New upstream release.
@@ -9,8 +9,9 @@ mysql-5.5 (5.5.30+dfsg-1+dyson1) UNRELEASED; urgency=low
* Built for Dyson
* Disable dtrace (added Build-Conflicts) - we are not ready for it.
* Do not build depend on psmisc on illumos-any
+ * Add SMF service
- -- Igor Pashev <pashev.igor@gmail.com> Tue, 19 Mar 2013 00:51:14 +0000
+ -- Igor Pashev <pashev.igor@gmail.com> Wed, 20 Mar 2013 13:11:18 +0000
mysql-5.5 (5.5.29+dfsg-1) unstable; urgency=low
diff --git a/debian/rules b/debian/rules
index e5de371..2e85c87 100755
--- a/debian/rules
+++ b/debian/rules
@@ -216,7 +216,16 @@ override_dh_installlogrotate-arch:
# Start mysql in runlevel 19 before 20 where apache, proftpd etc gets
# started which might depend on a running database server.
override_dh_installinit-arch:
+ifeq (illumos,$(ARCH_OS))
+ mkdir -p debian/mysql-server-5.5/lib/svc/manifest/application/database
+ mkdir -p debian/mysql-server-5.5/lib/svc/method
+ install -m 644 -t debian/mysql-server-5.5/lib/svc/manifest/application/database \
+ debian/smf/mysql.xml
+ install -m 755 -t debian/mysql-server-5.5/lib/svc/method \
+ debian/smf/mysql
+else
dh_installinit --name=mysql -- defaults 19 21
+endif
override_dh_installcron-arch:
dh_installcron --name mysql-server
diff --git a/debian/smf/mysql b/debian/smf/mysql
new file mode 100755
index 0000000..ba7cefd
--- /dev/null
+++ b/debian/smf/mysql
@@ -0,0 +1,76 @@
+#!/bin/bash
+
+MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
+
+export HOME=/etc/mysql
+cd /
+umask 077
+
+mysqld_get_param() {
+ /usr/sbin/mysqld --print-defaults \
+ | tr " " "\n" \
+ | grep -- "--$1" \
+ | tail -n 1 \
+ | cut -d= -f2
+}
+
+## Checks if there is a server running and if so if it is accessible.
+#
+# check_alive insists on a pingable server
+# check_dead also fails if there is a lost mysqld in the process list
+#
+# Usage: boolean mysqld_status [check_alive|check_dead] [warn|nowarn]
+mysqld_status () {
+ ping_output=`$MYADMIN ping 2>&1`; ping_alive=$(( ! $? ))
+
+ ps_alive=0
+ pidfile=`mysqld_get_param pid-file`
+ if [ -f "$pidfile" ] && ps `cat $pidfile` >/dev/null 2>&1; then ps_alive=1; fi
+
+ if [ "$1" = "check_alive" -a $ping_alive = 1 ] ||
+ [ "$1" = "check_dead" -a $ping_alive = 0 -a $ps_alive = 0 ]; then
+ return 0 # EXIT_SUCCESS
+ else
+ if [ "$2" = "warn" ]; then
+ echo -e "$ps_alive processes alive and '$MYADMIN ping' resulted in\n$ping_output\n" | $ERR_LOGGER -p daemon.debug
+ fi
+ return 1 # EXIT_FAILURE
+ fi
+}
+
+start() {
+ test -e /var/run/mysqld || install -m 755 -o mysql -g root -d /var/run/mysqld
+ /usr/bin/mysqld_safe > /dev/null 2>&1 &
+ for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14; do
+ sleep 1
+ if mysqld_status check_alive nowarn ; then break; fi
+ done
+ if mysqld_status check_alive warn; then
+ output=$(/etc/mysql/debian-start)
+ [ -n "$output" ] && echo "$output"
+ else
+ echo "Please take a look at the syslog"
+ fi
+}
+
+stop() {
+ shutdown_out=`$MYADMIN shutdown 2>&1`; r=$?
+ if [ "$r" -ne 0 ]; then
+ echo "mysqld shutdown failed: $shutdown_out"
+ echo "killing by signal"
+ pidfile=`mysqld_get_param pid-file`
+ if [ -f "$pidfile" ]; then
+ pkill mysqld
+ fi
+ fi
+}
+
+refresh() {
+ $MYADMIN reload
+}
+
+case "$1" in
+ start) start;;
+ stop) stop;;
+ refresh) refresh;;
+esac
diff --git a/debian/smf/mysql.xml b/debian/smf/mysql.xml
index df21cd5..3ad9c62 100644
--- a/debian/smf/mysql.xml
+++ b/debian/smf/mysql.xml
@@ -10,10 +10,8 @@
</dependency>
<exec_method type="method" name="start" exec="/lib/svc/method/mysql start" timeout_seconds="60"/>
<exec_method type="method" name="stop" exec="/lib/svc/method/mysql stop" timeout_seconds="60"/>
+ <exec_method type="method" name="refresh" exec="/lib/svc/method/mysql refresh" timeout_seconds="60"/>
<instance name="default" enabled="true">
- <method_context>
- <method_credential user="mysql" group="mysql"/>
- </method_context>
</instance>
<stability value="Evolving"/>
<template>