Репозиторий Sisyphus
Последнее обновление: 18 августа 2019 | Пакетов: 17338 | Посещений: 14654283
en ru br
Репозитории ALT

Группа :: Базы Данных
Пакет: mariadb

 Главная   Изменения   Спек   Патчи   Исходники   Загрузить   Gear   Bugs and FR  Repocop 

#!/bin/sh
#
# chkconfig: - 80 20
#
# description: The start/stop script for MySQL - \
# very fast and reliable SQL database engine.
#

WITHOUT_RC_COMPAT=1

# Source function library.
. /etc/init.d/functions

ROOT=/var/lib/mysql
#DATADIR=`/usr/bin/my_print_defaults mysqld |sed -ne 's/^--datadir=\(.*\)/\1/pg' |tail -1`
LOCKFILE="/var/lock/subsys/mysqld"
PIDFILE="/var/run/mysqld/mysqld.pid"
RETVAL=0

SourceIfNotEmpty /etc/sysconfig/mysqld

[ -z "$OPT" ] && OPT=""

adjust()
{
# don't run mysql_install_db script if mysql.user table exists
eval echo 'describe mysql.user;' | mysqld --bootstrap --max_allowed_packet=8M --net_buffer_length=16K >/dev/null 2>&1 || /usr/sbin/mysql_install_db

# action "Adjusting environment for mysqld:" /etc/chroot.d/mysql.all
RETVAL=$?
return $RETVAL
}

charset()
{
if [ ! -z "$CHSET" ]; then
fgrep -qs 'charset name="'$CHSET'"' /usr/share/mysql/charsets/Index.xml && return \
|| echo "Unable to find charset: $CHSET"
fi
unset LANG LANGUAGE LC_ALL
default_charset="$(HOME=/var/empty . /etc/profile.d/lang.sh && locale |sed -ne 's/^LC_COLLATE="\?[^".]\+\.\([^"]\+\)"\?$/\1/p')"
case "$default_charset" in
CP1251)
CHSET=cp1251
;;
KOI8-R)
CHSET=koi8r
;;
KOI8-U)
CHSET=koi8u
;;
UTF-8)
CHSET=utf8
;;
*)
echo "Unable to find proper charset from system locale, setting 'utf8'."
echo "Please edit mysqld init script and set proper charset."
CHSET=utf8
;;
esac
}

stop_wait()
{
for (( i=$1; $i>0; i=(($i-1)) )); do
start-stop-daemon --stop --name mysqld --pidfile "$PIDFILE" --user mysql --test >/dev/null 2>&1 || return
printf '%5s' "$i"
sleep 1
printf "\b\b\b\b\b \b\b\b\b\b"
done
return 255
}


start()
{
adjust || return
charset
start_daemon --lockfile "$LOCKFILE" --pidfile "$PIDFILE" --name mysqld --expect-user mysql -- safe_mysqld -C "$CHSET" $OPT
RETVAL=$?
return $RETVAL
}

stop()
{
echo -n "Sending TERM signal to mysqld: "
stop_daemon --lockfile "$LOCKFILE" --pidfile "$PIDFILE" --name mysqld --expect-user mysql -TERM -- mysqld

echo -n "Waiting, while mysqld actualy stopped:"
stop_wait 300
RETVAL=$?

if [ $RETVAL == 255 ]; then
echo_failure
echo
stop_daemon --lockfile "$LOCKFILE" --pidfile "$PIDFILE" --name mysqld --expect-user mysql -- mysqld
RETVAL=$?
return $RETVAL
else
echo_success
echo
return $RETVAL
fi
return $RETVAL
}

restart()
{
stop
start
}

reload()
{
msg_reloading mysqld
stop_daemon --pidfile "$PIDFILE" --expect-user mysql -HUP -- mysqld
RETVAL=$?
return $RETVAL
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
reload
;;
condstop)
if [ -e "$LOCKFILE" ]; then
stop
fi
;;
condrestart)
if [ -e "$LOCKFILE" ]; then
restart
fi
;;
status)
status --pidfile "$PIDFILE" --expect-user mysql mysqld
RETVAL=$?
;;
*)
msg_usage "${0##*/} {start|stop|reload|restart|reload|condstop|condrestart|status}"
RETVAL=1
esac

exit $RETVAL
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin