summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2017-10-08 13:17:19 +0300
committerIgor Pashev <pashev.igor@gmail.com>2017-10-08 16:12:38 +0300
commita312ac2b0a7d339c2d7a94f3805e1f5186424966 (patch)
tree803160f0f683c9696f9493138f0e802921a7a3e6
parentd4e345f2fa6fa245286946cd3c803586019153f0 (diff)
downloadmariadb-10.1-a312ac2b0a7d339c2d7a94f3805e1f5186424966.tar.gz
Add SMF service
Remove all legacy stuff. Perform install database in SMF service.
-rwxr-xr-xdebian/additions/debian-start42
-rwxr-xr-xdebian/additions/debian-start.inc.sh79
-rw-r--r--debian/mariadb-server-10.1.config14
-rw-r--r--debian/mariadb-server-10.1.insserv.conf1
-rwxr-xr-xdebian/mariadb-server-10.1.install3
-rw-r--r--debian/mariadb-server-10.1.mysql.default24
-rw-r--r--debian/mariadb-server-10.1.mysql.init207
-rw-r--r--debian/mariadb-server-10.1.postinst191
-rw-r--r--debian/mariadb-server-10.1.postrm55
-rw-r--r--debian/mariadb-server-10.1.preinst184
-rw-r--r--debian/mariadb-server-10.1.smf/manifest/application/database/mariadb.xml32
-rwxr-xr-xdebian/mariadb-server-10.1.smf/method/mariadb94
-rw-r--r--debian/mariadb-server-10.1.templates45
-rwxr-xr-xdebian/rules2
14 files changed, 146 insertions, 827 deletions
diff --git a/debian/additions/debian-start b/debian/additions/debian-start
deleted file mode 100755
index 40c248f..0000000
--- a/debian/additions/debian-start
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/bash
-#
-# This script is executed by "/etc/init.d/mysql" on every (re)start.
-#
-# Changes to this file will be preserved when updating the Debian package.
-#
-# NOTE: This file is read only by the traditional SysV init script, not systemd.
-#
-
-source /usr/share/mysql/debian-start.inc.sh
-
-if [ -f /etc/default/mysql ]; then
- . /etc/default/mysql
-fi
-
-MYSQL="/usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf"
-MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
-MYUPGRADE="/usr/bin/mysql_upgrade --defaults-extra-file=/etc/mysql/debian.cnf"
-MYCHECK="/usr/bin/mysqlcheck --defaults-file=/etc/mysql/debian.cnf"
-MYCHECK_SUBJECT="WARNING: mysqlcheck has found corrupt tables"
-MYCHECK_PARAMS="--all-databases --fast --silent"
-MYCHECK_RCPT="${MYCHECK_RCPT:-root}"
-
-## Checking for corrupt, not cleanly closed (only for MyISAM and Aria engines) and upgrade needing tables.
-
-# The following commands should be run when the server is up but in background
-# where they do not block the server start and in one shell instance so that
-# they run sequentially. They are supposed not to echo anything to stdout.
-# If you want to disable the check for crashed tables comment
-# "check_for_crashed_tables" out.
-# (There may be no output to stdout inside the background process!)
-
-# Need to ignore SIGHUP, as otherwise a SIGHUP can sometimes abort the upgrade
-# process in the middle.
-trap "" SIGHUP
-(
- upgrade_system_tables_if_necessary;
- check_root_accounts;
- check_for_crashed_tables;
-) >&2 &
-
-exit 0
diff --git a/debian/additions/debian-start.inc.sh b/debian/additions/debian-start.inc.sh
deleted file mode 100755
index 33cd892..0000000
--- a/debian/additions/debian-start.inc.sh
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/bin/bash
-#
-# This file is included by /etc/mysql/debian-start
-#
-
-## Check MyISAM and Aria unclosed tables.
-# - Requires the server to be up.
-# - Is supposed to run silently in background.
-function check_for_crashed_tables() {
- set -e
- set -u
-
- # But do it in the background to not stall the boot process.
- logger -p daemon.info -i -t$0 "Triggering myisam-recover for all MyISAM tables and aria-recover for all Aria tables"
-
- # Checking for $? is unreliable so the size of the output is checked.
- # Some table handlers like HEAP do not support CHECK TABLE.
- tempfile=`tempfile`
-
- # We have to use xargs in this case, because a for loop barfs on the
- # spaces in the thing to be looped over.
-
- # If a crashed table is encountered, the "mysql" command will return with a status different from 0
- set +e
-
- LC_ALL=C $MYSQL --skip-column-names --batch -e '
- select concat('\''select count(*) into @discard from `'\'',
- TABLE_SCHEMA, '\''`.`'\'', TABLE_NAME, '\''`'\'')
- from information_schema.TABLES where TABLE_SCHEMA<>'\''INFORMATION_SCHEMA'\'' and TABLE_SCHEMA<>'\''PERFORMANCE_SCHEMA'\'' and ( ENGINE='\''MyISAM'\'' or ENGINE='\''Aria'\'' )' | \
- xargs -i $MYSQL --skip-column-names --silent --batch \
- --force -e "{}" &>$tempfile
- set -e
-
- if [ -s "$tempfile" ]; then
- (
- /bin/echo -e "\n" \
- "Improperly closed tables are also reported if clients are accessing\n" \
- "the tables *now*. A list of current connections is below.\n";
- $MYADMIN processlist status
- ) >> $tempfile
- # Check for presence as a dependency on mailx would require an MTA.
- if [ -x /usr/bin/mailx ]; then
- mailx -e -s"$MYCHECK_SUBJECT" $MYCHECK_RCPT < $tempfile
- fi
- (echo "$MYCHECK_SUBJECT"; cat $tempfile) | logger -p daemon.warn -i -t$0
- fi
- rm $tempfile
-}
-
-## Check for tables needing an upgrade.
-# - Requires the server to be up.
-# - Is supposed to run silently in background.
-function upgrade_system_tables_if_necessary() {
- set -e
- set -u
-
- logger -p daemon.info -i -t$0 "Upgrading MySQL tables if necessary."
-
- # Filter all "duplicate column", "duplicate key" and "unknown column"
- # errors as the script is designed to be idempotent.
- LC_ALL=C $MYUPGRADE \
- 2>&1 \
- | egrep -v '^(1|@had|ERROR (1054|1060|1061))' \
- | logger -p daemon.warn -i -t$0
-}
-
-## Check for the presence of both, root accounts with and without password.
-# This might have been caused by a bug related to mysql_install_db (#418672).
-function check_root_accounts() {
- set -e
- set -u
-
- logger -p daemon.info -i -t$0 "Checking for insecure root accounts."
-
- ret=$( echo "SELECT count(*) FROM mysql.user WHERE user='root' and password='' and plugin='';" | $MYSQL --skip-column-names )
- if [ "$ret" -ne "0" ]; then
- logger -p daemon.warn -i -t$0 "WARNING: mysql.user contains $ret root accounts without password or plugin!"
- fi
-}
diff --git a/debian/mariadb-server-10.1.config b/debian/mariadb-server-10.1.config
deleted file mode 100644
index 7da26df..0000000
--- a/debian/mariadb-server-10.1.config
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-set -e
-
-. /usr/share/debconf/confmodule
-
-if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi
-${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 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.1/nis_warning || true
- db_go
-fi
diff --git a/debian/mariadb-server-10.1.insserv.conf b/debian/mariadb-server-10.1.insserv.conf
deleted file mode 100644
index cb29a54..0000000
--- a/debian/mariadb-server-10.1.insserv.conf
+++ /dev/null
@@ -1 +0,0 @@
-$database mysql
diff --git a/debian/mariadb-server-10.1.install b/debian/mariadb-server-10.1.install
index 2b9d6c6..ad17d9d 100755
--- a/debian/mariadb-server-10.1.install
+++ b/debian/mariadb-server-10.1.install
@@ -3,13 +3,10 @@
[linux-any] usr/bin/galera_new_cluster
[linux-any] usr/bin/galera_recovery
[linux-any] usr/bin/mariadb-service-convert
-debian/additions/debian-start etc/mysql
-debian/additions/debian-start.inc.sh usr/share/mysql
debian/additions/echo_stderr usr/share/mysql
debian/additions/mariadb.conf.d/50-mysqld_safe.cnf etc/mysql/mariadb.conf.d
debian/additions/mariadb.conf.d/50-server.cnf etc/mysql/mariadb.conf.d
debian/additions/source_mariadb-10.1.py usr/share/apport/package-hooks
-debian/mariadb-server-10.1.insserv.conf => etc/insserv.conf.d/mariadb
[linux-any] lib/systemd/system/mariadb@.service
[linux-any] lib/systemd/system/mariadb.service
usr/bin/aria_chk
diff --git a/debian/mariadb-server-10.1.mysql.default b/debian/mariadb-server-10.1.mysql.default
deleted file mode 100644
index 3d3bc80..0000000
--- a/debian/mariadb-server-10.1.mysql.default
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# NOTE: This file is read only by the traditional SysV init script and has been
-# available only in Ubuntu 16.04 and 16.10 and never in a official Debian release.
-# Debian 9 and Ubuntu 17.04 onwards do not normally read this file as they use
-# systemd by default.
-#
-# For similar behaviour, systemd users should override ExecStart by dropping
-# files into /etc/systemd/system/mariadb.service.d/
-#
-# See also:
-# https://wiki.debian.org/Teams/pkg-systemd/Packaging#overriding_options_and_.2Fetc.2Fdefault_handling
-# https://mariadb.com/kb/en/mariadb/systemd/
-#
-# Note also that MariaDB systemd does _not_ utilize mysqld_safe nor debian-start.
-
-
-# The delay in seconds the init script waits for the server to be up and running after having started "mysqld_safe" to run the "/etc/mysql/debian-start" script.
-# If the server is still not responding after the delay, the script won't be executed and an error will be thrown on the syslog.
-# Default: 30
-#MYSQLD_STARTUP_TIMEOUT=30
-
-# The email recipient(s) of the output of the check for crashed and improperly closed MyISAM and Aria tables done at each server start by the "/etc/mysql/debian-start" script.
-# Default: root
-#MYCHECK_RCPT="root"
diff --git a/debian/mariadb-server-10.1.mysql.init b/debian/mariadb-server-10.1.mysql.init
deleted file mode 100644
index c18ef8c..0000000
--- a/debian/mariadb-server-10.1.mysql.init
+++ /dev/null
@@ -1,207 +0,0 @@
-#!/bin/bash
-#
-### BEGIN INIT INFO
-# Provides: mysql
-# Required-Start: $remote_fs $syslog
-# Required-Stop: $remote_fs $syslog
-# Should-Start: $network $named $time
-# Should-Stop: $network $named $time
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Start and stop the mysql database server daemon
-# Description: Controls the main MariaDB database server daemon "mysqld"
-# and its wrapper script "mysqld_safe".
-### END INIT INFO
-#
-set -e
-set -u
-${DEBIAN_SCRIPT_DEBUG:+ set -v -x}
-
-test -x /usr/sbin/mysqld || exit 0
-
-. /lib/lsb/init-functions
-
-SELF=$(cd $(dirname $0); pwd -P)/$(basename $0)
-
-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/mysql -i"
-
-if [ -f /etc/default/mysql ]; then
- . /etc/default/mysql
-fi
-
-# 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
-
-# Safeguard (relative paths, core dumps..)
-cd /
-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/
-
-## 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 MariaDB 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 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 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)
- 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" "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 MariaDB database server by signal" "mysqld"
- killall -15 mysqld
- server_down=
- for i in `seq 1 600`; 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 MariaDB manually and read /usr/share/doc/mariadb-server-10.1/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" "mysqld"
- $MYADMIN reload
- log_end_msg 0
- ;;
-
- 'status')
- if mysqld_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" "mysqld"
- $SELF start "${@:2}" --wsrep-new-cluster
- ;;
-
- *)
- echo "Usage: $SELF start|stop|restart|reload|force-reload|status|bootstrap"
- exit 1
- ;;
-esac
diff --git a/debian/mariadb-server-10.1.postinst b/debian/mariadb-server-10.1.postinst
index 43eed58..353d6cc 100644
--- a/debian/mariadb-server-10.1.postinst
+++ b/debian/mariadb-server-10.1.postinst
@@ -1,181 +1,30 @@
#!/bin/bash -e
-. /usr/share/debconf/confmodule
+configure() {
+ # creating mysql group if he isn't already there
+ if ! getent group mysql >/dev/null; then
+ addgroup --system mysql >/dev/null
+ fi
+
+ # creating mysql user if he isn't already there
+ if ! getent passwd mysql >/dev/null; then
+ adduser \
+ --system \
+ --disabled-login \
+ --ingroup mysql \
+ --no-create-home \
+ --home /nonexistent \
+ --gecos "MySQL Server" \
+ --shell /bin/false \
+ mysql >/dev/null
+ fi
+}
-if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi
-${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
-
-export PATH=$PATH:/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"
-# 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
-
-MYSQL_BOOTSTRAP="/usr/sbin/mysqld --bootstrap --user=mysql --disable-log-bin --skip-grant-tables --default-storage-engine=myisam"
case "$1" in
- configure)
- mysql_statedir=/usr/share/mysql
- mysql_datadir=/var/lib/mysql
- mysql_logdir=/var/log/mysql
- mysql_rundir=/var/run/mysqld
- 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
-
- # 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_datadir" -a ! -L "$mysql_datadir" ]; then mkdir "$mysql_datadir" ; fi
- if [ ! -d "$mysql_logdir" -a ! -L "$mysql_logdir" ]; then mkdir "$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
-
- # 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-10.1.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/mysql 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 --skip-auth-anonymous-user --auth-root-authentication-method=socket --rpm --cross-bootstrap --user=mysql --disable-log-bin 2>&1 | $ERR_LOGGER
- set -e
-
-
- # Create the credentials file if not present. On all new installs the
- # root account can be used directly for maintenance authenticated by
- # unix socket and on new installs there is no need to define a
- # separate Debian maintenance user account.
- 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
- 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 = root" >>$dc
- echo "password = " >>$dc
- echo "socket = $mysql_rundir/mysqld.sock" >>$dc
- echo "[mysql_upgrade]" >>$dc
- echo "host = localhost" >>$dc
- echo "user = root" >>$dc
- echo "password = " >>$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=`/bin/echo -e \
- "USE mysql;\n" \
- "SET sql_log_bin=0;\n" \
- "ALTER TABLE user CHANGE Password Password char(41) character set latin1 collate latin1_bin DEFAULT '' NOT NULL;"`
-
- # Upgrade password column format.
- # NOTE: $MYSQL_BOOTSTRAP requires one SQL statement per line, semicolon at the end.
- echo "$password_column_fix_query" | $MYSQL_BOOTSTRAP 2>&1 | $ERR_LOGGER
-
- ;;
-
- abort-upgrade|abort-remove|abort-configure)
- ;;
-
- *)
- echo "postinst called with unknown argument '$1'" 1>&2
- exit 1
- ;;
+ configure) configure;;
esac
-db_stop # in case invoke failes
-
-# dh_systemd_start doesn't emit anything since we still ship /etc/init.d/mysql.
-# 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
-
#DEBHELPER#
-# Modified dh_systemd_start snippet that's not added automatically due /etc/init.d/mysql
-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/mysql" ]; then
- if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
- invoke-rc.d mysql start || exit $?
- fi
-fi
-
exit 0
diff --git a/debian/mariadb-server-10.1.postrm b/debian/mariadb-server-10.1.postrm
deleted file mode 100644
index 3c822d3..0000000
--- a/debian/mariadb-server-10.1.postrm
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/bin/bash -e
-
-. /usr/share/debconf/confmodule
-
-if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi
-${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
-
-#
-# - 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-10.1.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-10.1/postrm_remove_databases || true
- db_go || true
- db_get mariadb-server-10.1/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 /var/run/mysqld # this directory is created by the init script, don't leave behind
- userdel mysql || true
- fi
-
- #DEBHELPER#
-
-fi
-
-# Modified dh_systemd_start snippet that's not added automatically due /etc/init.d/mysql
-if [ -d /run/systemd/system ]; then
- systemctl --system daemon-reload >/dev/null || true
-fi
-
-exit 0
diff --git a/debian/mariadb-server-10.1.preinst b/debian/mariadb-server-10.1.preinst
deleted file mode 100644
index 3a76270..0000000
--- a/debian/mariadb-server-10.1.preinst
+++ /dev/null
@@ -1,184 +0,0 @@
-#!/bin/bash -e
-#
-# summary of how this script can be called:
-# * <new-preinst> install
-# * <new-preinst> install <old-version>
-# * <new-preinst> upgrade <old-version>
-# * <old-preinst> abort-upgrade <new-version>
-#
-
-. /usr/share/debconf/confmodule
-
-# Just kill the invalid insserv.conf.d directory without fallback
-if [ -d "/etc/insserv.conf.d/mariadb/" ]; then
- rm -rf "/etc/insserv.conf.d/mariadb/"
-fi
-
-if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi
-${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
-
-export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin
-MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
-mysql_datadir=/var/lib/mysql
-mysql_upgradedir=/var/lib/mysql-upgrade
-
-################################ main() ##########################
-
-this_version=10.1
-max_upgradeable_version=5.6
-
-# 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
-
-
-# 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
-
- 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
-
-
-# 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-10.1/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
-
-# 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
-
-#
-# 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
-
-# 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
-
-# end of NIS tolerance zone
-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
- mkdir -p "$mysql_upgradedir"
- cp -dT "$checkdir" "$mysql_upgradedir/$dir.link"
- fi
-done
-
-# creating mysql home directory
-if [ ! -d $mysql_datadir -a ! -L $mysql_datadir ]; then
- mkdir $mysql_datadir
-fi
-
-# 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
-
-# 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
-find $mysql_datadir ! -uid $(id -u mysql) -print0 | xargs -0 -r chown mysql
-find $mysql_datadir -follow -not -group mysql -print0 2>/dev/null \
- | xargs -0 --no-run-if-empty chgrp mysql
-set -e
-
-
-db_stop
-
-#DEBHELPER#
-
-exit 0
diff --git a/debian/mariadb-server-10.1.smf/manifest/application/database/mariadb.xml b/debian/mariadb-server-10.1.smf/manifest/application/database/mariadb.xml
new file mode 100644
index 0000000..1502be8
--- /dev/null
+++ b/debian/mariadb-server-10.1.smf/manifest/application/database/mariadb.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<!DOCTYPE service_bundle SYSTEM "/usr/share/xml/schema/smf/service_bundle.dtd.1">
+<service_bundle type="manifest" name="mariadb">
+ <service name="application/database/mariadb" type="service" version="1">
+ <dependency name="network" grouping="require_all" restart_on="none" type="service">
+ <service_fmri value="svc:/milestone/network:default"/>
+ </dependency>
+ <dependency name="filesystem-local" grouping="require_all" restart_on="none" type="service">
+ <service_fmri value="svc:/system/filesystem/local:default"/>
+ </dependency>
+ <exec_method type="method" name="start" exec="/lib/svc/method/mariadb start" timeout_seconds="3600"/>
+ <exec_method type="method" name="stop" exec=":kill" timeout_seconds="3600"/>
+ <property_group name="startd" type="framework">
+ <propval name="duration" type="astring" value="contract"/>
+ </property_group>
+ <instance name="default" enabled="false">
+ <dependency name="main-file" grouping="require_all" restart_on="none" type="path">
+ <service_fmri value="file://localhost/etc/mysql/my.cnf"/>
+ </dependency>
+ </instance>
+ <stability value="Unstable"/>
+ <template>
+ <common_name>
+ <loctext xml:lang="C">MariaDB database server</loctext>
+ </common_name>
+ <documentation>
+ <manpage title="mysqld" section="8"/>
+ <doc_link name="mariadb.org" uri="https://mariadb.org"/>
+ </documentation>
+ </template>
+ </service>
+</service_bundle>
diff --git a/debian/mariadb-server-10.1.smf/method/mariadb b/debian/mariadb-server-10.1.smf/method/mariadb
new file mode 100755
index 0000000..9fb044e
--- /dev/null
+++ b/debian/mariadb-server-10.1.smf/method/mariadb
@@ -0,0 +1,94 @@
+#!/bin/bash
+
+set -euo pipefail
+
+DEFAULTS_FILE=/etc/mysql/my.cnf
+
+mysqld_get_param() {
+ "${MYSQLD[@]}" --print-defaults \
+ | tr " " "\n" \
+ | grep -- "--$1" \
+ | tail -n 1 \
+ | cut -d= -f2 || echo "$2"
+}
+
+DATADIR=$(mysqld_get_param 'datadir' '/var/lib/mysql')
+SOCKET=$(mysqld_get_param 'socket' '/var/run/mysqld/mysqld.sock')
+PID_FILE=$(mysqld_get_param 'pid-file' '/var/run/mysqld/mysqld.pid')
+
+USER=$(mysqld_get_param 'user' 'mysql')
+GROUP=$(id -n -g "$USER")
+
+MYSQL=(/usr/bin/mysql --defaults-file="$DEFAULTS_FILE")
+
+MYSQLD=(/usr/sbin/mysqld --defaults-file="$DEFAULTS_FILE")
+MYSQLD+=(--datadir="$DATADIR")
+MYSQLD+=(--pid-file="$PID_FILE")
+MYSQLD+=(--socket="$SOCKET")
+MYSQLD+=(--user="$USER")
+
+prestart () {
+ if ! [ -f "$DATADIR/mysql/user.MYI" ]; then
+ rm -rf "$DATADIR/mysql"
+ /usr/bin/mysql_install_db \
+ --defaults-file="$DEFAULTS_FILE" \
+ --verbose \
+ --skip-auth-anonymous-user \
+
+ fi
+
+ chown -Rc "$USER:$GROUP" "$DATADIR"
+ chmod -Rc u=rwX,g=rX,o= "$DATADIR"
+
+ pid_dir=$(dirname "$PID_FILE")
+ socket_dir=$(dirname "$SOCKET")
+
+ mkdir -p "$pid_dir"
+ chown -Rc "$USER:$GROUP" "$pid_dir"
+ chmod -R u=rwX,g=rX,o=rX "$pid_dir"
+
+ # XXX It is possible that socket_dir == pid_dir
+ mkdir -p "$socket_dir"
+ chown -Rc "$USER:$GROUP" "$socket_dir"
+ chmod -R u=rwX,g=rX,o=rX "$socket_dir"
+}
+
+
+poststart () {
+ /usr/bin/mysql_upgrade --defaults-file="$DEFAULTS_FILE" \
+ --socket="$SOCKET"
+}
+
+alive () {
+ [ -f "$PID_FILE" ] && kill -0 "$(cat "$PID_FILE")"
+}
+
+start () {
+ prestart
+
+ "${MYSQLD[@]}" &
+
+ count=0
+ while ! "${MYSQL[@]}" -e ';' 2>/dev/null; do
+ sleep 1s
+ if ! (( count % 60 )); then
+ "${MYSQL[@]}" -e ';' || true
+ fi
+ (( ++count ))
+ if ! alive; then
+ exit 1
+ fi
+ done
+
+ poststart
+}
+
+
+export HOME=/etc/mysql
+cd / || exit 1
+umask 077
+
+case "$1" in
+ start) start;;
+ *) echo "Unknown command: $1" >&2; exit 1;;
+esac
diff --git a/debian/mariadb-server-10.1.templates b/debian/mariadb-server-10.1.templates
deleted file mode 100644
index 38f5889..0000000
--- a/debian/mariadb-server-10.1.templates
+++ /dev/null
@@ -1,45 +0,0 @@
-# These templates have been reviewed by the debian-l10n-english
-# team
-#
-# If modifications/additions/rewording are needed, please ask
-# for an advice to debian-l10n-english@lists.debian.org
-#
-# Even minor modifications require translation updates and such
-# changes should be coordinated with translators and reviewers.
-
-Template: mariadb-server-10.1/old_data_directory_saved
-Type: note
-_Description: The old data directory will be saved at new location
- A file named /var/lib/mysql/debian-*.flag exists on this system.
- The number indicates a database binary format version that cannot automatically
- be upgraded (or downgraded).
- .
- Therefore the previous data directory will be renamed to /var/lib/mysql-* and
- a new data directory will be initialized at /var/lib/mysql.
- .
- Please manually export/import your data (e.g. with mysqldump) if needed.
-
-Template: mariadb-server-10.1/nis_warning
-Type: note
-#flag:translate!:3,5
-_Description: Important note for NIS/YP users
- Using MariaDB under NIS/YP requires a mysql user account to be added on
- the local system with:
- .
- adduser --system --group --home /var/lib/mysql mysql
- .
- You should also check the permissions and ownership of the
- /var/lib/mysql directory:
- .
- /var/lib/mysql: drwxr-xr-x mysql mysql
-
-Template: mariadb-server-10.1/postrm_remove_databases
-Type: boolean
-Default: false
-_Description: Remove all MariaDB databases?
- The /var/lib/mysql directory which contains the MariaDB databases is about
- to be removed.
- .
- If you're removing the MariaDB package in order to later install a more
- recent version or if a different mariadb-server package is already
- using it, the data should be kept.
diff --git a/debian/rules b/debian/rules
index c91f9a0..078b234 100755
--- a/debian/rules
+++ b/debian/rules
@@ -76,8 +76,6 @@ override_dh_auto_clean:
[ ! -f debian/mysql-test-unstable-tests.orig ] || \
mv debian/mysql-test-unstable-tests.orig mysql-test/unstable-tests
- debconf-updatepo # Update po-files when clean runs before each build
-
override_dh_auto_configure:
@echo "RULES.$@"
dh_testdir