root@95f18ae10f8e:/build# apt install mariadb-server Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: mariadb-client-10.5 mariadb-plugin-rocksdb mariadb-plugin-s3 mariadb-server-10.5 mariadb-test mariadb-test-data Suggested packages: mailx netcat-openbsd patch The following packages will be upgraded: mariadb-client-10.5 mariadb-plugin-rocksdb mariadb-plugin-s3 mariadb-server mariadb-server-10.5 mariadb-test mariadb-test-data 7 upgraded, 0 newly installed, 0 to remove and 65 not upgraded. Need to get 45.8 MB of archives. After this operation, 5233 kB of additional disk space will be used. Do you want to continue? [Y/n] Get:1 http://deb.debian.org/debian sid/main amd64 mariadb-plugin-rocksdb amd64 1:10.5.8-3 [2471 kB] Get:2 http://deb.debian.org/debian sid/main amd64 mariadb-test amd64 1:10.5.8-3 [11.5 MB] Get:3 http://deb.debian.org/debian sid/main amd64 mariadb-client-10.5 amd64 1:10.5.8-3 [1490 kB] Get:4 http://deb.debian.org/debian sid/main amd64 mariadb-test-data all 1:10.5.8-3 [25.3 MB] Get:5 http://deb.debian.org/debian sid/main amd64 mariadb-plugin-s3 amd64 1:10.5.8-3 [797 kB] Get:6 http://deb.debian.org/debian sid/main amd64 mariadb-server-10.5 amd64 1:10.5.8-3 [4201 kB] Get:7 http://deb.debian.org/debian sid/main amd64 mariadb-server all 1:10.5.8-3 [34.1 kB] Fetched 45.8 MB in 8s (6049 kB/s) debconf: delaying package configuration, since apt-utils is not installed (Reading database ... 37284 files and directories currently installed.) Preparing to unpack .../0-mariadb-plugin-rocksdb_1%3a10.5.8-3_amd64.deb ... Unpacking mariadb-plugin-rocksdb (1:10.5.8-3) over (1:10.5.6-2) ... Preparing to unpack .../1-mariadb-test_1%3a10.5.8-3_amd64.deb ... Unpacking mariadb-test (1:10.5.8-3) over (1:10.5.6-2) ... Preparing to unpack .../2-mariadb-client-10.5_1%3a10.5.8-3_amd64.deb ... Unpacking mariadb-client-10.5 (1:10.5.8-3) over (1:10.5.6-2) ... Preparing to unpack .../3-mariadb-test-data_1%3a10.5.8-3_all.deb ... Unpacking mariadb-test-data (1:10.5.8-3) over (1:10.5.6-2) ... Preparing to unpack .../4-mariadb-plugin-s3_1%3a10.5.8-3_amd64.deb ... Unpacking mariadb-plugin-s3 (1:10.5.8-3) over (1:10.5.6-2) ... Preparing to unpack .../5-mariadb-server-10.5_1%3a10.5.8-3_amd64.deb ... test -x /usr/sbin/mariadbd || exit 0 + test -x /usr/sbin/mariadbd . /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)) if [ $# -ne 1 ]; then echo "$0: invalid arguments" >&2 return 4 fi 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 -c -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="--name $base --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 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 echo -n "$1:" || true return fi 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 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 "$@" echo -n "$@..." || true log_action_begin_msg_post "$@" } log_action_cont_msg () { 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 ++ for hook in $(run-parts --lsbsysinit --list /lib/lsb/init-functions.d 2>/dev/null) ++ '[' -r /lib/lsb/init-functions.d/00-verbose ']' ++ . /lib/lsb/init-functions.d/00-verbose ## Generated automatically. Do not edit! -*- shell-script -*- vlog_daemon_msg() { if test x"${VERBOSE:-yes}" != x"no" ; then log_daemon_msg "$@" fi } vlog_begin_msg() { if test x"${VERBOSE:-yes}" != x"no" ; then log_begin_msg "$@" fi } vlog_end_msg() { if test x"${VERBOSE:-yes}" != x"no" ; then log_end_msg "$@" fi } vlog_action_msg() { if test x"${VERBOSE:-yes}" != x"no" ; then log_action_msg "$@" fi } vlog_action_begin_msg() { if test x"${VERBOSE:-yes}" != x"no" ; then log_action_begin_msg "$@" fi } vlog_action_end_msg() { if test x"${VERBOSE:-yes}" != x"no" ; then log_action_end_msg "$@" fi } # vim: ft=sh FANCYTTY= ++ FANCYTTY= [ -e /etc/lsb-base-logging.sh ] && . /etc/lsb-base-logging.sh || true ++ '[' -e /etc/lsb-base-logging.sh ']' ++ true SELF=$(cd $(dirname $0); pwd -P)/$(basename $0) +++ dirname /etc/init.d/mariadb ++ cd /etc/init.d ++ pwd -P ++ basename /etc/init.d/mariadb + SELF=/etc/init.d/mariadb MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf" + MYADMIN='/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf' # priority can be overridden and "-s" adds output to stderr ERR_LOGGER="logger -p daemon.err -t /etc/init.d/mariadb -i" + ERR_LOGGER='logger -p daemon.err -t /etc/init.d/mariadb -i' if [ -f /etc/default/mysql ]; then . /etc/default/mysql fi + '[' -f /etc/default/mysql ']' # Also source default/mariadb in case the installation was upgraded from # packages originally installed from MariaDB.org repositories, which have # had support for reading /etc/default/mariadb since March 2016. if [ -f /etc/default/mariadb ]; then . /etc/default/mariadb fi + '[' -f /etc/default/mariadb ']' # 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 mariadbd_get_param option mariadbd_get_param() { /usr/sbin/mariadbd --print-defaults \ | tr " " "\n" \ | grep -- "--$1" \ | tail -n 1 \ | cut -d= -f2 } ## Do some sanity checks before even trying to start mariadbd. 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=`mariadbd_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 mariadbd in the process list # # Usage: boolean mariadbd_status [check_alive|check_dead] [warn|nowarn] mariadbd_status () { ping_output=`$MYADMIN ping 2>&1`; ping_alive=$(( ! $? )) ps_alive=0 pidfile=`mariadbd_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 MariaDB database server" "mariadbd" if mariadbd_status check_alive nowarn; then log_progress_msg "already running" log_end_msg 0 else # Could be removed during boot test -e /run/mysqld || install -m 755 -o mysql -g root -d /run/mysqld # Start MariaDB! /usr/bin/mysqld_safe "${@:2}" 2>&1 >/dev/null | $ERR_LOGGER & for i in $(seq 1 "${MYSQLD_STARTUP_TIMEOUT:-30}"); do sleep 1 if mariadbd_status check_alive nowarn ; then break; fi log_progress_msg "." done if mariadbd_status check_alive warn; then log_end_msg 0 # Now start mysqlcheck or whatever the admin wants. output=$(/etc/mysql/debian-start) if [ -n "$output" ]; then log_action_msg "$output" fi 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 MariaDB database server" "mariadbd" if ! mariadbd_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 MariaDB database server by signal" "mariadbd" killall -15 mariadbd server_down= for i in `seq 1 600`; do sleep 1 if mariadbd_status check_dead nowarn; then server_down=1; break; fi done if test -z "$server_down"; then killall -9 mariadbd; fi fi fi if ! mariadbd_status check_dead warn; then log_end_msg 1 log_failure_msg "Please stop MariaDB manually and read /usr/share/doc/mariadb-server-10.5/README.Debian.gz!" exit -1 else log_end_msg 0 fi ;; 'restart') set +e; $SELF stop; set -e shift $SELF start "${@}" ;; 'reload'|'force-reload') log_daemon_msg "Reloading MariaDB database server" "mariadbd" $MYADMIN reload log_end_msg 0 ;; 'status') if mariadbd_status check_alive nowarn; then log_action_msg "$($MYADMIN version)" else log_action_msg "MariaDB is stopped." exit 3 fi ;; 'bootstrap') # Bootstrap the cluster, start the first node # that initiates the cluster log_daemon_msg "Bootstrapping the cluster" "mariadbd" $SELF start "${@:2}" --wsrep-new-cluster ;; *) echo "Usage: $SELF start|stop|restart|reload|force-reload|status" exit 1 ;; esac + case "${1:-''}" in + log_daemon_msg 'Stopping MariaDB database server' mariadbd + '[' -z 'Stopping MariaDB database server' ']' + log_daemon_msg_pre 'Stopping MariaDB database server' mariadbd + : + '[' -z mariadbd ']' + echo -n 'Stopping MariaDB database server: mariadbd' Stopping MariaDB database server: mariadbd+ log_daemon_msg_post 'Stopping MariaDB database server' mariadbd + : + mariadbd_status check_dead nowarn ++ /usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping + ping_output='mysqld is alive' + ping_alive=1 + ps_alive=0 ++ mariadbd_get_param pid-file ++ /usr/sbin/mariadbd --print-defaults ++ tr ' ' '\n' ++ grep -- --pid-file ++ tail -n 1 ++ cut -d= -f2 + pidfile=/run/mysqld/mysqld.pid + '[' -f /run/mysqld/mysqld.pid ']' ++ cat /run/mysqld/mysqld.pid + ps 6090 + 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 ++ /usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf shutdown + shutdown_out= + r=0 + set -e + '[' 0 -ne 0 ']' + mariadbd_status check_dead warn ++ /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 '\''/run/mysqld/mysqld.sock'\'' (2)'\'' Check that mysqld is running and that the socket: '\''/run/mysqld/mysqld.sock'\'' exists!' + ping_alive=0 + ps_alive=0 ++ mariadbd_get_param pid-file ++ /usr/sbin/mariadbd --print-defaults ++ tr ' ' '\n' ++ grep -- --pid-file ++ tail -n 1 ++ cut -d= -f2 + pidfile=/run/mysqld/mysqld.pid + '[' -f /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 ']' + '[' xxterm '!=' x ']' + '[' xxterm '!=' xdumb ']' + '[' -x /usr/bin/tput ']' + '[' -x /usr/bin/expr ']' + /usr/bin/tput hpa 60 + /usr/bin/tput setaf 1 + '[' -z ']' + FANCYTTY=1 + case "$FANCYTTY" in + true ++ /usr/bin/tput setaf 1 + RED='' ++ /usr/bin/tput setaf 3 + YELLOW='' ++ /usr/bin/tput op + NORMAL='' + '[' 0 -eq 0 ']' + echo . . + log_end_msg_post 0 + : + return 0 + DEBIAN_SCRIPT_TRACE=1 ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } + echo '#42#DEBUG# RUNNING /var/lib/dpkg/tmp.ci/config configure 1:10.5.6-2' '1>&2' #42#DEBUG# RUNNING /var/lib/dpkg/tmp.ci/config configure 1:10.5.6-2 1>&2 # 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 mariadb-server-10.5/nis_warning || true db_go fi ++ which ypwhich + test -n '' + DEBIAN_SCRIPT_TRACE=1 ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } + echo '#42#DEBUG# RUNNING /var/lib/dpkg/tmp.ci/preinst upgrade 1:10.5.6-2 1:10.5.8-3' '1>&2' #42#DEBUG# RUNNING /var/lib/dpkg/tmp.ci/preinst upgrade 1:10.5.6-2 1:10.5.8-3 1>&2 export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin + export PATH=/usr/sbin:/usr/bin:/sbin:/bin:/sbin:/usr/sbin:/bin:/usr/bin + PATH=/usr/sbin:/usr/bin:/sbin:/bin:/sbin:/usr/sbin:/bin:/usr/bin mysql_datadir=/var/lib/mysql + mysql_datadir=/var/lib/mysql mysql_upgradedir=/var/lib/mysql-upgrade + mysql_upgradedir=/var/lib/mysql-upgrade # 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! Another mariadbd in e.g. a different chroot is fine for us. stop_server() { # Return immediately if there are no mysql processes running # as there is no point in trying to shutdown in that case. if ! pgrep -x --ns $$ mariadbd > /dev/null; then return; fi # Compatibility with versions that ran 'mysqld' if ! pgrep -x --ns $$ mysqld > /dev/null; then return; fi set +e invoke-rc.d mariadb stop invoke-rc.d mysql stop # Backwards compatibility errno=$? set -e # systemctl could emit exit code 100=no init script (fresh install) if [ "$errno" != 0 -a "$errno" != 100 ]; then echo "Attempt to stop MariaDB/MySQL server returned exitcode $errno" 1>&2 echo "There is a MariaDB/MySQL server running, but we failed in our attempts to stop it." 1>&2 echo "Stop it yourself and try again!" 1>&2 db_stop exit 1 fi } ################################ main() ########################## this_version=$MAJOR_VER + this_version=10.5 max_upgradeable_version=5.7 + max_upgradeable_version=5.7 # Check if a flag file is found that indicates a previous MariaDB or MySQL # version was installed. If multiple flags are found, check which one was # the biggest version number. for flag in $mysql_datadir/debian-*.flag do # The for loop leaves $flag as the query string if there are no results, # so the check below is needed to stop further processing when there are # no real results. if [ "$flag" = "$mysql_datadir/debian-*.flag" ] then break fi flag_version=$(echo "$flag" | sed 's/.*debian-\([0-9\.]\+\).flag/\1/') # Initialize value if empty if [ -z "$found_version" ] then found_version=$flag_version fi # Update value if now bigger then before if dpkg --compare-versions "$flag_version" '>>' "$found_version" then found_version=$flag_version fi done + for flag in $mysql_datadir/debian-*.flag + '[' /var/lib/mysql/debian-10.5.flag = '/var/lib/mysql/debian-*.flag' ']' ++ echo /var/lib/mysql/debian-10.5.flag ++ sed 's/.*debian-\([0-9\.]\+\).flag/\1/' + flag_version=10.5 + '[' -z '' ']' + found_version=10.5 + dpkg --compare-versions 10.5 '>>' 10.5 # If an upgrade is detected, proceed with it automatically without # requiring any user interaction. # # However, if the user attempts to downgrade, warn about the incompatibility. # Downgrade is detected if the flag version is bigger than $this_version # (e.g. 10.1 > 10.0) or the flag version is smaller than 10.0 but bigger # than $max_upgradeable_version. if [ ! -z "$found_version" ] then # MySQL 8.0 in Ubuntu has a bug in packaging and the file is name wrongly # 'debian-5.7.flag', so in case '5.7' was encountered an extra check needs to # be done to see is there is a file called undo_001, which is a sign of 8.0. if [ "$found_version" == "5.7" ] && [ -f "$mysql_datadir/undo_001" ] then # Seems to be a 8.0, flag has wrongly 5.7 (know bug) found_version=8.0 fi echo "$mysql_datadir: found previous version $found_version" if dpkg --compare-versions "$found_version" '>>' "$this_version" then downgrade_detected=true fi if dpkg --compare-versions "$found_version" '>>' "$max_upgradeable_version" \ && dpkg --compare-versions "$found_version" '<<' "10.0" then downgrade_detected=true fi fi + '[' '!' -z 10.5 ']' + '[' 10.5 == 5.7 ']' + echo '/var/lib/mysql: found previous version 10.5' /var/lib/mysql: found previous version 10.5 + dpkg --compare-versions 10.5 '>>' 10.5 + dpkg --compare-versions 10.5 '>>' 5.7 + dpkg --compare-versions 10.5 '<<' 10.0 # Don't abort dpkg if downgrade is detected (as was done previously). # Instead simply move the old datadir and create a new for this_version. if [ ! -z "$downgrade_detected" ] then db_input critical "mariadb-server-$MAJOR_VER/old_data_directory_saved" || true db_go echo "The file $mysql_datadir/debian-$found_version.flag indicates a" 1>&2 echo "version that cannot automatically be upgraded. Therefore the" 1>&2 echo "previous data directory will be renamed to $mysql_datadir-$found_version and" 1>&2 echo "a new data directory will be initialized at $mysql_datadir." 1>&2 echo "Please manually export/import your data (e.g. with mysqldump) if needed." 1>&2 mv -f "$mysql_datadir" "$mysql_datadir-$found_version" # Also move away the old debian.cnf file that included credentials that are # no longer valid mv -f /etc/mysql/debian.cnf "/etc/mysql/debian.cnf-$found_version" fi + '[' '!' -z '' ']' # to be sure stop_server + stop_server + pgrep -x --ns 6423 mariadbd + return # If we use NIS then errors should be tolerated. It's up to the # user to ensure that the mysql user is correctly setup. # 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 set +e fi ++ which ypwhich + test -n '' # # Now we have to ensure the following state: # /etc/passwd: mysql:x:100:101:MySQL Server:/nonexistent:/bin/false # /etc/group: mysql:x:101: # # Sadly there could any state be present on the system so we have to # modify everything carefully i.e. not doing a chown before creating # the user etc... # # creating mysql group if he isn't already there if ! getent group mysql >/dev/null; then # Adding system group: mysql. addgroup --system mysql >/dev/null fi + getent group mysql # creating mysql user if he isn't already there if ! getent passwd mysql >/dev/null; then # Adding system user: mysql. adduser \ --system \ --disabled-login \ --ingroup mysql \ --no-create-home \ --home /nonexistent \ --gecos "MySQL Server" \ --shell /bin/false \ mysql >/dev/null fi + getent passwd mysql # end of NIS tolerance zone set -e + set -e # if there's a symlink, let's store where it's pointing, because otherwise # it's going to be lost in some situations for dir in DATADIR LOGDIR; do checkdir=$(eval echo "$"$dir) if [ -L "$checkdir" ]; then # Use mkdir option 'Z' to create with correct SELinux context. mkdir -pZ "$mysql_upgradedir" cp -dT "$checkdir" "$mysql_upgradedir/$dir.link" fi done + for dir in DATADIR LOGDIR ++ eval echo '$DATADIR' +++ echo + checkdir= + '[' -L '' ']' + for dir in DATADIR LOGDIR ++ eval echo '$LOGDIR' +++ echo + checkdir= + '[' -L '' ']' # creating mysql home directory if [ ! -d $mysql_datadir ] && [ ! -L $mysql_datadir ]; then # Use mkdir option 'Z' to create with correct SELinux context. mkdir -Z $mysql_datadir fi + '[' '!' -d /var/lib/mysql ']' # checking disc space if LC_ALL=C BLOCKSIZE= df --portability $mysql_datadir/. | tail -n 1 | awk '{ exit ($4>1000) }'; then echo "ERROR: There's not enough space in $mysql_datadir/" 1>&2 db_stop exit 1 fi + LC_ALL=C + BLOCKSIZE= + df --portability /var/lib/mysql/. + tail -n 1 + awk '{ exit ($4>1000) }' # Since the home directory was created before putting the user into # the mysql group and moreover we cannot guarantee that the # permissions were correctly *before* calling this script, we fix them now. # In case we use NIS and no mysql user is present then this script should # better fail now than later.. # The "set +e" is necessary as e.g. a ".journal" of a ext3 partition is # not chgrp'able (#318435). set +e + set +e find $mysql_datadir ! -uid "$(id -u mysql)" -print0 | xargs -0 -r chown mysql + xargs -0 -r chown mysql ++ id -u mysql + find /var/lib/mysql '!' -uid 101 -print0 find $mysql_datadir -follow -not -group mysql -print0 2>/dev/null \ | xargs -0 --no-run-if-empty chgrp mysql + find /var/lib/mysql -follow -not -group mysql -print0 + xargs -0 --no-run-if-empty chgrp mysql set -e + set -e db_stop + db_stop + echo STOP Unpacking mariadb-server-10.5 (1:10.5.8-3) over (1:10.5.6-2) ... + DEBIAN_SCRIPT_TRACE=1 ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } + echo '#42#DEBUG# RUNNING /var/lib/dpkg/info/mariadb-server-10.5.postrm upgrade 1:10.5.8-3' '1>&2' #42#DEBUG# RUNNING /var/lib/dpkg/info/mariadb-server-10.5.postrm upgrade 1:10.5.8-3 1>&2 MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf" + MYADMIN='/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf' # 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! Another mariadbd in e.g. a different chroot is fine for us. stop_server() { # Return immediately if there are no mysql processes running # as there is no point in trying to shutdown in that case. if ! pgrep -x mariadbd > /dev/null; then return; fi # Compatibility with versions that ran 'mysqld' if ! pgrep -x mysqld > /dev/null; then return; fi set +e invoke-rc.d mariadb stop invoke-rc.d mysql stop # Backwards compatibility errno=$? set -e # systemctl could emit exit code 100=no init script (fresh install) if [ "$errno" != 0 -a "$errno" != 100 ]; then echo "Attempt to stop MariaDB/MySQL server returned exitcode $errno" 1>&2 echo "There is a MariaDB/MySQL server running, but we failed in our attempts to stop it." 1>&2 echo "Stop it yourself and try again!" 1>&2 db_stop exit 1 fi } case "$1" in purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) if [ -n "`$MYADMIN ping 2>/dev/null`" ]; then stop_server sleep 2 fi ;; *) echo "postrm called with unknown argument '$1'" 1>&2 exit 1 ;; esac + case "$1" in ++ /usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping + '[' -n '' ']' # # - Purge logs and data only if they are ours (#307473) # - Remove the mysql user only after all his owned files are purged. # - Cleanup the initscripts only if this was the last provider of them # if [ "$1" = "purge" ] && [ -f "/var/lib/mysql/debian-$MAJOR_VER.flag" ]; then # we remove the mysql user only after all his owned files are purged rm -f /var/log/mysql.{log,err}{,.0,.[1234567].gz} rm -rf /var/log/mysql db_input high "mariadb-server-$MAJOR_VER/postrm_remove_databases" || true db_go || true db_get "mariadb-server-$MAJOR_VER/postrm_remove_databases" || true if [ "$RET" = "true" ]; then # never remove the debian.cnf when the databases are still existing # else we ran into big trouble on the next install! rm -f /etc/mysql/debian.cnf # Remove all contents from /var/lib/mysql except if it's a # directory with file system data. See #829491 for details and # #608938 for potential mysql-server leftovers which erroneously # had been renamed. # Attempt removal only if the directory hasn't already been removed # by dpkg to avoid failing on "No such file or directory" errors. if [ -d /var/lib/mysql ] then find /var/lib/mysql -mindepth 1 \ -not -path '*/lost+found/*' -not -name 'lost+found' \ -not -path '*/lost@002bfound/*' -not -name 'lost@002bfound' \ -delete # "|| true" still needed as rmdir still exits with non-zero if # /var/lib/mysql is a mount point rmdir --ignore-fail-on-non-empty /var/lib/mysql || true fi rm -rf /run/mysqld # this directory is created by the init script, don't leave behind userdel mysql || true fi fi + '[' upgrade = purge ']' # Automatically added by dh_installinit/13.2.1 if [ "$1" = "purge" ] ; then update-rc.d mariadb remove >/dev/null fi + '[' upgrade = purge ']' # End automatically added section # Automatically added by dh_systemd_enable/13.2.1 if [ "$1" = "remove" ]; then if [ -x "/usr/bin/deb-systemd-helper" ]; then deb-systemd-helper mask 'mariadb.service' >/dev/null || true fi fi + '[' upgrade = remove ']' if [ "$1" = "purge" ]; then if [ -x "/usr/bin/deb-systemd-helper" ]; then deb-systemd-helper purge 'mariadb.service' >/dev/null || true deb-systemd-helper unmask 'mariadb.service' >/dev/null || true fi fi + '[' upgrade = purge ']' # End automatically added section # Automatically added by dh_systemd_enable/13.2.1 if [ "$1" = "remove" ]; then if [ -x "/usr/bin/deb-systemd-helper" ]; then deb-systemd-helper mask 'mariadb.service' >/dev/null || true fi fi + '[' upgrade = remove ']' if [ "$1" = "purge" ]; then if [ -x "/usr/bin/deb-systemd-helper" ]; then deb-systemd-helper purge 'mariadb.service' >/dev/null || true deb-systemd-helper unmask 'mariadb.service' >/dev/null || true fi fi + '[' upgrade = purge ']' # End automatically added section # Automatically added by dh_installdebconf/13.2.1 if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then . /usr/share/debconf/confmodule db_purge fi + '[' upgrade = purge ']' # End automatically added section # Modified dh_systemd_start snippet that's not added automatically if [ -d /run/systemd/system ]; then systemctl --system daemon-reload >/dev/null || true fi + '[' -d /run/systemd/system ']' Preparing to unpack .../6-mariadb-server_1%3a10.5.8-3_all.deb ... Unpacking mariadb-server (1:10.5.8-3) over (1:10.5.6-2) ... Setting up mariadb-test-data (1:10.5.8-3) ... Setting up mariadb-client-10.5 (1:10.5.8-3) ... Setting up mariadb-server-10.5 (1:10.5.8-3) ... Installing new version of config file /etc/mysql/mariadb.conf.d/50-server.cnf ... + DEBIAN_SCRIPT_TRACE=1 ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } + echo '#42#DEBUG# RUNNING /var/lib/dpkg/info/mariadb-server-10.5.config configure 1:10.5.6-2' '1>&2' #42#DEBUG# RUNNING /var/lib/dpkg/info/mariadb-server-10.5.config configure 1:10.5.6-2 1>&2 # 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 mariadb-server-10.5/nis_warning || true db_go fi ++ which ypwhich + test -n '' + DEBIAN_SCRIPT_TRACE=1 ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } + echo '#42#DEBUG# RUNNING /var/lib/dpkg/info/mariadb-server-10.5.postinst configure 1:10.5.6-2' '1>&2' #42#DEBUG# RUNNING /var/lib/dpkg/info/mariadb-server-10.5.postinst configure 1:10.5.6-2 1>&2 export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin + export PATH=/usr/sbin:/usr/bin:/sbin:/bin:/sbin:/usr/sbin:/bin:/usr/bin + PATH=/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 mariadb-server-$MAJOR_VER.postinst -i" + ERR_LOGGER='logger -p daemon.err -t mariadb-server-10.5.postinst -i' # Specify syslog tag name so it is clear the entry came from this postinst script. # This will make an error in a logged command immediately apparent by aborting # the install, rather than failing silently and leaving a broken install. set -o pipefail + set -o pipefail case "$1" in configure) # This is needed because mysql_install_db removes the pid file in /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 /run. set +e; invoke-rc.d mariadb stop; set -e # An existing /etc/init.d/mysql might be on the system if there was a # previous MySQL or MariaDB installation, since /etc/init.d files are # considered config files and stay around even after the package is removed. # # The install step of this package adds a new /etc/init.d/mariadb file. As # we also want to ensure that there are no old (and potentially outdated) # versions of /etc/init.d/mysql we simply replace it using a copy of the # latest 'mariadb' file. This has also the added benefit that anything that # invokes traditional sysv init with either 'mysql' or 'mariadb' will end up # controlling this newly installed MariaDB, and thus we maintain better # backwards compatiblity. # # Note that the 'Provides' line is also updated to avoid 'insserv' exiting # on failure (when it is run by update-rc.d) because of duplicate service # names. if [ -f "/etc/init.d/mysql" ] && [ -f "/etc/init.d/mariadb" ] then # Copy init file and rename the service name and filename on the fly sed 's/Provides: mariadb/Provides: mysql/g' /etc/init.d/mariadb > /etc/init.d/mysql # NOTE: Number of spaces/tabs is important here! # Confirm if the sed worked if ! grep --quiet "Provides: mysql" /etc/init.d/mysql then # If not, then delete the file to avoid failures later on rm -f /etc/init.d/mysql echo "Warning! Failed creating a mysql named copy of mariadb init.d file" fi fi mysql_statedir=/usr/share/mysql mysql_datadir=/var/lib/mysql mysql_logdir=/var/log/mysql mysql_cfgdir=/etc/mysql mysql_upgradedir=/var/lib/mysql-upgrade # If the following symlink exists, it is a preserved copy the old data dir # created by the preinst script during a 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_datadir else targetdir=$mysql_logdir 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 are 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 # Upgrading from mysql.com needs might have the root user as auth_socket. # auto.cnf is a sign of a mysql install, that doesn't exist in mariadb. # We use lsof to protect against concurrent access by mysqld (mariadb has # its own projection). We make sure we're not doing this on a MySQL-8.0 # directory. # This direct update is needed to enable an authentication mechanism to # perform mariadb-upgrade, (MDEV-22678). To keep the impact minimal, we # skip innodb and set key-buffer-size to 0 as it isn't reused. if [ -f "$mysql_datadir"/auto.cnf ] && [ -f "$mysql_datadir"/mysql/user.MYD ] && [ ! lsof -nt "$mysql_datadir"/mysql/user.MYD > /dev/null ] && [ ! -f "$mysql_datadir"/undo_001 ]; then echo "UPDATE mysql.user SET plugin='unix_socket' WHERE plugin='auth_socket';" | /usr/sbin/mariadbd --skip-innodb --key_buffer_size=0 --default-storage-engine=MyISAM --bootstrap 2> /dev/null fi # Ensure the existence and right permissions for the database and # log files. Use mkdir option 'Z' to create with correct SELinux context. if [ ! -d "$mysql_statedir" ] && [ ! -L "$mysql_statedir" ]; then mkdir -Z "$mysql_statedir"; fi if [ ! -d "$mysql_datadir" ] && [ ! -L "$mysql_datadir" ]; then mkdir -Z "$mysql_datadir" ; fi if [ ! -d "$mysql_logdir" ] && [ ! -L "$mysql_logdir" ]; then mkdir -Z "$mysql_logdir" ; 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_statedir 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_statedir find $mysql_datadir ! -uid "$(id -u mysql)" -print0 | xargs -0 -r chown mysql chown -R mysql:adm $mysql_logdir chmod 2750 $mysql_logdir set -e ## Set the correct filesystem ownership for the PAM v2 plugin # eg. /usr/lib/x86_64-linux-gnu/mysql/plugin/auth_pam_tool_dir/ # NOTE! This is security sensitive, don't allow for a race condition. # # 1. Drop privileges of directory # -> At this point only root can see and execute auth_pam_tool chmod 0700 /usr/lib/mysql/plugin/auth_pam_tool_dir # # 2. Make binary setuid # -> At this point only root can run the setuid binary so no escalation here yet chmod 04755 /usr/lib/mysql/plugin/auth_pam_tool_dir/auth_pam_tool # # 3. Allow user 'mysql' to see and execute auth_pam_tool # -> Now user mysql owns the directory and can see and execute the binary inside # -> Since the binary is setuid, user mysql gets limited root powers here to # run the PAM authetications, which need root (e.g. to validate passwords # against /etc/shadow) chown mysql /usr/lib/mysql/plugin/auth_pam_tool_dir # 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 mariadb-server/postrm_remove_database false || true # Clean up old flags before setting new one rm -f $mysql_datadir/debian-*.flag # Flag data dir to avoid downgrades touch "$mysql_datadir/debian-$MAJOR_VER.flag" # initiate databases. Output is not allowed by debconf :-( # This will fail if we are upgrading an existing database; in this case # mysql_upgrade, called from the /etc/init.d/mariadb start script, will # handle things. # Debian: beware of the bashisms... # Debian: can safely run on upgrades with existing databases set +e bash /usr/bin/mysql_install_db --rpm --cross-bootstrap --user=mysql \ --disable-log-bin --skip-test-db 2>&1 | \ $ERR_LOGGER set -e # To avoid downgrades. touch "$mysql_statedir/debian-$MAJOR_VER.flag" # On new installations root user can connect via unix_socket. # But on upgrades, scripts rely on debian-sys-maint user and # credentials in /etc/mysql/debian.cnf # All tools use --defaults-file=/etc/mysql/debian.cnf # And while it's not needed for new installations, we keep using # --defaults-file option for tools (for the sake of upgrades) # and thus need /etc/mysql/debian.cnf to exist, even if it's empty. # In the long run the goal is to obsolete this file. dc=$mysql_cfgdir/debian.cnf; if [ ! -d "$mysql_cfgdir" ]; then install -o 0 -g 0 -m 0755 -d $mysql_cfgdir fi if [ ! -e "$dc" ]; then cat /dev/null > $dc echo "# THIS FILE IS OBSOLETE. STOP USING IT IF POSSIBLE." >>$dc echo "# This file exists only for backwards compatibility for" >>$dc echo "# tools that run '--defaults-file=/etc/mysql/debian.cnf'" >>$dc echo "# and have root level access to the local filesystem." >>$dc echo "# With those permissions one can run 'mariadb' directly" >>$dc echo "# anyway thanks to unix socket authentication and hence" >>$dc echo "# this file is useless. See package README for more info." >>$dc echo "[client]" >>$dc echo "host = localhost" >>$dc echo "user = root" >>$dc echo "[mysql_upgrade]" >>$dc echo "host = localhost" >>$dc echo "user = root" >>$dc echo "# THIS FILE WILL BE REMOVED IN A FUTURE DEBIAN RELEASE." >>$dc fi # Keep it only root-readable, as it always was chown 0:0 $dc chmod 0600 $dc # If there is a real AppArmor profile, we reload it. # If the default empty profile is installed, then we remove any old # profile that may be loaded. # This allows upgrade from old versions (that have an apparmor profile # on by default) to work both to disable a default profile, and to keep # any profile installed and maintained by users themselves. profile="/etc/apparmor.d/usr.sbin.mariadbd" if [ -f "$profile" ] && aa-status --enabled 2>/dev/null; then if grep -q /usr/sbin/mariadbd "$profile" 2>/dev/null ; then apparmor_parser -r "$profile" || true else echo "/usr/sbin/mariadbd { }" | apparmor_parser --remove 2>/dev/null || true fi fi # The introduction of /etc/logrotate.d/mariadb has made the old config # obsolete and it needs to be disabled to prevent logrotate running twice. if [ -f /etc/logrotate.d/mysql-server ] then mv -vf /etc/logrotate.d/mysql-server /etc/logrotate.d/mysql-server.dpkg-bak fi ;; abort-upgrade|abort-remove|abort-configure) ;; triggered) if [ -x "$(command -v systemctl)" ]; then systemctl daemon-reload else invoke-rc.d mariadb restart fi ;; *) echo "postinst called with unknown argument '$1'" 1>&2 exit 1 ;; esac + case "$1" in + set +e + invoke-rc.d mariadb stop test -x /usr/sbin/mariadbd || exit 0 + test -x /usr/sbin/mariadbd . /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)) if [ $# -ne 1 ]; then echo "$0: invalid arguments" >&2 return 4 fi 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 -c -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="--name $base --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 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 echo -n "$1:" || true return fi 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 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 "$@" echo -n "$@..." || true log_action_begin_msg_post "$@" } log_action_cont_msg () { 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 ++ for hook in $(run-parts --lsbsysinit --list /lib/lsb/init-functions.d 2>/dev/null) ++ '[' -r /lib/lsb/init-functions.d/00-verbose ']' ++ . /lib/lsb/init-functions.d/00-verbose ## Generated automatically. Do not edit! -*- shell-script -*- vlog_daemon_msg() { if test x"${VERBOSE:-yes}" != x"no" ; then log_daemon_msg "$@" fi } vlog_begin_msg() { if test x"${VERBOSE:-yes}" != x"no" ; then log_begin_msg "$@" fi } vlog_end_msg() { if test x"${VERBOSE:-yes}" != x"no" ; then log_end_msg "$@" fi } vlog_action_msg() { if test x"${VERBOSE:-yes}" != x"no" ; then log_action_msg "$@" fi } vlog_action_begin_msg() { if test x"${VERBOSE:-yes}" != x"no" ; then log_action_begin_msg "$@" fi } vlog_action_end_msg() { if test x"${VERBOSE:-yes}" != x"no" ; then log_action_end_msg "$@" fi } # vim: ft=sh FANCYTTY= ++ FANCYTTY= [ -e /etc/lsb-base-logging.sh ] && . /etc/lsb-base-logging.sh || true ++ '[' -e /etc/lsb-base-logging.sh ']' ++ true SELF=$(cd $(dirname $0); pwd -P)/$(basename $0) +++ dirname /etc/init.d/mariadb ++ cd /etc/init.d ++ pwd -P ++ basename /etc/init.d/mariadb + SELF=/etc/init.d/mariadb MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf" + MYADMIN='/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf' # priority can be overridden and "-s" adds output to stderr ERR_LOGGER="logger -p daemon.err -t /etc/init.d/mariadb -i" + ERR_LOGGER='logger -p daemon.err -t /etc/init.d/mariadb -i' if [ -f /etc/default/mysql ]; then . /etc/default/mysql fi + '[' -f /etc/default/mysql ']' # Also source default/mariadb in case the installation was upgraded from # packages originally installed from MariaDB.org repositories, which have # had support for reading /etc/default/mariadb since March 2016. if [ -f /etc/default/mariadb ]; then . /etc/default/mariadb fi + '[' -f /etc/default/mariadb ']' # 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 mariadbd_get_param option mariadbd_get_param() { /usr/sbin/mariadbd --print-defaults \ | tr " " "\n" \ | grep -- "--$1" \ | tail -n 1 \ | cut -d= -f2 } ## Do some sanity checks before even trying to start mariadbd. 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=`mariadbd_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 mariadbd in the process list # # Usage: boolean mariadbd_status [check_alive|check_dead] [warn|nowarn] mariadbd_status () { ping_output=`$MYADMIN ping 2>&1`; ping_alive=$(( ! $? )) ps_alive=0 pidfile=`mariadbd_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 MariaDB database server" "mariadbd" if mariadbd_status check_alive nowarn; then log_progress_msg "already running" log_end_msg 0 else # Could be removed during boot test -e /run/mysqld || install -m 755 -o mysql -g root -d /run/mysqld # Start MariaDB! /usr/bin/mysqld_safe "${@:2}" 2>&1 >/dev/null | $ERR_LOGGER & for i in $(seq 1 "${MYSQLD_STARTUP_TIMEOUT:-30}"); do sleep 1 if mariadbd_status check_alive nowarn ; then break; fi log_progress_msg "." done if mariadbd_status check_alive warn; then log_end_msg 0 # Now start mysqlcheck or whatever the admin wants. output=$(/etc/mysql/debian-start) if [ -n "$output" ]; then log_action_msg "$output" fi 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 MariaDB database server" "mariadbd" if ! mariadbd_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 MariaDB database server by signal" "mariadbd" killall -15 mariadbd server_down= for i in `seq 1 600`; do sleep 1 if mariadbd_status check_dead nowarn; then server_down=1; break; fi done if test -z "$server_down"; then killall -9 mariadbd; fi fi fi if ! mariadbd_status check_dead warn; then log_end_msg 1 log_failure_msg "Please stop MariaDB manually and read /usr/share/doc/mariadb-server-10.5/README.Debian.gz!" exit -1 else log_end_msg 0 fi ;; 'restart') set +e; $SELF stop; set -e shift $SELF start "${@}" ;; 'reload'|'force-reload') log_daemon_msg "Reloading MariaDB database server" "mariadbd" $MYADMIN reload log_end_msg 0 ;; 'status') if mariadbd_status check_alive nowarn; then log_action_msg "$($MYADMIN version)" else log_action_msg "MariaDB is stopped." exit 3 fi ;; 'bootstrap') # Bootstrap the cluster, start the first node # that initiates the cluster log_daemon_msg "Bootstrapping the cluster" "mariadbd" $SELF start "${@:2}" --wsrep-new-cluster ;; *) echo "Usage: $SELF start|stop|restart|reload|force-reload|status" exit 1 ;; esac + case "${1:-''}" in + log_daemon_msg 'Stopping MariaDB database server' mariadbd + '[' -z 'Stopping MariaDB database server' ']' + log_daemon_msg_pre 'Stopping MariaDB database server' mariadbd + : + '[' -z mariadbd ']' + echo -n 'Stopping MariaDB database server: mariadbd' Stopping MariaDB database server: mariadbd+ log_daemon_msg_post 'Stopping MariaDB database server' mariadbd + : + mariadbd_status check_dead nowarn ++ /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 '\''/run/mysqld/mysqld.sock'\'' (2)'\'' Check that mysqld is running and that the socket: '\''/run/mysqld/mysqld.sock'\'' exists!' + ping_alive=0 + ps_alive=0 ++ mariadbd_get_param pid-file ++ /usr/sbin/mariadbd --print-defaults ++ tr ' ' '\n' ++ grep -- --pid-file ++ cut -d= -f2 ++ tail -n 1 + pidfile=/run/mysqld/mysqld.pid + '[' -f /run/mysqld/mysqld.pid ']' + '[' check_dead = check_alive -a 0 = 1 ']' + '[' check_dead = check_dead -a 0 = 0 -a 0 = 0 ']' + return 0 + mariadbd_status check_dead warn ++ /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 '\''/run/mysqld/mysqld.sock'\'' (2)'\'' Check that mysqld is running and that the socket: '\''/run/mysqld/mysqld.sock'\'' exists!' + ping_alive=0 + ps_alive=0 ++ mariadbd_get_param pid-file ++ /usr/sbin/mariadbd --print-defaults ++ tr ' ' '\n' ++ grep -- --pid-file ++ tail -n 1 ++ cut -d= -f2 + pidfile=/run/mysqld/mysqld.pid + '[' -f /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 ']' + '[' xxterm '!=' x ']' + '[' xxterm '!=' xdumb ']' + '[' -x /usr/bin/tput ']' + '[' -x /usr/bin/expr ']' + /usr/bin/tput hpa 60 + /usr/bin/tput setaf 1 + '[' -z ']' + FANCYTTY=1 + case "$FANCYTTY" in + true ++ /usr/bin/tput setaf 1 + RED='' ++ /usr/bin/tput setaf 3 + YELLOW='' ++ /usr/bin/tput op + NORMAL='' + '[' 0 -eq 0 ']' + echo . . + log_end_msg_post 0 + : + return 0 + set -e + '[' -f /etc/init.d/mysql ']' + mysql_statedir=/usr/share/mysql + mysql_datadir=/var/lib/mysql + mysql_logdir=/var/log/mysql + mysql_cfgdir=/etc/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 + '[' -f /var/lib/mysql/auto.cnf ']' + '[' '!' -d /usr/share/mysql ']' + '[' '!' -d /var/lib/mysql ']' + '[' '!' -d /var/log/mysql ']' + set +e + chown -R 0:0 /usr/share/mysql + xargs -0 -r chown mysql ++ id -u mysql + find /var/lib/mysql '!' -uid 101 -print0 + chown -R mysql:adm /var/log/mysql + chmod 2750 /var/log/mysql + set -e + chmod 0700 /usr/lib/mysql/plugin/auth_pam_tool_dir + chmod 04755 /usr/lib/mysql/plugin/auth_pam_tool_dir/auth_pam_tool + chown mysql /usr/lib/mysql/plugin/auth_pam_tool_dir + db_set mariadb-server/postrm_remove_database false + _db_cmd 'SET mariadb-server/postrm_remove_database' false + _db_internal_IFS=' ' + IFS=' ' + printf '%s\n' 'SET mariadb-server/postrm_remove_database false' + IFS=' ' + read -r _db_internal_line + IFS=' ' + RET='10 mariadb-server/postrm_remove_database doesn'\''t exist' + case ${_db_internal_line%%[ ]*} in + return 10 + true + rm -f /var/lib/mysql/debian-10.5.flag + touch /var/lib/mysql/debian-10.5.flag + set +e + bash /usr/bin/mysql_install_db --rpm --cross-bootstrap --user=mysql --disable-log-bin --skip-test-db + logger -p daemon.err -t mariadb-server-10.5.postinst -i + set -e + touch /usr/share/mysql/debian-10.5.flag + dc=/etc/mysql/debian.cnf + '[' '!' -d /etc/mysql ']' + '[' '!' -e /etc/mysql/debian.cnf ']' + chown 0:0 /etc/mysql/debian.cnf + chmod 0600 /etc/mysql/debian.cnf + profile=/etc/apparmor.d/usr.sbin.mariadbd + '[' -f /etc/apparmor.d/usr.sbin.mariadbd ']' + aa-status --enabled + '[' -f /etc/logrotate.d/mysql-server ']' db_stop # in case invoke failes + db_stop + echo STOP # dh_systemd_start doesn't emit anything since we still ship /etc/init.d/mariadb. # Thus MariaDB server is started via init.d script, which in turn redirects to # systemctl. If we upgrade from MySQL mysql.service may be masked, which also # means init.d script is disabled. Unmask mysql service explicitly. # Check first that the command exists, to avoid emitting any warning messages. if [ -x "$(command -v deb-systemd-helper)" ]; then deb-systemd-helper unmask mysql.service > /dev/null fi ++ command -v deb-systemd-helper + '[' -x /usr/bin/deb-systemd-helper ']' + deb-systemd-helper unmask mysql.service # Automatically added by dh_systemd_enable/13.2.1 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'mariadb.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'mariadb.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'mariadb.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'mariadb.service' >/dev/null || true fi fi + '[' configure = configure ']' + deb-systemd-helper unmask mariadb.service + deb-systemd-helper --quiet was-enabled mariadb.service + deb-systemd-helper enable mariadb.service # End automatically added section # Automatically added by dh_systemd_enable/13.2.1 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if deb-systemd-helper debian-installed 'mariadb.service'; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'mariadb.service' >/dev/null || true if deb-systemd-helper --quiet was-enabled 'mariadb.service'; then # Create new symlinks, if any. deb-systemd-helper enable 'mariadb.service' >/dev/null || true fi fi # Update the statefile to add new symlinks (if any), which need to be cleaned # up on purge. Also remove old symlinks. deb-systemd-helper update-state 'mariadb.service' >/dev/null || true fi + '[' configure = configure ']' + deb-systemd-helper debian-installed mariadb.service + deb-systemd-helper unmask mariadb.service + deb-systemd-helper --quiet was-enabled mariadb.service + deb-systemd-helper enable mariadb.service + deb-systemd-helper update-state mariadb.service # End automatically added section # Automatically added by dh_installinit/13.2.1 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -x "/etc/init.d/mariadb" ]; then update-rc.d mariadb defaults 19 21 >/dev/null || exit 1 fi fi + '[' configure = configure ']' + '[' -x /etc/init.d/mariadb ']' + update-rc.d mariadb defaults 19 21 # End automatically added section # Modified dh_systemd_start snippet that's not added automatically if [ -d /run/systemd/system ]; then systemctl --system daemon-reload >/dev/null || true deb-systemd-invoke start mariadb.service >/dev/null || true # Modified dh_installinit snippet to only run with sysvinit elif [ -x "/etc/init.d/mariadb" ]; then if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then invoke-rc.d mariadb start || exit $? fi fi + '[' -d /run/systemd/system ']' + '[' -x /etc/init.d/mariadb ']' + '[' configure = configure ']' + invoke-rc.d mariadb start test -x /usr/sbin/mariadbd || exit 0 + test -x /usr/sbin/mariadbd . /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)) if [ $# -ne 1 ]; then echo "$0: invalid arguments" >&2 return 4 fi 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 -c -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="--name $base --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 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 echo -n "$1:" || true return fi 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 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 "$@" echo -n "$@..." || true log_action_begin_msg_post "$@" } log_action_cont_msg () { 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 ++ for hook in $(run-parts --lsbsysinit --list /lib/lsb/init-functions.d 2>/dev/null) ++ '[' -r /lib/lsb/init-functions.d/00-verbose ']' ++ . /lib/lsb/init-functions.d/00-verbose ## Generated automatically. Do not edit! -*- shell-script -*- vlog_daemon_msg() { if test x"${VERBOSE:-yes}" != x"no" ; then log_daemon_msg "$@" fi } vlog_begin_msg() { if test x"${VERBOSE:-yes}" != x"no" ; then log_begin_msg "$@" fi } vlog_end_msg() { if test x"${VERBOSE:-yes}" != x"no" ; then log_end_msg "$@" fi } vlog_action_msg() { if test x"${VERBOSE:-yes}" != x"no" ; then log_action_msg "$@" fi } vlog_action_begin_msg() { if test x"${VERBOSE:-yes}" != x"no" ; then log_action_begin_msg "$@" fi } vlog_action_end_msg() { if test x"${VERBOSE:-yes}" != x"no" ; then log_action_end_msg "$@" fi } # vim: ft=sh FANCYTTY= ++ FANCYTTY= [ -e /etc/lsb-base-logging.sh ] && . /etc/lsb-base-logging.sh || true ++ '[' -e /etc/lsb-base-logging.sh ']' ++ true SELF=$(cd $(dirname $0); pwd -P)/$(basename $0) +++ dirname /etc/init.d/mariadb ++ cd /etc/init.d ++ pwd -P ++ basename /etc/init.d/mariadb + SELF=/etc/init.d/mariadb MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf" + MYADMIN='/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf' # priority can be overridden and "-s" adds output to stderr ERR_LOGGER="logger -p daemon.err -t /etc/init.d/mariadb -i" + ERR_LOGGER='logger -p daemon.err -t /etc/init.d/mariadb -i' if [ -f /etc/default/mysql ]; then . /etc/default/mysql fi + '[' -f /etc/default/mysql ']' # Also source default/mariadb in case the installation was upgraded from # packages originally installed from MariaDB.org repositories, which have # had support for reading /etc/default/mariadb since March 2016. if [ -f /etc/default/mariadb ]; then . /etc/default/mariadb fi + '[' -f /etc/default/mariadb ']' # 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 mariadbd_get_param option mariadbd_get_param() { /usr/sbin/mariadbd --print-defaults \ | tr " " "\n" \ | grep -- "--$1" \ | tail -n 1 \ | cut -d= -f2 } ## Do some sanity checks before even trying to start mariadbd. 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=`mariadbd_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 mariadbd in the process list # # Usage: boolean mariadbd_status [check_alive|check_dead] [warn|nowarn] mariadbd_status () { ping_output=`$MYADMIN ping 2>&1`; ping_alive=$(( ! $? )) ps_alive=0 pidfile=`mariadbd_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 MariaDB database server" "mariadbd" if mariadbd_status check_alive nowarn; then log_progress_msg "already running" log_end_msg 0 else # Could be removed during boot test -e /run/mysqld || install -m 755 -o mysql -g root -d /run/mysqld # Start MariaDB! /usr/bin/mysqld_safe "${@:2}" 2>&1 >/dev/null | $ERR_LOGGER & for i in $(seq 1 "${MYSQLD_STARTUP_TIMEOUT:-30}"); do sleep 1 if mariadbd_status check_alive nowarn ; then break; fi log_progress_msg "." done if mariadbd_status check_alive warn; then log_end_msg 0 # Now start mysqlcheck or whatever the admin wants. output=$(/etc/mysql/debian-start) if [ -n "$output" ]; then log_action_msg "$output" fi 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 MariaDB database server" "mariadbd" if ! mariadbd_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 MariaDB database server by signal" "mariadbd" killall -15 mariadbd server_down= for i in `seq 1 600`; do sleep 1 if mariadbd_status check_dead nowarn; then server_down=1; break; fi done if test -z "$server_down"; then killall -9 mariadbd; fi fi fi if ! mariadbd_status check_dead warn; then log_end_msg 1 log_failure_msg "Please stop MariaDB manually and read /usr/share/doc/mariadb-server-10.5/README.Debian.gz!" exit -1 else log_end_msg 0 fi ;; 'restart') set +e; $SELF stop; set -e shift $SELF start "${@}" ;; 'reload'|'force-reload') log_daemon_msg "Reloading MariaDB database server" "mariadbd" $MYADMIN reload log_end_msg 0 ;; 'status') if mariadbd_status check_alive nowarn; then log_action_msg "$($MYADMIN version)" else log_action_msg "MariaDB is stopped." exit 3 fi ;; 'bootstrap') # Bootstrap the cluster, start the first node # that initiates the cluster log_daemon_msg "Bootstrapping the cluster" "mariadbd" $SELF start "${@:2}" --wsrep-new-cluster ;; *) echo "Usage: $SELF start|stop|restart|reload|force-reload|status" exit 1 ;; esac + case "${1:-''}" in + sanity_checks + '[' '!' -r /etc/mysql/my.cnf ']' ++ mariadbd_get_param datadir ++ /usr/sbin/mariadbd --print-defaults ++ tr ' ' '\n' ++ grep -- --datadir ++ tail -n 1 ++ cut -d= -f2 + datadir=/var/lib/mysql + LC_ALL=C + BLOCKSIZE= + df --portability /var/lib/mysql/. + tail -n 1 + awk '{ exit ($4>4096) }' + log_daemon_msg 'Starting MariaDB database server' mariadbd + '[' -z 'Starting MariaDB database server' ']' + log_daemon_msg_pre 'Starting MariaDB database server' mariadbd + : + '[' -z mariadbd ']' + echo -n 'Starting MariaDB database server: mariadbd' Starting MariaDB database server: mariadbd+ log_daemon_msg_post 'Starting MariaDB database server' mariadbd + : + mariadbd_status check_alive nowarn ++ /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 '\''/run/mysqld/mysqld.sock'\'' (2)'\'' Check that mysqld is running and that the socket: '\''/run/mysqld/mysqld.sock'\'' exists!' + ping_alive=0 + ps_alive=0 ++ mariadbd_get_param pid-file ++ /usr/sbin/mariadbd --print-defaults ++ tr ' ' '\n' ++ grep -- --pid-file ++ tail -n 1 ++ cut -d= -f2 + pidfile=/run/mysqld/mysqld.pid + '[' -f /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 /run/mysqld + /usr/bin/mysqld_safe + logger -p daemon.err -t /etc/init.d/mariadb -i ++ seq 1 30 + for i in $(seq 1 "${MYSQLD_STARTUP_TIMEOUT:-30}") + sleep 1 + mariadbd_status check_alive nowarn ++ /usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping + ping_output='mysqld is alive' + ping_alive=1 + ps_alive=0 ++ mariadbd_get_param pid-file ++ /usr/sbin/mariadbd --print-defaults ++ tr ' ' '\n' ++ grep -- --pid-file ++ tail -n 1 ++ cut -d= -f2 + pidfile=/run/mysqld/mysqld.pid + '[' -f /run/mysqld/mysqld.pid ']' ++ cat /run/mysqld/mysqld.pid + ps 6749 + ps_alive=1 + '[' check_alive = check_alive -a 1 = 1 ']' + return 0 + break + mariadbd_status check_alive warn ++ /usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping + ping_output='mysqld is alive' + ping_alive=1 + ps_alive=0 ++ mariadbd_get_param pid-file ++ /usr/sbin/mariadbd --print-defaults ++ tr ' ' '\n' ++ grep -- --pid-file ++ tail -n 1 ++ cut -d= -f2 + pidfile=/run/mysqld/mysqld.pid + '[' -f /run/mysqld/mysqld.pid ']' ++ cat /run/mysqld/mysqld.pid + ps 6749 + 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 ']' + '[' xxterm '!=' x ']' + '[' xxterm '!=' xdumb ']' + '[' -x /usr/bin/tput ']' + '[' -x /usr/bin/expr ']' + /usr/bin/tput hpa 60 + /usr/bin/tput setaf 1 + '[' -z ']' + FANCYTTY=1 + case "$FANCYTTY" in + true ++ /usr/bin/tput setaf 1 + RED='' ++ /usr/bin/tput setaf 3 + YELLOW='' ++ /usr/bin/tput op + NORMAL='' + '[' 0 -eq 0 ']' + echo . . + log_end_msg_post 0 + : + return 0 ++ /etc/mysql/debian-start + output= + '[' -n '' ']' Setting up mariadb-server (1:10.5.8-3) ... Setting up mariadb-test (1:10.5.8-3) ... Setting up mariadb-plugin-rocksdb (1:10.5.8-3) ... Setting up mariadb-plugin-s3 (1:10.5.8-3) ... root@95f18ae10f8e:/build#