~ubuntu-branches/ubuntu/trusty/mariadb-5.5/trusty-proposed

« back to all changes in this revision

Viewing changes to support-files/mysql.server.sh

  • Committer: Package Import Robot
  • Author(s): Otto Kekäläinen, Otto Kekäläinen, James Page
  • Date: 2014-03-02 01:38:26 UTC
  • mfrom: (2.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20140302013826-z3afnfteqo86pccd
Tags: 5.5.36-1
[ Otto Kekäläinen ]
* New upstream release.
* Updated Danish debconf translation (Closes: #739750).
* d/control: Added explicit Conflicts/Replaces for mysql-5.6 packages
  (Closes: #739841).
* d/control: Update for use of virtual-* packages for switching to/from
  MySQL alternatives.

[ James Page ]
* d/control: Drop Nicholas from Uploaders, MIA (Closes: #739360).
* d/control: Add libjemalloc-dev to BD's.

Show diffs side-by-side

added added

removed removed

Lines of Context:
147
147
                    datadir_set=1
148
148
        ;;
149
149
      --pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
 
150
      --socket=*) socket=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
150
151
      --service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
151
152
    esac
152
153
  done
153
154
}
154
155
 
155
 
wait_for_pid () {
156
 
  verb="$1"           # created | removed
157
 
  pid="$2"            # process ID of the program operating on the pid-file
158
 
  pid_file_path="$3" # path to the PID file.
159
 
 
160
 
  i=0
161
 
  avoid_race_condition="by checking again"
162
 
 
163
 
  while test $i -ne $service_startup_timeout ; do
164
 
 
165
 
    case "$verb" in
166
 
      'created')
167
 
        # wait for a PID-file to pop into existence.
168
 
        test -s "$pid_file_path" && i='' && break
169
 
        ;;
170
 
      'removed')
171
 
        # wait for this PID-file to disappear
172
 
        test ! -s "$pid_file_path" && i='' && break
173
 
        ;;
174
 
      *)
175
 
        echo "wait_for_pid () usage: wait_for_pid created|removed pid pid_file_path"
176
 
        exit 1
177
 
        ;;
178
 
    esac
179
 
 
180
 
    # if server isn't running, then pid-file will never be updated
181
 
    if test -n "$pid"; then
182
 
      if kill -0 "$pid" 2>/dev/null; then
183
 
        :  # the server still runs
184
 
      else
185
 
        # The server may have exited between the last pid-file check and now.  
186
 
        if test -n "$avoid_race_condition"; then
187
 
          avoid_race_condition=""
188
 
          continue  # Check again.
189
 
        fi
190
 
 
191
 
        # there's nothing that will affect the file.
192
 
        log_failure_msg "The server quit without updating PID file ($pid_file_path)."
193
 
        return 1  # not waiting any more.
194
 
      fi
195
 
    fi
196
 
 
197
 
    echo $echo_n ".$echo_c"
198
 
    i=`expr $i + 1`
199
 
    sleep 1
200
 
 
201
 
  done
202
 
 
203
 
  if test -z "$i" ; then
204
 
    log_success_msg
205
 
    return 0
206
 
  else
207
 
    log_failure_msg
208
 
    return 1
209
 
  fi
210
 
}
211
 
 
212
156
# Get arguments from the my.cnf file,
213
157
# the only group, which is read from now on is [mysqld]
214
158
if test -x ./bin/my_print_defaults
266
210
 
267
211
parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server`
268
212
 
 
213
# wait for the pid file to disappear
 
214
wait_for_gone () {
 
215
  pid="$1"           # process ID of the program operating on the pid-file
 
216
  pid_file_path="$2" # path to the PID file.
 
217
 
 
218
  i=0
 
219
  crash_protection="by checking again"
 
220
 
 
221
  while test $i -ne $service_startup_timeout ; do
 
222
 
 
223
    if kill -0 "$pid" 2>/dev/null; then
 
224
      :  # the server still runs
 
225
    else
 
226
      if test ! -s "$pid_file_path"; then
 
227
        # no server process and no pid-file? great, we're done!
 
228
        log_success_msg
 
229
        return 0
 
230
      fi
 
231
 
 
232
      # pid-file exists, the server process doesn't.
 
233
      # it must've crashed, and mysqld_safe will restart it
 
234
      if test -n "$crash_protection"; then
 
235
        crash_protection=""
 
236
        sleep 5
 
237
        continue  # Check again.
 
238
      fi
 
239
 
 
240
      # Cannot help it
 
241
      log_failure_msg "The server quit without updating PID file ($pid_file_path)."
 
242
      return 1  # not waiting any more.
 
243
    fi
 
244
 
 
245
    echo $echo_n ".$echo_c"
 
246
    i=`expr $i + 1`
 
247
    sleep 1
 
248
 
 
249
  done
 
250
 
 
251
  log_failure_msg
 
252
  return 1
 
253
}
 
254
 
 
255
wait_for_ready () {
 
256
 
 
257
  test -n "$socket" && sockopt="--socket=$socket"
 
258
 
 
259
  i=0
 
260
  while test $i -ne $service_startup_timeout ; do
 
261
 
 
262
    if $bindir/mysqladmin $sockopt ping >/dev/null 2>&1; then
 
263
      log_success_msg
 
264
      return 0
 
265
    fi
 
266
 
 
267
    echo $echo_n ".$echo_c"
 
268
    i=`expr $i + 1`
 
269
    sleep 1
 
270
 
 
271
  done
 
272
 
 
273
  log_failure_msg
 
274
  return 1
 
275
}
269
276
#
270
277
# Set pid file if not given
271
278
#
292
299
      # Give extra arguments to mysqld with the my.cnf file. This script
293
300
      # may be overwritten at next upgrade.
294
301
      $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &
295
 
      wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?
 
302
      wait_for_ready; return_value=$?
296
303
 
297
304
      # Make lock for RedHat / SuSE
298
305
      if test -w "$lockdir"
319
326
        echo $echo_n "Shutting down MySQL"
320
327
        kill $mysqld_pid
321
328
        # mysqld should remove the pid file when it exits, so wait for it.
322
 
        wait_for_pid removed "$mysqld_pid" "$mysqld_pid_file_path"; return_value=$?
 
329
        wait_for_gone $mysqld_pid "$mysqld_pid_file_path"; return_value=$?
323
330
      else
324
331
        log_failure_msg "MySQL server process #$mysqld_pid is not running!"
325
332
        rm "$mysqld_pid_file_path"