Commit 89236a8a authored by Otto Kekäläinen's avatar Otto Kekäläinen

Deb: skip invoke-rc.d mysql stop if no mysql process is running at all

Quite often in upgrades on systemd systems dpkg emitted an error like:

  Failed to stop mysql.service: Unit mysql.service not loaded.
  invoke-rc.d: initscript mysql, action "stop" failed.
  invoke-rc.d returned 5
  There is a MySQL server running, but we failed in our attempts to stop it.
  Stop it yourself and try again!
  dpkg: error processing archive /var/cache/apt/archives/mariadb-server-10.2

This is because the mariadb/mysql.service file is not loaded during
the upgrade/unpack stage of dpkg in certain situations. With this simple
check we can easily skip the shutdown step when it is really not needed,
which is for sure the case if no mysqld process at all is running on the
entire system.
parent e726ae6b
......@@ -23,6 +23,10 @@ mysql_upgradedir=/var/lib/mysql-upgrade
stop_server() {
if [ ! -x /etc/init.d/mysql ]; then return; fi
# Return immediately if there are no mysql processes running
# as there is no point in trying to shutdown in that case.
if ! pgrep mysqld > /dev/null; then return; fi
set +e
if [ -x /usr/sbin/invoke-rc.d ]; then
cmd="invoke-rc.d mysql stop"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment