#!/bin/bash # Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA get_pcount () { PSCOUNT=$(ps -ef | grep "/usr/sbin/mysqld" | wc -l) echo "${PSCOUNT}" } server_stop () { PSCOUNT=$(get_pcount) COUNT=0 while :; do COUNT=$(( COUNT+1 )) echo -n . if [ "${PSCOUNT}" -eq 1 ]; then echo break fi if [ "${COUNT}" -gt 15 ]; then echo return 1 fi PSCOUNT=$(get_pcount) sleep 1 done return 0 } case "$1" in install) if [ -z "$2" ]; then set -e if [ -x "/etc/init.d/mysql" ]; then invoke-rc.d mysql stop || exit $? server_stop fi # Native 5.5 packages create a /var/run/mysqld owned by root. This can cause # errors in the systemd service, so we reset ownership if it exists. MYSQLRUN=/var/run/mysqld if [ -d ${MYSQLRUN} ]; then install -d -m0755 -omysql -gmysql ${MYSQLRUN} fi set +e fi ;; upgrade) set -e #DEBHELPER# server_stop set +e ;; abort-upgrade) ;; *) exit 1 ;; esac exit 0