diff options
author | James Meyer <james.meyer@operamail.com> | 2012-10-29 19:05:46 (GMT) |
---|---|---|
committer | James Meyer <james.meyer@operamail.com> | 2012-10-29 19:05:46 (GMT) |
commit | 88b26331f2219c06ed6624d4e3094cd9e8ad7757 (patch) | |
tree | 472c35ab18a483d2d55243964d736c76db78b097 /abs/core/mysql/mysqld.rc | |
parent | a669c8442c818a1288d80f101faafe15400c7ab1 (diff) | |
download | linhes_pkgbuild-88b26331f2219c06ed6624d4e3094cd9e8ad7757.zip linhes_pkgbuild-88b26331f2219c06ed6624d4e3094cd9e8ad7757.tar.gz linhes_pkgbuild-88b26331f2219c06ed6624d4e3094cd9e8ad7757.tar.bz2 |
mysq: update to 5.5
Diffstat (limited to 'abs/core/mysql/mysqld.rc')
-rwxr-xr-x | abs/core/mysql/mysqld.rc | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/abs/core/mysql/mysqld.rc b/abs/core/mysql/mysqld.rc new file mode 100755 index 0000000..4bbddb5 --- /dev/null +++ b/abs/core/mysql/mysqld.rc @@ -0,0 +1,77 @@ +#!/bin/bash + +# general config +. /etc/rc.conf +. /etc/rc.d/functions + +getPID() { + echo $(pgrep -u mysql mysqld 2>/dev/null); +} + +case "$1" in + start) + stat_busy "Starting MySQL Server" + [ ! -d /run/mysqld ] && install -d -g mysql -o mysql /run/mysqld &>/dev/null + if [ -z "$(getPID)" ]; then + /usr/bin/mysqld_safe --user=mysql &>/dev/null & + if [ $? -gt 0 ]; then + stat_fail + exit 1 + else + timeo=30 + while [ $timeo -gt 0 ]; do + response=`/usr/bin/mysqladmin -uUNKNOWN_USER ping 2>&1` && break + echo "$response" | grep -q "mysqld is alive" && break + sleep 1 + let timeo=${timeo}-1 + done + if [ $timeo -eq 0 ]; then + stat_fail + exit 1 + else + echo $(getPID) > /run/mysqld/mysqld.pid + add_daemon mysqld + stat_done + fi + fi + else + stat_fail + exit 1 + fi + ;; + + stop) + stat_busy "Stopping MySQL Server" + if [ ! -z "$(getPID)" ]; then + timeo=30 + kill $(getPID) &> /dev/null + if [ $? -gt 0 ]; then + stat_fail + exit 1 + fi + while [ ! -z "$(getPID)" -a $timeo -gt 0 ]; do + sleep 1 + let timeo=${timeo}-1 + done + if [ -z "$(getPID)" ]; then + rm -f /run/mysqld/mysqld.pid &>/dev/null + rm_daemon mysqld + stat_done + else + stat_fail + exit 1 + fi + else + stat_fail + exit 1 + fi + ;; + + restart) + $0 stop + $0 start + ;; + *) + echo "usage: $0 {start|stop|restart}" +esac +exit 0 |