This file is indexed.

preinst is in mysql-server-5.5 5.5.22-0ubuntu1.

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
192
193
194
195
196
197
#!/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

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"
DATADIR=/var/lib/mysql
LOGDIR=/var/log/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 mysqld in e.g. a different chroot is fine for us.
stop_server() {
    if [ ! -x /etc/init.d/mysql ]; then return; fi

    set +e
    if [ -x /usr/sbin/invoke-rc.d ]; then
      cmd="invoke-rc.d mysql stop"
    else
      cmd="/etc/init.d/mysql stop"
    fi
    $cmd
    errno=$?
    set -e
   
    # 0=ok, 100=no init script (fresh install)
    if [ "$errno" != 0 -a "$errno" != 100 ]; then
      echo "${cmd/ */} returned $errno" 1>&2
      echo "There is a 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=5.5

# Abort if an NDB cluster is in use.
if egrep -qi -r '^[^#]*ndb.connectstring|^[[:space:]]*\[[[:space:]]*ndb_mgmd' /etc/mysql/; then
  db_fset mysql-server/no_upgrade_when_using_ndb seen false || true
  db_input high mysql-server/no_upgrade_when_using_ndb || true
  db_go
  db_stop
  exit 1
fi

# Abort if skip-bdb option is enabled, required for 5.0 -> 5.1 upgrades.
#TODO

# Safe the user from stupidities.
show_downgrade_warning=0
for i in `ls $DATADIR/debian-*.flag 2>/dev/null`; do
  found_version=`echo $i | sed 's/.*debian-\([0-9\.]\+\).flag/\1/'`
  if dpkg --compare-versions "$this_version" '<<' "$found_version"; then
    show_downgrade_warning=1
    break;
  fi
done
if [ "$show_downgrade_warning" = 1 ]; then
  db_fset mysql-server-$this_version/really_downgrade seen false || true
  db_input medium mysql-server-$this_version/really_downgrade || true
  db_go
  db_get mysql-server-$this_version/really_downgrade || true
  if [ "$RET" = "true" ]; then
    rm -f $DATADIR/debian-*.flag
    touch $DATADIR/debian-$this_version.flag
  else
    echo "Aborting downgrade from (at least) $found_version to $this_version." 1>&2
    echo "If are sure you want to downgrade to $this_version, remove the file" 1>&2
    echo "$DATADIR/debian-*.flag and try installing again." 1>&2
    db_stop
    exit 1
  fi
fi

# to be sure
stop_server

# 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 "$UPGRADEDIR"
	cp -d "$checkdir" "$UPGRADEDIR/$dir.link"
    fi
done

# creating mysql home directory
if [ ! -d $DATADIR -a ! -L $DATADIR ]; then
 	mkdir $DATADIR
fi

# checking disc space
if LC_ALL=C BLOCKSIZE= df --portability $DATADIR/. | tail -n 1 | awk '{ exit ($4>1000) }'; then
  echo "ERROR: There's not enough space in $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
chown mysql:mysql $DATADIR
find $DATADIR -follow -not -group mysql -print0 2>/dev/null \
  | xargs -0 --no-run-if-empty chgrp mysql
set -e

# Some files below /etc/ were possibly in the mysql-server-5.0/etch package
# before. They get overwritten by current ones to avoid unnecessary dpkg questions.
while read md5 file; do
  if [ "`md5sum $file 2>/dev/null`" = "$md5  $file" ]; then
    cp /usr/share/mysql-common/internal-use-only/`echo $file | sed 's�/�_�g'` $file
  fi
done <<EOT
6691f2fdc5c6d27ff0260eb79813e1bc  /etc/init.d/mysql
b53b9552d44661361d39157c3c7c51d3  /etc/logrotate.d/mysql-server
57f3e58f72582ca55100dc1ba0f1a8ae  /etc/mysql/debian-start
EOT

db_stop

# Automatically added by dh_installinit
if [ "$1" = install ] || [ "$1" = upgrade ]; then
	if [ -e "/etc/init.d/mysql" ] && [ ! -L "/etc/init.d/mysql" ]; then
		if [ "`md5sum \"/etc/init.d/mysql\" | sed -e \"s/ .*//\"`" != \
		     "`dpkg-query -W -f='${Conffiles}' mysql-server-5.5 | sed -n -e \"\\\\' /etc/init.d/mysql '{s/ obsolete$//;s/.* //p}\"`" ]
		then
			echo "Obsolete conffile /etc/init.d/mysql has been modified by you, renaming to .dpkg-bak"
			mv -f "/etc/init.d/mysql" "/etc/init.d/mysql.dpkg-bak"
		else
			rm -f "/etc/init.d/mysql"
		fi
	fi
fi
# End automatically added section


exit 0