[debian-mysql] Bug#732558: mysql-server-5.5: Security upgrade 5.5.33+dfsg-0+wheezy1 failed
Bob Proulx
bob at proulx.com
Wed Dec 18 19:13:41 UTC 2013
Package: mysql-server-5.5
Version: 5.5.33+dfsg-0+wheezy1
Severity: normal
A fully up to date system with mysql server 5.5.31+dfsg-0+wheezy1
installed and installing the security upgrade 5.5.33+dfsg-0+wheezy1
has failed to restart afterward. Here are the details as I have them.
root at leibniz:~# apt-get update -qq
root at leibniz:~# apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]?
Setting up mysql-server-5.5 (5.5.33+dfsg-0+wheezy1) ...
Stopping MySQL database server: mysqld.
Starting MySQL database server: mysqld . ..
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing mysql-server-5.5 (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.5; however:
Package mysql-server-5.5 is not configured yet.
dpkg: error processing mysql-server (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
mysql-server-5.5
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
root at leibniz:~# dpkg -l | grep mysql
ii libdatetime-format-mysql-perl 0.04-2 all Parse and format MySQL dates and times
ii libdbd-mysql-perl 4.021-1+b1 amd64 Perl5 database interface to the MySQL database
ii libmysqlclient18:amd64 5.5.33+dfsg-0+wheezy1 amd64 MySQL database client library
ii mysql-client-5.5 5.5.33+dfsg-0+wheezy1 amd64 MySQL database client binaries
ii mysql-common 5.5.33+dfsg-0+wheezy1 all MySQL database common files, e.g. /etc/mysql/my.cnf
iU mysql-server 5.5.33+dfsg-0+wheezy1 all MySQL database server (metapackage depending on the latest version)
iF mysql-server-5.5 5.5.33+dfsg-0+wheezy1 amd64 MySQL database server binaries and system database setup
ii mysql-server-core-5.5 5.5.33+dfsg-0+wheezy1 amd64 MySQL database server binaries
Looking at the scripts it looks like there are some debug variables.
Setting those to obtain some debug information.
root at leibniz:~# DEBIAN_SCRIPT_TRACE=1 dpkg --configure mysql-server-5.5
Setting up mysql-server-5.5 (5.5.33+dfsg-0+wheezy1) ...
#42#DEBUG# RUNNING /var/lib/dpkg/info/mysql-server-5.5.config configure 5.5.31+dfsg-0+wheezy1 1>&2
#42#DEBUG# RUNNING /var/lib/dpkg/info/mysql-server-5.5.postinst configure 5.5.31+dfsg-0+wheezy1 1>&2
Stopping MySQL database server: mysqld.
Starting MySQL database server: mysqld . ..
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing mysql-server-5.5 (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
mysql-server-5.5
root at leibniz:~# DEBIAN_SCRIPT_DEBUG=1 dpkg --configure mysql-server-5.5
...very long...attached as a separate file...
This is a production machine so I must clear the error soon and get it
back online. I will try to create a snapshot of the current error
state for analysis but I expect the next step is to purge all and then
install fresh and import a backup of the database.
Bob
-------------- next part --------------
Setting up mysql-server-5.5 (5.5.33+dfsg-0+wheezy1) ...
+ DEBIAN_SCRIPT_TRACE=1
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
+ echo '#42#DEBUG# RUNNING /var/lib/dpkg/info/mysql-server-5.5.config configure 5.5.31+dfsg-0+wheezy1' '1>&2'
#42#DEBUG# RUNNING /var/lib/dpkg/info/mysql-server-5.5.config configure 5.5.31+dfsg-0+wheezy1 1>&2
CNF=/etc/mysql/my.cnf
+ CNF=/etc/mysql/my.cnf
# Beware that there are two ypwhich one of them needs the 2>/dev/null!
if test -n "`which ypwhich 2>/dev/null`" && ypwhich >/dev/null 2>&1; then
db_input high mysql-server-5.5/nis_warning || true
db_go
fi
which ypwhich 2>/dev/null
++ which ypwhich
+ test -n /usr/bin/ypwhich
+ ypwhich
+ db_input high mysql-server-5.5/nis_warning
+ _db_cmd 'INPUT high' mysql-server-5.5/nis_warning
+ _db_internal_IFS='
'
+ IFS=' '
+ printf '%s\n' 'INPUT high mysql-server-5.5/nis_warning'
+ IFS='
'
+ IFS='
'
+ read -r _db_internal_line
+ RET='30 question skipped'
+ case ${_db_internal_line%%[ ]*} in
+ return 30
+ true
+ db_go
+ _db_cmd 'GO '
+ _db_internal_IFS='
'
+ IFS=' '
+ printf '%s\n' 'GO '
+ IFS='
'
+ IFS='
'
+ read -r _db_internal_line
+ RET=ok
+ case ${_db_internal_line%%[ ]*} in
+ return 0
# only ask this question on fresh installs, during "reconfiguration" and when
# not upgrading from an existing 5.0 installation.
# there is also an additional check for empty root passwords in the
# postinst script when the tools are available for us to use.
if [ "$1" = "configure" ] && ([ -z "$2" ] && [ ! -e "/var/lib/mysql/debian-5.0.flag" ] ) || [ "$1" = "reconfigure" ]; then
while :; do
RET=""
db_input high mysql-server/root_password || true
db_go
db_get mysql-server/root_password
# if password isn't empty we ask for password verification
if [ -z "$RET" ]; then
db_fset mysql-server/root_password seen false
db_fset mysql-server/root_password_again seen false
break
fi
ROOT_PW="$RET"
db_input high mysql-server/root_password_again || true
db_go
db_get mysql-server/root_password_again
if [ "$RET" == "$ROOT_PW" ]; then
ROOT_PW=''
break
fi
db_fset mysql-server/password_mismatch seen false
db_input critical mysql-server/password_mismatch
db_set mysql-server/root_password ""
db_set mysql-server/root_password_again ""
db_go
done
fi
+ '[' configure = configure ']'
+ '[' -z 5.5.31+dfsg-0+wheezy1 ']'
+ '[' configure = reconfigure ']'
+ DEBIAN_SCRIPT_TRACE=1
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
+ echo '#42#DEBUG# RUNNING /var/lib/dpkg/info/mysql-server-5.5.postinst configure 5.5.31+dfsg-0+wheezy1' '1>&2'
#42#DEBUG# RUNNING /var/lib/dpkg/info/mysql-server-5.5.postinst configure 5.5.31+dfsg-0+wheezy1 1>&2
export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin
+ export PATH=/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/sbin:/usr/sbin:/bin:/usr/bin
+ PATH=/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/sbin:/usr/sbin:/bin:/usr/bin
# 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"
+ ERR_LOGGER='logger -p daemon.err -t mysqld_safe -i'
invoke() {
if [ -x /usr/sbin/invoke-rc.d ]; then
invoke-rc.d mysql $1
else
/etc/init.d/mysql $1
fi
}
MYSQL_BOOTSTRAP="/usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables"
+ MYSQL_BOOTSTRAP='/usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables'
test_mysql_access() {
mysql --no-defaults -u root -h localhost </dev/null >/dev/null 2>&1
}
# call with $1 = "online" to connect to the server, otherwise it bootstraps
set_mysql_rootpw() {
# forget we ever saw the password. don't use reset to keep the seen status
db_set mysql-server/root_password ""
db_set mysql-server/root_password_again ""
tfile=`mktemp`
if [ ! -f "$tfile" ]; then
return 1
fi
# this avoids us having to call "test" or "[" on $rootpw
cat << EOF > $tfile
USE mysql;
UPDATE user SET password=PASSWORD("$rootpw") WHERE user='root';
FLUSH PRIVILEGES;
EOF
if grep -q 'PASSWORD("")' $tfile; then
retval=0
elif [ "$1" = "online" ]; then
mysql --no-defaults -u root -h localhost <$tfile >/dev/null
retval=$?
else
$MYSQL_BOOTSTRAP <$tfile
retval=$?
fi
rm -f $tfile
return $retval
}
# This is necessary because mysql_install_db removes the pid file in /var/run
# 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
+ invoke stop
+ '[' -x /usr/sbin/invoke-rc.d ']'
+ invoke-rc.d mysql stop
test -x /usr/bin/mysqld_safe || exit 0
+ test -x /usr/bin/mysqld_safe
. /lib/lsb/init-functions
+ . /lib/lsb/init-functions
# /lib/lsb/init-functions for Debian -*- shell-script -*-
#
#Copyright (c) 2002-08 Chris Lawrence
#All rights reserved.
#
#Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions
#are met:
#1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#3. Neither the name of the author nor the names of other contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
#THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
#IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
#ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
#LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
#CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
#SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
#BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
#OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
#EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
start_daemon () {
local force nice pidfile exec args OPTIND
force=""
nice=0
pidfile=/dev/null
OPTIND=1
while getopts fn:p: opt ; do
case "$opt" in
f) force="force";;
n) nice="$OPTARG";;
p) pidfile="$OPTARG";;
esac
done
shift $(($OPTIND - 1))
if [ "$1" = '--' ]; then
shift
fi
exec="$1"; shift
args="--start --nicelevel $nice --quiet --oknodo"
if [ "$force" ]; then
/sbin/start-stop-daemon $args \
--chdir "$PWD" --startas $exec --pidfile /dev/null -- "$@"
elif [ $pidfile ]; then
/sbin/start-stop-daemon $args \
--chdir "$PWD" --exec $exec --oknodo --pidfile "$pidfile" -- "$@"
else
/sbin/start-stop-daemon $args --chdir "$PWD" --exec $exec -- "$@"
fi
}
pidofproc () {
local pidfile base status specified pid OPTIND
pidfile=
specified=
OPTIND=1
while getopts p: opt ; do
case "$opt" in
p) pidfile="$OPTARG"
specified="specified"
;;
esac
done
shift $(($OPTIND - 1))
base=${1##*/}
if [ ! "$specified" ]; then
pidfile="/var/run/$base.pid"
fi
if [ -n "${pidfile:-}" ]; then
if [ -e "$pidfile" ]; then
if [ -r "$pidfile" ]; then
read pid < "$pidfile"
if [ -n "${pid:-}" ]; then
if $(kill -0 "${pid:-}" 2> /dev/null); then
echo "$pid" || true
return 0
elif ps "${pid:-}" >/dev/null 2>&1; then
echo "$pid" || true
return 0 # program is running, but not owned by this user
else
return 1 # program is dead and /var/run pid file exists
fi
fi
else
return 4 # pid file not readable, hence status is unknown.
fi
else
# pid file doesn't exist, try to find the pid nevertheless
if [ -x /bin/pidof ] && [ ! "$specified" ]; then
status="0"
/bin/pidof -o %PPID -x $1 || status="$?"
if [ "$status" = 1 ]; then
return 3 # program is not running
fi
return 0
fi
return 3 # specified pid file doesn't exist, program probably stopped
fi
fi
if [ "$specified" ]; then
return 3 # almost certain it's not running
fi
return 4 # Unable to determine status
}
# start-stop-daemon uses the same algorithm as "pidofproc" above.
killproc () {
local pidfile sig status base name_param is_term_sig OPTIND
pidfile=
name_param=
is_term_sig=
OPTIND=1
while getopts p: opt ; do
case "$opt" in
p) pidfile="$OPTARG";;
esac
done
shift $(($OPTIND - 1))
base=${1##*/}
if [ ! $pidfile ]; then
name_param="--name $base --pidfile /var/run/$base.pid"
else
name_param="--pidfile $pidfile"
fi
sig=$(echo ${2:-} | sed -e 's/^-\(.*\)/\1/')
sig=$(echo $sig | sed -e 's/^SIG\(.*\)/\1/')
if [ "$sig" = 15 ] || [ "$sig" = TERM ]; then
is_term_sig="terminate_signal"
fi
status=0
if [ ! "$is_term_sig" ]; then
if [ -n "$sig" ]; then
/sbin/start-stop-daemon --stop --signal "$sig" \
--quiet $name_param || status="$?"
else
/sbin/start-stop-daemon --stop \
--retry 5 \
--quiet $name_param || status="$?"
fi
else
/sbin/start-stop-daemon --stop --quiet \
--oknodo $name_param || status="$?"
fi
if [ "$status" = 1 ]; then
if [ -z "$sig" ]; then
return 0
fi
return 3 # program is not running
fi
if [ "$status" = 0 ] && [ "$is_term_sig" ] && [ "$pidfile" ]; then
pidofproc -p "$pidfile" "$1" >/dev/null || rm -f "$pidfile"
fi
return 0
}
# Return LSB status
status_of_proc () {
local pidfile daemon name status OPTIND
pidfile=
OPTIND=1
while getopts p: opt ; do
case "$opt" in
p) pidfile="$OPTARG";;
esac
done
shift $(($OPTIND - 1))
if [ -n "$pidfile" ]; then
pidfile="-p $pidfile"
fi
daemon="$1"
name="$2"
status="0"
pidofproc $pidfile $daemon >/dev/null || status="$?"
if [ "$status" = 0 ]; then
log_success_msg "$name is running"
return 0
elif [ "$status" = 4 ]; then
log_failure_msg "could not access PID file for $name"
return $status
else
log_failure_msg "$name is not running"
return $status
fi
}
log_use_fancy_output () {
TPUT=/usr/bin/tput
EXPR=/usr/bin/expr
if [ -t 1 ] &&
[ "x${TERM:-}" != "x" ] &&
[ "x${TERM:-}" != "xdumb" ] &&
[ -x $TPUT ] && [ -x $EXPR ] &&
$TPUT hpa 60 >/dev/null 2>&1 &&
$TPUT setaf 1 >/dev/null 2>&1
then
[ -z $FANCYTTY ] && FANCYTTY=1 || true
else
FANCYTTY=0
fi
case "$FANCYTTY" in
1|Y|yes|true) true;;
*) false;;
esac
}
log_success_msg () {
if [ -n "${1:-}" ]; then
log_begin_msg $@
fi
log_end_msg 0
}
log_failure_msg () {
if [ -n "${1:-}" ]; then
log_begin_msg $@ "..."
fi
log_end_msg 1 || true
}
log_warning_msg () {
if [ -n "${1:-}" ]; then
log_begin_msg $@ "..."
fi
log_end_msg 255 || true
}
#
# NON-LSB HELPER FUNCTIONS
#
# int get_lsb_header_val (char *scriptpathname, char *key)
get_lsb_header_val () {
if [ ! -f "$1" ] || [ -z "${2:-}" ]; then
return 1
fi
LSB_S="### BEGIN INIT INFO"
LSB_E="### END INIT INFO"
sed -n "/$LSB_S/,/$LSB_E/ s/# $2: \(.*\)/\1/p" $1
}
# If the currently running init daemon is upstart, return zero; if the
# calling init script belongs to a package which also provides a native
# upstart job, it should generally exit non-zero in this case.
init_is_upstart()
{
if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | /bin/grep -q upstart; then
return 0
fi
return 1
}
# int log_begin_message (char *message)
log_begin_msg () {
log_begin_msg_pre "$@"
if [ -z "${1:-}" ]; then
return 1
fi
/bin/echo -n "$@" || true
log_begin_msg_post "$@"
}
# Sample usage:
# log_daemon_msg "Starting GNOME Login Manager" "gdm"
#
# On Debian, would output "Starting GNOME Login Manager: gdm"
# On Ubuntu, would output " * Starting GNOME Login Manager..."
#
# If the second argument is omitted, logging suitable for use with
# log_progress_msg() is used:
#
# log_daemon_msg "Starting remote filesystem services"
#
# On Debian, would output "Starting remote filesystem services:"
# On Ubuntu, would output " * Starting remote filesystem services..."
log_daemon_msg () {
if [ -z "${1:-}" ]; then
return 1
fi
log_daemon_msg_pre "$@"
if [ -z "${2:-}" ]; then
/bin/echo -n "$1:" || true
return
fi
/bin/echo -n "$1: $2" || true
log_daemon_msg_post "$@"
}
# #319739
#
# Per policy docs:
#
# log_daemon_msg "Starting remote file system services"
# log_progress_msg "nfsd"; start-stop-daemon --start --quiet nfsd
# log_progress_msg "mountd"; start-stop-daemon --start --quiet mountd
# log_progress_msg "ugidd"; start-stop-daemon --start --quiet ugidd
# log_end_msg 0
#
# You could also do something fancy with log_end_msg here based on the
# return values of start-stop-daemon; this is left as an exercise for
# the reader...
#
# On Ubuntu, one would expect log_progress_msg to be a no-op.
log_progress_msg () {
if [ -z "${1:-}" ]; then
return 1
fi
/bin/echo -n " $@" || true
}
# int log_end_message (int exitstatus)
log_end_msg () {
# If no arguments were passed, return
if [ -z "${1:-}" ]; then
return 1
fi
local retval
retval=$1
log_end_msg_pre "$@"
# Only do the fancy stuff if we have an appropriate terminal
# and if /usr is already mounted
if log_use_fancy_output; then
RED=$( $TPUT setaf 1)
YELLOW=$( $TPUT setaf 3)
NORMAL=$( $TPUT op)
else
RED=''
YELLOW=''
NORMAL=''
fi
if [ $1 -eq 0 ]; then
echo "." || true
elif [ $1 -eq 255 ]; then
/bin/echo -e " ${YELLOW}(warning).${NORMAL}" || true
else
/bin/echo -e " ${RED}failed!${NORMAL}" || true
fi
log_end_msg_post "$@"
return $retval
}
log_action_msg () {
log_action_msg_pre "$@"
echo "$@." || true
log_action_msg_post "$@"
}
log_action_begin_msg () {
log_action_begin_msg_pre "$@"
/bin/echo -n "$@..." || true
log_action_begin_msg_post "$@"
}
log_action_cont_msg () {
/bin/echo -n "$@..." || true
}
log_action_end_msg () {
local end
log_action_end_msg_pre "$@"
if [ -z "${2:-}" ]; then
end="."
else
end=" ($2)."
fi
if [ $1 -eq 0 ]; then
echo "done${end}" || true
else
if log_use_fancy_output; then
RED=$( $TPUT setaf 1)
NORMAL=$( $TPUT op)
/bin/echo -e "${RED}failed${end}${NORMAL}" || true
else
echo "failed${end}" || true
fi
fi
log_action_end_msg_post "$@"
}
# Pre&Post empty function declaration, to be overriden from /lib/lsb/init-functions.d/*
log_daemon_msg_pre () { :; }
log_daemon_msg_post () { :; }
log_begin_msg_pre () { :; }
log_begin_msg_post () { :; }
log_end_msg_pre () { :; }
log_end_msg_post () { :; }
log_action_msg_pre () { :; }
log_action_msg_post () { :; }
log_action_begin_msg_pre () { :; }
log_action_begin_msg_post () { :; }
log_action_end_msg_pre () { :; }
log_action_end_msg_post () { :; }
# Include hooks from other packages in /lib/lsb/init-functions.d
for hook in $(run-parts --lsbsysinit --list /lib/lsb/init-functions.d 2>/dev/null); do
[ -r $hook ] && . $hook || true
done
run-parts --lsbsysinit --list /lib/lsb/init-functions.d 2>/dev/null)
run-parts --lsbsysinit --list /lib/lsb/init-functions.d 2>/dev/null
+++ run-parts --lsbsysinit --list /lib/lsb/init-functions.d
++ for hook in '$(run-parts --lsbsysinit --list /lib/lsb/init-functions.d 2>/dev/null)'
++ '[' -r /lib/lsb/init-functions.d/20-left-info-blocks ']'
++ . /lib/lsb/init-functions.d/20-left-info-blocks
# Default info blocks put to the left of the screen
log_daemon_msg_pre () {
if log_use_fancy_output; then
/bin/echo -n "[....] " || true
fi
}
log_begin_msg_pre () {
log_daemon_msg_pre "$@"
}
log_end_msg_pre () {
if log_use_fancy_output; then
RED=$( $TPUT setaf 1)
GREEN=$( $TPUT setaf 2)
YELLOW=$( $TPUT setaf 3)
NORMAL=$( $TPUT op)
$TPUT civis || true
$TPUT sc && \
$TPUT hpa 0 && \
if [ $1 -eq 0 ]; then
/bin/echo -ne "[${GREEN} ok ${NORMAL}" || true
elif [ $1 -eq 255 ]; then
/bin/echo -ne "[${YELLOW}warn${NORMAL}" || true
else
/bin/echo -ne "[${RED}FAIL${NORMAL}" || true
fi && \
$TPUT rc || true
$TPUT cnorm || true
fi
}
log_action_msg_pre () {
if log_use_fancy_output; then
CYAN=$( $TPUT setaf 6)
NORMAL=$( $TPUT op)
/bin/echo -ne "[${CYAN}info${NORMAL}] " || true
fi
}
log_action_begin_msg_pre () {
log_daemon_msg_pre "$@"
}
log_action_end_msg_pre () {
log_end_msg_pre "$@"
}
FANCYTTY=
++ FANCYTTY=
[ -e /etc/lsb-base-logging.sh ] && . /etc/lsb-base-logging.sh || true
++ '[' -e /etc/lsb-base-logging.sh ']'
++ . /etc/lsb-base-logging.sh
FANCYTTY=no
+++ FANCYTTY=no
SELF=$(cd $(dirname $0); pwd -P)/$(basename $0)
cd $(dirname $0); pwd -P)/$(basename $0)
cd $(dirname $0); pwd -P
dirname $0)
dirname $0
+++ dirname /etc/init.d/mysql
++ cd /etc/init.d
++ pwd -P
basename $0)
basename $0
++ basename /etc/init.d/mysql
+ SELF=/etc/init.d/mysql
CONF=/etc/mysql/my.cnf
+ CONF=/etc/mysql/my.cnf
MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
+ MYADMIN='/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf'
# priority can be overriden and "-s" adds output to stderr
ERR_LOGGER="logger -p daemon.err -t /etc/init.d/mysql -i"
+ ERR_LOGGER='logger -p daemon.err -t /etc/init.d/mysql -i'
# Safeguard (relative paths, core dumps..)
cd /
+ cd /
umask 077
+ umask 077
# mysqladmin likes to read /root/.my.cnf. This is usually not what I want
# as many admins e.g. only store a password without a username there and
# so break my scripts.
export HOME=/etc/mysql/
+ export HOME=/etc/mysql/
+ HOME=/etc/mysql/
## Fetch a particular option from mysql's invocation.
#
# Usage: void mysqld_get_param option
mysqld_get_param() {
/usr/sbin/mysqld --print-defaults \
| tr " " "\n" \
| grep -- "--$1" \
| tail -n 1 \
| cut -d= -f2
}
## Do some sanity checks before even trying to start mysqld.
sanity_checks() {
# check for config file
if [ ! -r /etc/mysql/my.cnf ]; then
log_warning_msg "$0: WARNING: /etc/mysql/my.cnf cannot be read. See README.Debian.gz"
echo "WARNING: /etc/mysql/my.cnf cannot be read. See README.Debian.gz" | $ERR_LOGGER
fi
# check for diskspace shortage
datadir=`mysqld_get_param datadir`
if LC_ALL=C BLOCKSIZE= df --portability $datadir/. | tail -n 1 | awk '{ exit ($4>4096) }'; then
log_failure_msg "$0: ERROR: The partition with $datadir is too full!"
echo "ERROR: The partition with $datadir is too full!" | $ERR_LOGGER
exit 1
fi
}
## 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
}
#
# main()
#
case "${1:-''}" in
'start')
sanity_checks;
# Start daemon
log_daemon_msg "Starting MySQL database server" "mysqld"
if mysqld_status check_alive nowarn; then
log_progress_msg "already running"
log_end_msg 0
else
# Could be removed during boot
test -e /var/run/mysqld || install -m 755 -o mysql -g root -d /var/run/mysqld
# Start MySQL!
/usr/bin/mysqld_safe > /dev/null 2>&1 &
# 6s was reported in #352070 to be too few when using ndbcluster
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
log_progress_msg "."
done
if mysqld_status check_alive warn; then
log_end_msg 0
# Now start mysqlcheck or whatever the admin wants.
output=$(/etc/mysql/debian-start)
[ -n "$output" ] && log_action_msg "$output"
else
log_end_msg 1
log_failure_msg "Please take a look at the syslog"
fi
fi
;;
'stop')
# * As a passwordless mysqladmin (e.g. via ~/.my.cnf) must be possible
# at least for cron, we can rely on it here, too. (although we have
# to specify it explicit as e.g. sudo environments points to the normal
# users home and not /root)
log_daemon_msg "Stopping MySQL database server" "mysqld"
if ! mysqld_status check_dead nowarn; then
set +e
shutdown_out=`$MYADMIN shutdown 2>&1`; r=$?
set -e
if [ "$r" -ne 0 ]; then
log_end_msg 1
[ "$VERBOSE" != "no" ] && log_failure_msg "Error: $shutdown_out"
log_daemon_msg "Killing MySQL database server by signal" "mysqld"
killall -15 mysqld
server_down=
for i in 1 2 3 4 5 6 7 8 9 10; do
sleep 1
if mysqld_status check_dead nowarn; then server_down=1; break; fi
done
if test -z "$server_down"; then killall -9 mysqld; fi
fi
fi
if ! mysqld_status check_dead warn; then
log_end_msg 1
log_failure_msg "Please stop MySQL manually and read /usr/share/doc/mysql-server-5.5/README.Debian.gz!"
exit -1
else
log_end_msg 0
fi
;;
'restart')
set +e; $SELF stop; set -e
$SELF start
;;
'reload'|'force-reload')
log_daemon_msg "Reloading MySQL database server" "mysqld"
$MYADMIN reload
log_end_msg 0
;;
'status')
if mysqld_status check_alive nowarn; then
log_action_msg "$($MYADMIN version)"
else
log_action_msg "MySQL is stopped."
exit 3
fi
;;
*)
echo "Usage: $SELF start|stop|restart|reload|force-reload|status"
exit 1
;;
esac
+ case "${1:-''}" in
+ log_daemon_msg 'Stopping MySQL database server' mysqld
+ '[' -z 'Stopping MySQL database server' ']'
+ log_daemon_msg_pre 'Stopping MySQL database server' mysqld
+ log_use_fancy_output
+ TPUT=/usr/bin/tput
+ EXPR=/usr/bin/expr
+ '[' -t 1 ']'
+ FANCYTTY=0
+ case "$FANCYTTY" in
+ false
+ '[' -z mysqld ']'
+ /bin/echo -n 'Stopping MySQL database server: mysqld'
Stopping MySQL database server: mysqld+ log_daemon_msg_post 'Stopping MySQL database server' mysqld
+ :
+ mysqld_status check_dead nowarn
$MYADMIN ping 2>&1
++ /usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping
+ ping_output='mysqld is alive'
+ ping_alive=1
+ ps_alive=0
mysqld_get_param pid-file
++ mysqld_get_param pid-file
++ grep -- --pid-file
++ /usr/sbin/mysqld --print-defaults
++ tail -n 1
++ tr ' ' '\n'
++ cut -d= -f2
+ pidfile=/var/run/mysqld/mysqld.pid
+ '[' -f /var/run/mysqld/mysqld.pid ']'
cat $pidfile
++ cat /var/run/mysqld/mysqld.pid
+ ps 15420
+ ps_alive=1
+ '[' check_dead = check_alive -a 1 = 1 ']'
+ '[' check_dead = check_dead -a 1 = 0 -a 1 = 0 ']'
+ '[' nowarn = warn ']'
+ return 1
+ set +e
$MYADMIN shutdown 2>&1
++ /usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf shutdown
+ shutdown_out=
+ r=0
+ set -e
+ '[' 0 -ne 0 ']'
+ mysqld_status check_dead warn
$MYADMIN ping 2>&1
++ /usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping
+ ping_output='/usr/bin/mysqladmin: connect to server at '\''localhost'\'' failed
error: '\''Can'\''t connect to local MySQL server through socket '\''/var/run/mysqld/mysqld.sock'\'' (2)'\''
Check that mysqld is running and that the socket: '\''/var/run/mysqld/mysqld.sock'\'' exists!'
+ ping_alive=0
+ ps_alive=0
mysqld_get_param pid-file
++ mysqld_get_param pid-file
++ grep -- --pid-file
++ /usr/sbin/mysqld --print-defaults
++ tr ' ' '\n'
++ tail -n 1
++ cut -d= -f2
+ pidfile=/var/run/mysqld/mysqld.pid
+ '[' -f /var/run/mysqld/mysqld.pid ']'
+ '[' check_dead = check_alive -a 0 = 1 ']'
+ '[' check_dead = check_dead -a 0 = 0 -a 0 = 0 ']'
+ return 0
+ log_end_msg 0
+ '[' -z 0 ']'
+ local retval
+ retval=0
+ log_end_msg_pre 0
+ log_use_fancy_output
+ TPUT=/usr/bin/tput
+ EXPR=/usr/bin/expr
+ '[' -t 1 ']'
+ FANCYTTY=0
+ case "$FANCYTTY" in
+ false
+ log_use_fancy_output
+ TPUT=/usr/bin/tput
+ EXPR=/usr/bin/expr
+ '[' -t 1 ']'
+ FANCYTTY=0
+ case "$FANCYTTY" in
+ false
+ RED=
+ YELLOW=
+ NORMAL=
+ '[' 0 -eq 0 ']'
+ echo .
.
+ log_end_msg_post 0
+ :
+ return 0
+ set -e
case "$1" in
configure)
mysql_datadir=/usr/share/mysql
mysql_statedir=/var/lib/mysql
mysql_rundir=/var/run/mysqld
mysql_logdir=/var/log
mysql_cfgdir=/etc/mysql
mysql_newlogdir=/var/log/mysql
mysql_upgradedir=/var/lib/mysql-upgrade
# first things first, if the following symlink exists, it is a preserved
# copy the old data dir from a mysql upgrade that would have otherwise
# been replaced by an empty mysql dir. this should restore it.
for dir in DATADIR LOGDIR; do
if [ "$dir" = "DATADIR" ]; then targetdir=$mysql_statedir; else targetdir=$mysql_newlogdir; fi
savelink="$mysql_upgradedir/$dir.link"
if [ -L "$savelink" ]; then
# If the targetdir was a symlink before we upgraded it is supposed
# to be either still be present or not existing anymore now.
if [ -L "$targetdir" ]; then
rm "$savelink"
elif [ ! -d "$targetdir" ]; then
mv "$savelink" "$targetdir"
else
# this should never even happen, but just in case...
mysql_tmp=`mktemp -d -t mysql-symlink-restore-XXXXXX`
echo "this is very strange! see $mysql_tmp/README..." >&2
mv "$targetdir" "$mysql_tmp"
cat << EOF > "$mysql_tmp/README"
if you're reading this, it's most likely because you had replaced /var/lib/mysql
with a symlink, then upgraded to a new version of mysql, and then dpkg
removed your symlink (see #182747 and others). the mysql packages noticed
that this happened, and as a workaround have restored it. however, because
/var/lib/mysql seems to have been re-created in the meantime, and because
we don't want to rm -rf something we don't know as much about, we're going
to leave this unexpected directory here. if your database looks normal,
and this is not a symlink to your database, you should be able to blow
this all away.
EOF
fi
fi
rmdir $mysql_upgradedir 2>/dev/null || true
done
# Ensure the existence and right permissions for the database and
# log files.
if [ ! -d "$mysql_statedir" -a ! -L "$mysql_statedir" ]; then mkdir "$mysql_statedir"; fi
if [ ! -d "$mysql_statedir/mysql" -a ! -L "$mysql_statedir/mysql" ]; then mkdir "$mysql_statedir/mysql"; fi
if [ ! -d "$mysql_newlogdir" -a ! -L "$mysql_newlogdir" ]; then mkdir "$mysql_newlogdir"; fi
# When creating an ext3 jounal on an already mounted filesystem like e.g.
# /var/lib/mysql, you get a .journal file that is not modifyable by chown.
# The mysql_datadir must not be writable by the mysql user under any
# circumstances as it contains scripts that are executed by root.
set +e
chown -R 0:0 $mysql_datadir
chown -R mysql $mysql_statedir
chmod 700 $mysql_statedir $mysql_statedir/mysql
if [ ! -d "$mysql_rundir" ]; then mkdir "$mysql_rundir"; fi
chown -R mysql $mysql_rundir
chown -R mysql:adm $mysql_newlogdir; chmod 2750 $mysql_newlogdir;
for i in log err; do
touch $mysql_logdir/mysql.$i
chown mysql:adm $mysql_logdir/mysql.$i
chmod 0640 $mysql_logdir/mysql.$i
done
set -e
# This is important to avoid dataloss when there is a removed
# mysql-server version from Woody lying around which used the same
# data directory and then somewhen gets purged by the admin.
db_set mysql-server/postrm_remove_database false || true
# To avoid downgrades.
touch $mysql_statedir/debian-5.5.flag
# initiate databases. Output is not allowed by debconf :-(
# Debian: beware of the bashisms...
# Debian: can safely run on upgrades with existing databases
set +e
bash /usr/bin/mysql_install_db --rpm 2>&1 | $ERR_LOGGER
if [ "$?" != "0" ]; then
echo "ATTENTION: An error has occured. More info is in the syslog!"
fi
set -e
## On every reconfiguration the maintenance user is recreated.
#
# - It is easier to regenerate the password every time but as people
# use fancy rsync scripts and file alteration monitors, the existing
# password is used and existing files not touched.
# - The mysqld statement is like that in mysql_install_db because the
# server is not already running. This has some implications:
# - The amount of newlines and semicolons in the query is important!
# - GRANT is not possible with --skip-grant-tables and "INSERT
# (user,host..) VALUES" is not --ansi compliant
# - The echo is just for readability. ash's buildin has no "-e" so use /bin/echo.
# - The Super_priv, Show_db_priv, Create_tmp_table_priv and Lock_tables_priv
# may not be present as old Woody 3.23 databases did not have it and the
# admin might not already have run mysql_upgrade which adds them.
# As the binlog cron scripts to need at least the Super_priv, I do first
# the old query which always succeeds and then the new which may or may not.
# recreate the credentials file if not present or without mysql_upgrade stanza
dc=$mysql_cfgdir/debian.cnf;
if [ -e "$dc" -a -n "`fgrep mysql_upgrade $dc 2>/dev/null`" ]; then
pass="`sed -n 's/^[ ]*password *= *// p' $dc | head -n 1`"
else
pass=`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..16)'`;
if [ ! -d "$mysql_cfgdir" ]; then install -o 0 -g 0 -m 0755 -d $mysql_cfgdir; fi
umask 066
cat /dev/null > $dc
umask 022
echo "# Automatically generated for Debian scripts. DO NOT TOUCH!" >>$dc
echo "[client]" >>$dc
echo "host = localhost" >>$dc
echo "user = debian-sys-maint" >>$dc
echo "password = $pass" >>$dc
echo "socket = $mysql_rundir/mysqld.sock" >>$dc
echo "[mysql_upgrade]" >>$dc
echo "host = localhost" >>$dc
echo "user = debian-sys-maint" >>$dc
echo "password = $pass" >>$dc
echo "socket = $mysql_rundir/mysqld.sock" >>$dc
echo "basedir = /usr" >>$dc
fi
# If this dir chmod go+w then the admin did it. But this file should not.
chown 0:0 $dc
chmod 0600 $dc
# update privilege tables
password_column_fix_query=`echo -e \
"USE mysql\n" \
"ALTER TABLE user CHANGE Password Password char(41) character set latin1 collate latin1_bin DEFAULT '' NOT NULL"`;
replace_query=`echo -e \
"USE mysql\n" \
"REPLACE INTO user SET " \
" host='localhost', user='debian-sys-maint', password=password('$pass'), " \
" Select_priv='Y', Insert_priv='Y', Update_priv='Y', Delete_priv='Y', " \
" Create_priv='Y', Drop_priv='Y', Reload_priv='Y', Shutdown_priv='Y', " \
" Process_priv='Y', File_priv='Y', Grant_priv='Y', References_priv='Y', " \
" Index_priv='Y', Alter_priv='Y', Super_priv='Y', Show_db_priv='Y', "\
" Create_tmp_table_priv='Y', Lock_tables_priv='Y', Execute_priv='Y', "\
" Repl_slave_priv='Y', Repl_client_priv='Y', Create_view_priv='Y', "\
" Show_view_priv='Y', Create_routine_priv='Y', Alter_routine_priv='Y', "\
" Create_user_priv='Y', Event_priv='Y', Trigger_priv='Y', Create_tablespace_priv='Y' "`;
fix_privs=`echo -e \
"USE mysql;\n" \
"ALTER TABLE user ADD column Create_view_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; " \
"ALTER TABLE user ADD column Show_view_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; " \
"ALTER TABLE user ADD column Create_routine_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; " \
"ALTER TABLE user ADD column Alter_routine_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; " \
"ALTER TABLE user ADD column Create_user_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; " \
"ALTER TABLE user ADD column Event_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; " \
"ALTER TABLE user ADD column Trigger_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; " \
"ALTER TABLE user ADD column Create_tablespace_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; " `
# Engines supported by etch should be installed per default. The query sequence is supposed
# to be aborted if the CREATE TABLE fails due to an already existent table in which case the
# admin might already have chosen to remove one or more plugins. Newlines are necessary.
install_plugins=`echo -e \
"USE mysql;\n" \
"CREATE TABLE plugin (name char(64) COLLATE utf8_bin NOT NULL DEFAULT '', " \
" dl char(128) COLLATE utf8_bin NOT NULL DEFAULT '', " \
" PRIMARY KEY (name)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='MySQL plugins';\n" \
"INSERT INTO plugin VALUES ('innodb', 'ha_innodb.so');\n" \
"INSERT INTO plugin VALUES ('federated', 'ha_federated.so');\n" \
"INSERT INTO plugin VALUES ('blackhole', 'ha_blackhole.so');\n" \
"INSERT INTO plugin VALUES ('archive', 'ha_archive.so');" `
# Upgrade password column format before the root password gets set.
echo "$password_column_fix_query" | $MYSQL_BOOTSTRAP 2>&1 | $ERR_LOGGER
db_get mysql-server/root_password && rootpw="$RET"
if ! set_mysql_rootpw; then
password_error="yes"
fi
echo "$fix_privs" | $MYSQL_BOOTSTRAP 2>&1 | $ERR_LOGGER
echo "$replace_query" | $MYSQL_BOOTSTRAP 2>&1 | $ERR_LOGGER
set +e
echo "$install_plugins" | $MYSQL_BOOTSTRAP 2>&1 | $ERR_LOGGER
set -e
;;
abort-upgrade|abort-remove|abort-configure)
;;
*)
echo "postinst called with unknown argument '$1'" 1>&2
exit 1
;;
esac
+ case "$1" in
+ mysql_datadir=/usr/share/mysql
+ mysql_statedir=/var/lib/mysql
+ mysql_rundir=/var/run/mysqld
+ mysql_logdir=/var/log
+ mysql_cfgdir=/etc/mysql
+ mysql_newlogdir=/var/log/mysql
+ mysql_upgradedir=/var/lib/mysql-upgrade
+ for dir in DATADIR LOGDIR
+ '[' DATADIR = DATADIR ']'
+ targetdir=/var/lib/mysql
+ savelink=/var/lib/mysql-upgrade/DATADIR.link
+ '[' -L /var/lib/mysql-upgrade/DATADIR.link ']'
+ rmdir /var/lib/mysql-upgrade
+ true
+ for dir in DATADIR LOGDIR
+ '[' LOGDIR = DATADIR ']'
+ targetdir=/var/log/mysql
+ savelink=/var/lib/mysql-upgrade/LOGDIR.link
+ '[' -L /var/lib/mysql-upgrade/LOGDIR.link ']'
+ rmdir /var/lib/mysql-upgrade
+ true
+ '[' '!' -d /var/lib/mysql -a '!' -L /var/lib/mysql ']'
+ '[' '!' -d /var/lib/mysql/mysql -a '!' -L /var/lib/mysql/mysql ']'
+ '[' '!' -d /var/log/mysql -a '!' -L /var/log/mysql ']'
+ set +e
+ chown -R 0:0 /usr/share/mysql
+ chown -R mysql /var/lib/mysql
+ chmod 700 /var/lib/mysql /var/lib/mysql/mysql
+ '[' '!' -d /var/run/mysqld ']'
+ chown -R mysql /var/run/mysqld
+ chown -R mysql:adm /var/log/mysql
+ chmod 2750 /var/log/mysql
+ for i in log err
+ touch /var/log/mysql.log
+ chown mysql:adm /var/log/mysql.log
+ chmod 0640 /var/log/mysql.log
+ for i in log err
+ touch /var/log/mysql.err
+ chown mysql:adm /var/log/mysql.err
+ chmod 0640 /var/log/mysql.err
+ set -e
+ db_set mysql-server/postrm_remove_database false
+ _db_cmd 'SET mysql-server/postrm_remove_database' false
+ _db_internal_IFS='
'
+ IFS=' '
+ printf '%s\n' 'SET mysql-server/postrm_remove_database false'
+ IFS='
'
+ IFS='
'
+ read -r _db_internal_line
+ RET='10 mysql-server/postrm_remove_database doesn'\''t exist'
+ case ${_db_internal_line%%[ ]*} in
+ return 10
+ true
+ touch /var/lib/mysql/debian-5.5.flag
+ set +e
+ bash /usr/bin/mysql_install_db --rpm
+ logger -p daemon.err -t mysqld_safe -i
+ '[' 0 '!=' 0 ']'
+ set -e
+ dc=/etc/mysql/debian.cnf
fgrep mysql_upgrade $dc 2>/dev/null
++ fgrep mysql_upgrade /etc/mysql/debian.cnf
+ '[' -e /etc/mysql/debian.cnf -a -n '[mysql_upgrade]' ']'
sed -n 's/^[ ]*password *= *// p' $dc | head -n 1
++ sed -n 's/^[ ]*password *= *// p' /etc/mysql/debian.cnf
++ head -n 1
+ pass=45WCZJQLwNMAvlSc
+ chown 0:0 /etc/mysql/debian.cnf
+ chmod 0600 /etc/mysql/debian.cnf
echo -e "USE mysql\n" "ALTER TABLE user CHANGE Password Password char(41) character set latin1 collate latin1_bin DEFAULT '' NOT NULL"
++ echo -e 'USE mysql\n' 'ALTER TABLE user CHANGE Password Password char(41) character set latin1 collate latin1_bin DEFAULT '\'''\'' NOT NULL'
+ password_column_fix_query='USE mysql
ALTER TABLE user CHANGE Password Password char(41) character set latin1 collate latin1_bin DEFAULT '\'''\'' NOT NULL'
echo -e "USE mysql\n" "REPLACE INTO user SET " " host='localhost', user='debian-sys-maint', password=password('$pass'), " " Select_priv='Y', Insert_priv='Y', Update_priv='Y', Delete_priv='Y', " " Create_priv='Y', Drop_priv='Y', Reload_priv='Y', Shutdown_priv='Y', " " Process_priv='Y', File_priv='Y', Grant_priv='Y', References_priv='Y', " " Index_priv='Y', Alter_priv='Y', Super_priv='Y', Show_db_priv='Y', " " Create_tmp_table_priv='Y', Lock_tables_priv='Y', Execute_priv='Y', " " Repl_slave_priv='Y', Repl_client_priv='Y', Create_view_priv='Y', " " Show_view_priv='Y', Create_routine_priv='Y', Alter_routine_priv='Y', " " Create_user_priv='Y', Event_priv='Y', Trigger_priv='Y', Create_tablespace_priv='Y' "
++ echo -e 'USE mysql\n' 'REPLACE INTO user SET ' ' host='\''localhost'\'', user='\''debian-sys-maint'\'', password=password('\''45WCZJQLwNMAvlSc'\''), ' ' Select_priv='\''Y'\'', Insert_priv='\''Y'\'', Update_priv='\''Y'\'', Delete_priv='\''Y'\'', ' ' Create_priv='\''Y'\'', Drop_priv='\''Y'\'', Reload_priv='\''Y'\'', Shutdown_priv='\''Y'\'', ' ' Process_priv='\''Y'\'', File_priv='\''Y'\'', Grant_priv='\''Y'\'', References_priv='\''Y'\'', ' ' Index_priv='\''Y'\'', Alter_priv='\''Y'\'', Super_priv='\''Y'\'', Show_db_priv='\''Y'\'', ' ' Create_tmp_table_priv='\''Y'\'', Lock_tables_priv='\''Y'\'', Execute_priv='\''Y'\'', ' ' Repl_slave_priv='\''Y'\'', Repl_client_priv='\''Y'\'', Create_view_priv='\''Y'\'', ' ' Show_view_priv='\''Y'\'', Create_routine_priv='\''Y'\'', Alter_routine_priv='\''Y'\'', ' ' Create_user_priv='\''Y'\'', Event_priv='\''Y'\'', Trigger_priv='\''Y'\'', Create_tablespace_priv='\''Y'\'' '
+ replace_query='USE mysql
REPLACE INTO user SET host='\''localhost'\'', user='\''debian-sys-maint'\'', password=password('\''45WCZJQLwNMAvlSc'\''), Select_priv='\''Y'\'', Insert_priv='\''Y'\'', Update_priv='\''Y'\'', Delete_priv='\''Y'\'', Create_priv='\''Y'\'', Drop_priv='\''Y'\'', Reload_priv='\''Y'\'', Shutdown_priv='\''Y'\'', Process_priv='\''Y'\'', File_priv='\''Y'\'', Grant_priv='\''Y'\'', References_priv='\''Y'\'', Index_priv='\''Y'\'', Alter_priv='\''Y'\'', Super_priv='\''Y'\'', Show_db_priv='\''Y'\'', Create_tmp_table_priv='\''Y'\'', Lock_tables_priv='\''Y'\'', Execute_priv='\''Y'\'', Repl_slave_priv='\''Y'\'', Repl_client_priv='\''Y'\'', Create_view_priv='\''Y'\'', Show_view_priv='\''Y'\'', Create_routine_priv='\''Y'\'', Alter_routine_priv='\''Y'\'', Create_user_priv='\''Y'\'', Event_priv='\''Y'\'', Trigger_priv='\''Y'\'', Create_tablespace_priv='\''Y'\'' '
echo -e "USE mysql;\n" "ALTER TABLE user ADD column Create_view_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; " "ALTER TABLE user ADD column Show_view_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; " "ALTER TABLE user ADD column Create_routine_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; " "ALTER TABLE user ADD column Alter_routine_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; " "ALTER TABLE user ADD column Create_user_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; " "ALTER TABLE user ADD column Event_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; " "ALTER TABLE user ADD column Trigger_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; " "ALTER TABLE user ADD column Create_tablespace_priv enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N'; "
++ echo -e 'USE mysql;\n' 'ALTER TABLE user ADD column Create_view_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; ' 'ALTER TABLE user ADD column Show_view_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; ' 'ALTER TABLE user ADD column Create_routine_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; ' 'ALTER TABLE user ADD column Alter_routine_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; ' 'ALTER TABLE user ADD column Create_user_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; ' 'ALTER TABLE user ADD column Event_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; ' 'ALTER TABLE user ADD column Trigger_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; ' 'ALTER TABLE user ADD column Create_tablespace_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; '
+ fix_privs='USE mysql;
ALTER TABLE user ADD column Create_view_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; ALTER TABLE user ADD column Show_view_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; ALTER TABLE user ADD column Create_routine_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; ALTER TABLE user ADD column Alter_routine_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; ALTER TABLE user ADD column Create_user_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; ALTER TABLE user ADD column Event_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; ALTER TABLE user ADD column Trigger_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; ALTER TABLE user ADD column Create_tablespace_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; '
echo -e "USE mysql;\n" "CREATE TABLE plugin (name char(64) COLLATE utf8_bin NOT NULL DEFAULT '', " " dl char(128) COLLATE utf8_bin NOT NULL DEFAULT '', " " PRIMARY KEY (name)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='MySQL plugins';\n" "INSERT INTO plugin VALUES ('innodb', 'ha_innodb.so');\n" "INSERT INTO plugin VALUES ('federated', 'ha_federated.so');\n" "INSERT INTO plugin VALUES ('blackhole', 'ha_blackhole.so');\n" "INSERT INTO plugin VALUES ('archive', 'ha_archive.so');"
++ echo -e 'USE mysql;\n' 'CREATE TABLE plugin (name char(64) COLLATE utf8_bin NOT NULL DEFAULT '\'''\'', ' ' dl char(128) COLLATE utf8_bin NOT NULL DEFAULT '\'''\'', ' ' PRIMARY KEY (name)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='\''MySQL plugins'\'';\n' 'INSERT INTO plugin VALUES ('\''innodb'\'', '\''ha_innodb.so'\'');\n' 'INSERT INTO plugin VALUES ('\''federated'\'', '\''ha_federated.so'\'');\n' 'INSERT INTO plugin VALUES ('\''blackhole'\'', '\''ha_blackhole.so'\'');\n' 'INSERT INTO plugin VALUES ('\''archive'\'', '\''ha_archive.so'\'');'
+ install_plugins='USE mysql;
CREATE TABLE plugin (name char(64) COLLATE utf8_bin NOT NULL DEFAULT '\'''\'', dl char(128) COLLATE utf8_bin NOT NULL DEFAULT '\'''\'', PRIMARY KEY (name)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='\''MySQL plugins'\'';
INSERT INTO plugin VALUES ('\''innodb'\'', '\''ha_innodb.so'\'');
INSERT INTO plugin VALUES ('\''federated'\'', '\''ha_federated.so'\'');
INSERT INTO plugin VALUES ('\''blackhole'\'', '\''ha_blackhole.so'\'');
INSERT INTO plugin VALUES ('\''archive'\'', '\''ha_archive.so'\'');'
+ echo 'USE mysql
ALTER TABLE user CHANGE Password Password char(41) character set latin1 collate latin1_bin DEFAULT '\'''\'' NOT NULL'
+ logger -p daemon.err -t mysqld_safe -i
+ /usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables
+ db_get mysql-server/root_password
+ _db_cmd 'GET mysql-server/root_password'
+ _db_internal_IFS='
'
+ IFS=' '
+ printf '%s\n' 'GET mysql-server/root_password'
+ IFS='
'
+ IFS='
'
+ read -r _db_internal_line
+ RET=
+ case ${_db_internal_line%%[ ]*} in
+ return 0
+ rootpw=
+ set_mysql_rootpw
+ db_set mysql-server/root_password ''
+ _db_cmd 'SET mysql-server/root_password' ''
+ _db_internal_IFS='
'
+ IFS=' '
+ printf '%s\n' 'SET mysql-server/root_password '
+ IFS='
'
+ IFS='
'
+ read -r _db_internal_line
+ RET='value set'
+ case ${_db_internal_line%%[ ]*} in
+ return 0
+ db_set mysql-server/root_password_again ''
+ _db_cmd 'SET mysql-server/root_password_again' ''
+ _db_internal_IFS='
'
+ IFS=' '
+ printf '%s\n' 'SET mysql-server/root_password_again '
+ IFS='
'
+ IFS='
'
+ read -r _db_internal_line
+ RET='value set'
+ case ${_db_internal_line%%[ ]*} in
+ return 0
mktemp
++ mktemp
+ tfile=/tmp/tmp.AJNs5Bys6k
+ '[' '!' -f /tmp/tmp.AJNs5Bys6k ']'
+ cat
+ grep -q 'PASSWORD("")' /tmp/tmp.AJNs5Bys6k
+ retval=0
+ rm -f /tmp/tmp.AJNs5Bys6k
+ return 0
+ echo 'USE mysql;
ALTER TABLE user ADD column Create_view_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; ALTER TABLE user ADD column Show_view_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; ALTER TABLE user ADD column Create_routine_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; ALTER TABLE user ADD column Alter_routine_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; ALTER TABLE user ADD column Create_user_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; ALTER TABLE user ADD column Event_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; ALTER TABLE user ADD column Trigger_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; ALTER TABLE user ADD column Create_tablespace_priv enum('\''N'\'','\''Y'\'') CHARACTER SET utf8 NOT NULL DEFAULT '\''N'\''; '
+ logger -p daemon.err -t mysqld_safe -i
+ /usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables
+ logger -p daemon.err -t mysqld_safe -i
+ /usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables
+ echo 'USE mysql
REPLACE INTO user SET host='\''localhost'\'', user='\''debian-sys-maint'\'', password=password('\''45WCZJQLwNMAvlSc'\''), Select_priv='\''Y'\'', Insert_priv='\''Y'\'', Update_priv='\''Y'\'', Delete_priv='\''Y'\'', Create_priv='\''Y'\'', Drop_priv='\''Y'\'', Reload_priv='\''Y'\'', Shutdown_priv='\''Y'\'', Process_priv='\''Y'\'', File_priv='\''Y'\'', Grant_priv='\''Y'\'', References_priv='\''Y'\'', Index_priv='\''Y'\'', Alter_priv='\''Y'\'', Super_priv='\''Y'\'', Show_db_priv='\''Y'\'', Create_tmp_table_priv='\''Y'\'', Lock_tables_priv='\''Y'\'', Execute_priv='\''Y'\'', Repl_slave_priv='\''Y'\'', Repl_client_priv='\''Y'\'', Create_view_priv='\''Y'\'', Show_view_priv='\''Y'\'', Create_routine_priv='\''Y'\'', Alter_routine_priv='\''Y'\'', Create_user_priv='\''Y'\'', Event_priv='\''Y'\'', Trigger_priv='\''Y'\'', Create_tablespace_priv='\''Y'\'' '
+ set +e
+ echo 'USE mysql;
CREATE TABLE plugin (name char(64) COLLATE utf8_bin NOT NULL DEFAULT '\'''\'', dl char(128) COLLATE utf8_bin NOT NULL DEFAULT '\'''\'', PRIMARY KEY (name)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='\''MySQL plugins'\'';
INSERT INTO plugin VALUES ('\''innodb'\'', '\''ha_innodb.so'\'');
INSERT INTO plugin VALUES ('\''federated'\'', '\''ha_federated.so'\'');
INSERT INTO plugin VALUES ('\''blackhole'\'', '\''ha_blackhole.so'\'');
INSERT INTO plugin VALUES ('\''archive'\'', '\''ha_archive.so'\'');'
+ logger -p daemon.err -t mysqld_safe -i
+ /usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables
+ set -e
# here we check to see if we can connect as root without a password
# this should catch upgrades from previous versions where the root
# password wasn't set. if there is a password, or if the connection
# fails for any other reason, nothing happens.
if [ "$1" = "configure" ]; then
if test_mysql_access; then
db_input medium mysql-server/root_password || true
db_go
db_get mysql-server/root_password && rootpw="$RET"
if ! set_mysql_rootpw "online"; then
password_error="yes"
fi
fi
if [ "$password_error" = "yes" ]; then
db_input high mysql-server/error_setting_password || true
db_go
fi
fi
+ '[' configure = configure ']'
+ test_mysql_access
+ mysql --no-defaults -u root -h localhost
+ '[' '' = yes ']'
db_stop # in case invoke failes
+ db_stop
+ echo STOP
# Automatically added by dh_installinit
if [ -x "/etc/init.d/mysql" ]; then
update-rc.d mysql defaults 19 21 >/dev/null
invoke-rc.d mysql start || exit $?
fi
+ '[' -x /etc/init.d/mysql ']'
+ update-rc.d mysql defaults 19 21
+ invoke-rc.d mysql start
test -x /usr/bin/mysqld_safe || exit 0
+ test -x /usr/bin/mysqld_safe
. /lib/lsb/init-functions
+ . /lib/lsb/init-functions
# /lib/lsb/init-functions for Debian -*- shell-script -*-
#
#Copyright (c) 2002-08 Chris Lawrence
#All rights reserved.
#
#Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions
#are met:
#1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#3. Neither the name of the author nor the names of other contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
#THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
#IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
#ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
#LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
#CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
#SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
#BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
#OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
#EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
start_daemon () {
local force nice pidfile exec args OPTIND
force=""
nice=0
pidfile=/dev/null
OPTIND=1
while getopts fn:p: opt ; do
case "$opt" in
f) force="force";;
n) nice="$OPTARG";;
p) pidfile="$OPTARG";;
esac
done
shift $(($OPTIND - 1))
if [ "$1" = '--' ]; then
shift
fi
exec="$1"; shift
args="--start --nicelevel $nice --quiet --oknodo"
if [ "$force" ]; then
/sbin/start-stop-daemon $args \
--chdir "$PWD" --startas $exec --pidfile /dev/null -- "$@"
elif [ $pidfile ]; then
/sbin/start-stop-daemon $args \
--chdir "$PWD" --exec $exec --oknodo --pidfile "$pidfile" -- "$@"
else
/sbin/start-stop-daemon $args --chdir "$PWD" --exec $exec -- "$@"
fi
}
pidofproc () {
local pidfile base status specified pid OPTIND
pidfile=
specified=
OPTIND=1
while getopts p: opt ; do
case "$opt" in
p) pidfile="$OPTARG"
specified="specified"
;;
esac
done
shift $(($OPTIND - 1))
base=${1##*/}
if [ ! "$specified" ]; then
pidfile="/var/run/$base.pid"
fi
if [ -n "${pidfile:-}" ]; then
if [ -e "$pidfile" ]; then
if [ -r "$pidfile" ]; then
read pid < "$pidfile"
if [ -n "${pid:-}" ]; then
if $(kill -0 "${pid:-}" 2> /dev/null); then
echo "$pid" || true
return 0
elif ps "${pid:-}" >/dev/null 2>&1; then
echo "$pid" || true
return 0 # program is running, but not owned by this user
else
return 1 # program is dead and /var/run pid file exists
fi
fi
else
return 4 # pid file not readable, hence status is unknown.
fi
else
# pid file doesn't exist, try to find the pid nevertheless
if [ -x /bin/pidof ] && [ ! "$specified" ]; then
status="0"
/bin/pidof -o %PPID -x $1 || status="$?"
if [ "$status" = 1 ]; then
return 3 # program is not running
fi
return 0
fi
return 3 # specified pid file doesn't exist, program probably stopped
fi
fi
if [ "$specified" ]; then
return 3 # almost certain it's not running
fi
return 4 # Unable to determine status
}
# start-stop-daemon uses the same algorithm as "pidofproc" above.
killproc () {
local pidfile sig status base name_param is_term_sig OPTIND
pidfile=
name_param=
is_term_sig=
OPTIND=1
while getopts p: opt ; do
case "$opt" in
p) pidfile="$OPTARG";;
esac
done
shift $(($OPTIND - 1))
base=${1##*/}
if [ ! $pidfile ]; then
name_param="--name $base --pidfile /var/run/$base.pid"
else
name_param="--pidfile $pidfile"
fi
sig=$(echo ${2:-} | sed -e 's/^-\(.*\)/\1/')
sig=$(echo $sig | sed -e 's/^SIG\(.*\)/\1/')
if [ "$sig" = 15 ] || [ "$sig" = TERM ]; then
is_term_sig="terminate_signal"
fi
status=0
if [ ! "$is_term_sig" ]; then
if [ -n "$sig" ]; then
/sbin/start-stop-daemon --stop --signal "$sig" \
--quiet $name_param || status="$?"
else
/sbin/start-stop-daemon --stop \
--retry 5 \
--quiet $name_param || status="$?"
fi
else
/sbin/start-stop-daemon --stop --quiet \
--oknodo $name_param || status="$?"
fi
if [ "$status" = 1 ]; then
if [ -z "$sig" ]; then
return 0
fi
return 3 # program is not running
fi
if [ "$status" = 0 ] && [ "$is_term_sig" ] && [ "$pidfile" ]; then
pidofproc -p "$pidfile" "$1" >/dev/null || rm -f "$pidfile"
fi
return 0
}
# Return LSB status
status_of_proc () {
local pidfile daemon name status OPTIND
pidfile=
OPTIND=1
while getopts p: opt ; do
case "$opt" in
p) pidfile="$OPTARG";;
esac
done
shift $(($OPTIND - 1))
if [ -n "$pidfile" ]; then
pidfile="-p $pidfile"
fi
daemon="$1"
name="$2"
status="0"
pidofproc $pidfile $daemon >/dev/null || status="$?"
if [ "$status" = 0 ]; then
log_success_msg "$name is running"
return 0
elif [ "$status" = 4 ]; then
log_failure_msg "could not access PID file for $name"
return $status
else
log_failure_msg "$name is not running"
return $status
fi
}
log_use_fancy_output () {
TPUT=/usr/bin/tput
EXPR=/usr/bin/expr
if [ -t 1 ] &&
[ "x${TERM:-}" != "x" ] &&
[ "x${TERM:-}" != "xdumb" ] &&
[ -x $TPUT ] && [ -x $EXPR ] &&
$TPUT hpa 60 >/dev/null 2>&1 &&
$TPUT setaf 1 >/dev/null 2>&1
then
[ -z $FANCYTTY ] && FANCYTTY=1 || true
else
FANCYTTY=0
fi
case "$FANCYTTY" in
1|Y|yes|true) true;;
*) false;;
esac
}
log_success_msg () {
if [ -n "${1:-}" ]; then
log_begin_msg $@
fi
log_end_msg 0
}
log_failure_msg () {
if [ -n "${1:-}" ]; then
log_begin_msg $@ "..."
fi
log_end_msg 1 || true
}
log_warning_msg () {
if [ -n "${1:-}" ]; then
log_begin_msg $@ "..."
fi
log_end_msg 255 || true
}
#
# NON-LSB HELPER FUNCTIONS
#
# int get_lsb_header_val (char *scriptpathname, char *key)
get_lsb_header_val () {
if [ ! -f "$1" ] || [ -z "${2:-}" ]; then
return 1
fi
LSB_S="### BEGIN INIT INFO"
LSB_E="### END INIT INFO"
sed -n "/$LSB_S/,/$LSB_E/ s/# $2: \(.*\)/\1/p" $1
}
# If the currently running init daemon is upstart, return zero; if the
# calling init script belongs to a package which also provides a native
# upstart job, it should generally exit non-zero in this case.
init_is_upstart()
{
if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | /bin/grep -q upstart; then
return 0
fi
return 1
}
# int log_begin_message (char *message)
log_begin_msg () {
log_begin_msg_pre "$@"
if [ -z "${1:-}" ]; then
return 1
fi
/bin/echo -n "$@" || true
log_begin_msg_post "$@"
}
# Sample usage:
# log_daemon_msg "Starting GNOME Login Manager" "gdm"
#
# On Debian, would output "Starting GNOME Login Manager: gdm"
# On Ubuntu, would output " * Starting GNOME Login Manager..."
#
# If the second argument is omitted, logging suitable for use with
# log_progress_msg() is used:
#
# log_daemon_msg "Starting remote filesystem services"
#
# On Debian, would output "Starting remote filesystem services:"
# On Ubuntu, would output " * Starting remote filesystem services..."
log_daemon_msg () {
if [ -z "${1:-}" ]; then
return 1
fi
log_daemon_msg_pre "$@"
if [ -z "${2:-}" ]; then
/bin/echo -n "$1:" || true
return
fi
/bin/echo -n "$1: $2" || true
log_daemon_msg_post "$@"
}
# #319739
#
# Per policy docs:
#
# log_daemon_msg "Starting remote file system services"
# log_progress_msg "nfsd"; start-stop-daemon --start --quiet nfsd
# log_progress_msg "mountd"; start-stop-daemon --start --quiet mountd
# log_progress_msg "ugidd"; start-stop-daemon --start --quiet ugidd
# log_end_msg 0
#
# You could also do something fancy with log_end_msg here based on the
# return values of start-stop-daemon; this is left as an exercise for
# the reader...
#
# On Ubuntu, one would expect log_progress_msg to be a no-op.
log_progress_msg () {
if [ -z "${1:-}" ]; then
return 1
fi
/bin/echo -n " $@" || true
}
# int log_end_message (int exitstatus)
log_end_msg () {
# If no arguments were passed, return
if [ -z "${1:-}" ]; then
return 1
fi
local retval
retval=$1
log_end_msg_pre "$@"
# Only do the fancy stuff if we have an appropriate terminal
# and if /usr is already mounted
if log_use_fancy_output; then
RED=$( $TPUT setaf 1)
YELLOW=$( $TPUT setaf 3)
NORMAL=$( $TPUT op)
else
RED=''
YELLOW=''
NORMAL=''
fi
if [ $1 -eq 0 ]; then
echo "." || true
elif [ $1 -eq 255 ]; then
/bin/echo -e " ${YELLOW}(warning).${NORMAL}" || true
else
/bin/echo -e " ${RED}failed!${NORMAL}" || true
fi
log_end_msg_post "$@"
return $retval
}
log_action_msg () {
log_action_msg_pre "$@"
echo "$@." || true
log_action_msg_post "$@"
}
log_action_begin_msg () {
log_action_begin_msg_pre "$@"
/bin/echo -n "$@..." || true
log_action_begin_msg_post "$@"
}
log_action_cont_msg () {
/bin/echo -n "$@..." || true
}
log_action_end_msg () {
local end
log_action_end_msg_pre "$@"
if [ -z "${2:-}" ]; then
end="."
else
end=" ($2)."
fi
if [ $1 -eq 0 ]; then
echo "done${end}" || true
else
if log_use_fancy_output; then
RED=$( $TPUT setaf 1)
NORMAL=$( $TPUT op)
/bin/echo -e "${RED}failed${end}${NORMAL}" || true
else
echo "failed${end}" || true
fi
fi
log_action_end_msg_post "$@"
}
# Pre&Post empty function declaration, to be overriden from /lib/lsb/init-functions.d/*
log_daemon_msg_pre () { :; }
log_daemon_msg_post () { :; }
log_begin_msg_pre () { :; }
log_begin_msg_post () { :; }
log_end_msg_pre () { :; }
log_end_msg_post () { :; }
log_action_msg_pre () { :; }
log_action_msg_post () { :; }
log_action_begin_msg_pre () { :; }
log_action_begin_msg_post () { :; }
log_action_end_msg_pre () { :; }
log_action_end_msg_post () { :; }
# Include hooks from other packages in /lib/lsb/init-functions.d
for hook in $(run-parts --lsbsysinit --list /lib/lsb/init-functions.d 2>/dev/null); do
[ -r $hook ] && . $hook || true
done
run-parts --lsbsysinit --list /lib/lsb/init-functions.d 2>/dev/null)
run-parts --lsbsysinit --list /lib/lsb/init-functions.d 2>/dev/null
+++ run-parts --lsbsysinit --list /lib/lsb/init-functions.d
++ for hook in '$(run-parts --lsbsysinit --list /lib/lsb/init-functions.d 2>/dev/null)'
++ '[' -r /lib/lsb/init-functions.d/20-left-info-blocks ']'
++ . /lib/lsb/init-functions.d/20-left-info-blocks
# Default info blocks put to the left of the screen
log_daemon_msg_pre () {
if log_use_fancy_output; then
/bin/echo -n "[....] " || true
fi
}
log_begin_msg_pre () {
log_daemon_msg_pre "$@"
}
log_end_msg_pre () {
if log_use_fancy_output; then
RED=$( $TPUT setaf 1)
GREEN=$( $TPUT setaf 2)
YELLOW=$( $TPUT setaf 3)
NORMAL=$( $TPUT op)
$TPUT civis || true
$TPUT sc && \
$TPUT hpa 0 && \
if [ $1 -eq 0 ]; then
/bin/echo -ne "[${GREEN} ok ${NORMAL}" || true
elif [ $1 -eq 255 ]; then
/bin/echo -ne "[${YELLOW}warn${NORMAL}" || true
else
/bin/echo -ne "[${RED}FAIL${NORMAL}" || true
fi && \
$TPUT rc || true
$TPUT cnorm || true
fi
}
log_action_msg_pre () {
if log_use_fancy_output; then
CYAN=$( $TPUT setaf 6)
NORMAL=$( $TPUT op)
/bin/echo -ne "[${CYAN}info${NORMAL}] " || true
fi
}
log_action_begin_msg_pre () {
log_daemon_msg_pre "$@"
}
log_action_end_msg_pre () {
log_end_msg_pre "$@"
}
FANCYTTY=
++ FANCYTTY=
[ -e /etc/lsb-base-logging.sh ] && . /etc/lsb-base-logging.sh || true
++ '[' -e /etc/lsb-base-logging.sh ']'
++ . /etc/lsb-base-logging.sh
FANCYTTY=no
+++ FANCYTTY=no
SELF=$(cd $(dirname $0); pwd -P)/$(basename $0)
cd $(dirname $0); pwd -P)/$(basename $0)
cd $(dirname $0); pwd -P
dirname $0)
dirname $0
+++ dirname /etc/init.d/mysql
++ cd /etc/init.d
++ pwd -P
basename $0)
basename $0
++ basename /etc/init.d/mysql
+ SELF=/etc/init.d/mysql
CONF=/etc/mysql/my.cnf
+ CONF=/etc/mysql/my.cnf
MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
+ MYADMIN='/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf'
# priority can be overriden and "-s" adds output to stderr
ERR_LOGGER="logger -p daemon.err -t /etc/init.d/mysql -i"
+ ERR_LOGGER='logger -p daemon.err -t /etc/init.d/mysql -i'
# Safeguard (relative paths, core dumps..)
cd /
+ cd /
umask 077
+ umask 077
# mysqladmin likes to read /root/.my.cnf. This is usually not what I want
# as many admins e.g. only store a password without a username there and
# so break my scripts.
export HOME=/etc/mysql/
+ export HOME=/etc/mysql/
+ HOME=/etc/mysql/
## Fetch a particular option from mysql's invocation.
#
# Usage: void mysqld_get_param option
mysqld_get_param() {
/usr/sbin/mysqld --print-defaults \
| tr " " "\n" \
| grep -- "--$1" \
| tail -n 1 \
| cut -d= -f2
}
## Do some sanity checks before even trying to start mysqld.
sanity_checks() {
# check for config file
if [ ! -r /etc/mysql/my.cnf ]; then
log_warning_msg "$0: WARNING: /etc/mysql/my.cnf cannot be read. See README.Debian.gz"
echo "WARNING: /etc/mysql/my.cnf cannot be read. See README.Debian.gz" | $ERR_LOGGER
fi
# check for diskspace shortage
datadir=`mysqld_get_param datadir`
if LC_ALL=C BLOCKSIZE= df --portability $datadir/. | tail -n 1 | awk '{ exit ($4>4096) }'; then
log_failure_msg "$0: ERROR: The partition with $datadir is too full!"
echo "ERROR: The partition with $datadir is too full!" | $ERR_LOGGER
exit 1
fi
}
## 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
}
#
# main()
#
case "${1:-''}" in
'start')
sanity_checks;
# Start daemon
log_daemon_msg "Starting MySQL database server" "mysqld"
if mysqld_status check_alive nowarn; then
log_progress_msg "already running"
log_end_msg 0
else
# Could be removed during boot
test -e /var/run/mysqld || install -m 755 -o mysql -g root -d /var/run/mysqld
# Start MySQL!
/usr/bin/mysqld_safe > /dev/null 2>&1 &
# 6s was reported in #352070 to be too few when using ndbcluster
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
log_progress_msg "."
done
if mysqld_status check_alive warn; then
log_end_msg 0
# Now start mysqlcheck or whatever the admin wants.
output=$(/etc/mysql/debian-start)
[ -n "$output" ] && log_action_msg "$output"
else
log_end_msg 1
log_failure_msg "Please take a look at the syslog"
fi
fi
;;
'stop')
# * As a passwordless mysqladmin (e.g. via ~/.my.cnf) must be possible
# at least for cron, we can rely on it here, too. (although we have
# to specify it explicit as e.g. sudo environments points to the normal
# users home and not /root)
log_daemon_msg "Stopping MySQL database server" "mysqld"
if ! mysqld_status check_dead nowarn; then
set +e
shutdown_out=`$MYADMIN shutdown 2>&1`; r=$?
set -e
if [ "$r" -ne 0 ]; then
log_end_msg 1
[ "$VERBOSE" != "no" ] && log_failure_msg "Error: $shutdown_out"
log_daemon_msg "Killing MySQL database server by signal" "mysqld"
killall -15 mysqld
server_down=
for i in 1 2 3 4 5 6 7 8 9 10; do
sleep 1
if mysqld_status check_dead nowarn; then server_down=1; break; fi
done
if test -z "$server_down"; then killall -9 mysqld; fi
fi
fi
if ! mysqld_status check_dead warn; then
log_end_msg 1
log_failure_msg "Please stop MySQL manually and read /usr/share/doc/mysql-server-5.5/README.Debian.gz!"
exit -1
else
log_end_msg 0
fi
;;
'restart')
set +e; $SELF stop; set -e
$SELF start
;;
'reload'|'force-reload')
log_daemon_msg "Reloading MySQL database server" "mysqld"
$MYADMIN reload
log_end_msg 0
;;
'status')
if mysqld_status check_alive nowarn; then
log_action_msg "$($MYADMIN version)"
else
log_action_msg "MySQL is stopped."
exit 3
fi
;;
*)
echo "Usage: $SELF start|stop|restart|reload|force-reload|status"
exit 1
;;
esac
+ case "${1:-''}" in
+ sanity_checks
+ '[' '!' -r /etc/mysql/my.cnf ']'
mysqld_get_param datadir
++ mysqld_get_param datadir
++ grep -- --datadir
++ /usr/sbin/mysqld --print-defaults
++ tr ' ' '\n'
++ tail -n 1
++ cut -d= -f2
+ datadir=/var/lib/mysql
+ LC_ALL=C
+ BLOCKSIZE=
+ awk '{ exit ($4>4096) }'
+ tail -n 1
+ df --portability /var/lib/mysql/.
+ log_daemon_msg 'Starting MySQL database server' mysqld
+ '[' -z 'Starting MySQL database server' ']'
+ log_daemon_msg_pre 'Starting MySQL database server' mysqld
+ log_use_fancy_output
+ TPUT=/usr/bin/tput
+ EXPR=/usr/bin/expr
+ '[' -t 1 ']'
+ FANCYTTY=0
+ case "$FANCYTTY" in
+ false
+ '[' -z mysqld ']'
+ /bin/echo -n 'Starting MySQL database server: mysqld'
Starting MySQL database server: mysqld+ log_daemon_msg_post 'Starting MySQL database server' mysqld
+ :
+ mysqld_status check_alive nowarn
$MYADMIN ping 2>&1
++ /usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping
+ ping_output='/usr/bin/mysqladmin: connect to server at '\''localhost'\'' failed
error: '\''Can'\''t connect to local MySQL server through socket '\''/var/run/mysqld/mysqld.sock'\'' (2)'\''
Check that mysqld is running and that the socket: '\''/var/run/mysqld/mysqld.sock'\'' exists!'
+ ping_alive=0
+ ps_alive=0
mysqld_get_param pid-file
++ mysqld_get_param pid-file
++ grep -- --pid-file
++ /usr/sbin/mysqld --print-defaults
++ tail -n 1
++ tr ' ' '\n'
++ cut -d= -f2
+ pidfile=/var/run/mysqld/mysqld.pid
+ '[' -f /var/run/mysqld/mysqld.pid ']'
+ '[' check_alive = check_alive -a 0 = 1 ']'
+ '[' check_alive = check_dead -a 0 = 0 -a 0 = 0 ']'
+ '[' nowarn = warn ']'
+ return 1
+ test -e /var/run/mysqld
+ for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14
+ sleep 1
+ /usr/bin/mysqld_safe
+ mysqld_status check_alive nowarn
$MYADMIN ping 2>&1
++ /usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping
+ ping_output='/usr/bin/mysqladmin: connect to server at '\''localhost'\'' failed
error: '\''Can'\''t connect to local MySQL server through socket '\''/var/run/mysqld/mysqld.sock'\'' (2)'\''
Check that mysqld is running and that the socket: '\''/var/run/mysqld/mysqld.sock'\'' exists!'
+ ping_alive=0
+ ps_alive=0
mysqld_get_param pid-file
++ mysqld_get_param pid-file
++ tr ' ' '\n'
++ tail -n 1
++ /usr/sbin/mysqld --print-defaults
++ cut -d= -f2
++ grep -- --pid-file
+ pidfile=/var/run/mysqld/mysqld.pid
+ '[' -f /var/run/mysqld/mysqld.pid ']'
+ '[' check_alive = check_alive -a 0 = 1 ']'
+ '[' check_alive = check_dead -a 0 = 0 -a 0 = 0 ']'
+ '[' nowarn = warn ']'
+ return 1
+ log_progress_msg .
+ '[' -z . ']'
+ /bin/echo -n ' .'
.+ for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14
+ sleep 1
+ mysqld_status check_alive nowarn
$MYADMIN ping 2>&1
++ /usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping
+ ping_output='/usr/bin/mysqladmin: connect to server at '\''localhost'\'' failed
error: '\''Can'\''t connect to local MySQL server through socket '\''/var/run/mysqld/mysqld.sock'\'' (2)'\''
Check that mysqld is running and that the socket: '\''/var/run/mysqld/mysqld.sock'\'' exists!'
+ ping_alive=0
+ ps_alive=0
mysqld_get_param pid-file
++ mysqld_get_param pid-file
++ /usr/sbin/mysqld --print-defaults
++ tail -n 1
++ tr ' ' '\n'
++ cut -d= -f2
++ grep -- --pid-file
+ pidfile=/var/run/mysqld/mysqld.pid
+ '[' -f /var/run/mysqld/mysqld.pid ']'
+ '[' check_alive = check_alive -a 0 = 1 ']'
+ '[' check_alive = check_dead -a 0 = 0 -a 0 = 0 ']'
+ '[' nowarn = warn ']'
+ return 1
+ log_progress_msg .
+ '[' -z . ']'
+ /bin/echo -n ' .'
.+ for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14
+ sleep 1
+ mysqld_status check_alive nowarn
$MYADMIN ping 2>&1
++ /usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping
+ ping_output='mysqld is alive'
+ ping_alive=1
+ ps_alive=0
mysqld_get_param pid-file
++ mysqld_get_param pid-file
++ /usr/sbin/mysqld --print-defaults
++ tail -n 1
++ tr ' ' '\n'
++ cut -d= -f2
++ grep -- --pid-file
+ pidfile=/var/run/mysqld/mysqld.pid
+ '[' -f /var/run/mysqld/mysqld.pid ']'
cat $pidfile
++ cat /var/run/mysqld/mysqld.pid
+ ps 16225
+ ps_alive=1
+ '[' check_alive = check_alive -a 1 = 1 ']'
+ return 0
+ break
+ mysqld_status check_alive warn
$MYADMIN ping 2>&1
++ /usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping
+ ping_output='mysqld is alive'
+ ping_alive=1
+ ps_alive=0
mysqld_get_param pid-file
++ mysqld_get_param pid-file
++ grep -- --pid-file
++ /usr/sbin/mysqld --print-defaults
++ tr ' ' '\n'
++ tail -n 1
++ cut -d= -f2
+ pidfile=/var/run/mysqld/mysqld.pid
+ '[' -f /var/run/mysqld/mysqld.pid ']'
cat $pidfile
++ cat /var/run/mysqld/mysqld.pid
+ ps 16225
+ ps_alive=1
+ '[' check_alive = check_alive -a 1 = 1 ']'
+ return 0
+ log_end_msg 0
+ '[' -z 0 ']'
+ local retval
+ retval=0
+ log_end_msg_pre 0
+ log_use_fancy_output
+ TPUT=/usr/bin/tput
+ EXPR=/usr/bin/expr
+ '[' -t 1 ']'
+ FANCYTTY=0
+ case "$FANCYTTY" in
+ false
+ log_use_fancy_output
+ TPUT=/usr/bin/tput
+ EXPR=/usr/bin/expr
+ '[' -t 1 ']'
+ FANCYTTY=0
+ case "$FANCYTTY" in
+ false
+ RED=
+ YELLOW=
+ NORMAL=
+ '[' 0 -eq 0 ']'
+ echo .
.
+ log_end_msg_post 0
+ :
+ return 0
/etc/mysql/debian-start)
/etc/mysql/debian-start
++ /etc/mysql/debian-start
+ output=
+ '[' -n '' ']'
invoke-rc.d: initscript mysql, action "start" failed.
+ exit 1
dpkg: error processing mysql-server-5.5 (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
mysql-server-5.5
More information about the pkg-mysql-maint
mailing list