This file is indexed.

postinst is in mariadb-server-10.0 10.0.24-7.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/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 }

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

invoke() {
  if [ -x /usr/sbin/invoke-rc.d ]; then
    invoke-rc.d mysql $1
  else
    /etc/init.d/mysql $1
  fi
}

MYSQL_BOOTSTRAP="/usr/sbin/mysqld --bootstrap --user=mysql --disable-log-bin --skip-grant-tables --default-storage-engine=myisam"

# This is necessary because mysql_install_db removes the pid file in /var/run
# and because changed configuration options should take effect immediately.
# In case the server wasn't running at all it should be ok if the stop
# script fails. I can't tell at this point because of the cleaned /var/run.
set +e; invoke stop; set -e

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"

Ff 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
e 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
    chown -R mysql $mysql_datadir
    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.0.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 --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: Lines like this apparently really need to be formatted this way
    # for mysqld to process the correclty (;-delimiter, newlines etc)
    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
  ;;
esac

db_stop # in case invoke failes

# If we upgrade from MySQL mysql.service may be masked, which also
# means init.d script is disabled. Unmask mysql service explicitely.
# Ignore exit code as command is not available everywhere.
deb-systemd-helper unmask mysql.service > /dev/null || true

# Automatically added by dh_installinit
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
	if [ -x "/etc/init.d/mysql" ]; then
		update-rc.d mysql defaults 19 21 >/dev/null
	fi
	if [ -x "/etc/init.d/mysql" ] || [ -e "/etc/init/mysql.conf" ]; then
		invoke-rc.d mysql start || exit $?
	fi
fi
# End automatically added section


exit 0