Blame SOURCES/mysql-check-socket.sh

80384c
#!/bin/sh
80384c
80384c
# We check if there is already a process using the socket file,
80384c
# since otherwise the systemd service file could report false
80384c
# positive result when starting and mysqld_safe could remove
80384c
# a socket file, which is actually being used by a different daemon.
80384c
80384c
source "`dirname ${BASH_SOURCE[0]}`/mysql-scripts-common"
80384c
80384c
if test -e "$socketfile" ; then
80384c
    echo "Socket file $socketfile exists." >&2
80384c
80384c
    # no write permissions
80384c
    if ! test -w "$socketfile" ; then
80384c
        echo "Not enough permission to write to the socket file $socketfile, which is suspicious." >&2
80384c
        echo "Please, remove $socketfile manually to start the service." >&2
80384c
        exit 1
80384c
    fi
80384c
80384c
    # not a socket file
80384c
    if ! test -S "$socketfile" ; then
80384c
        echo "The file $socketfile is not a socket file, which is suspicious." >&2
80384c
        echo "Please, remove $socketfile manually to start the service." >&2
80384c
        exit 1
80384c
    fi
80384c
80384c
    # some process uses the socket file
80384c
    if fuser "$socketfile" &>/dev/null ; then
80384c
        socketpid=$(fuser "$socketfile" 2>/dev/null)
80384c
        echo "Is another MySQL daemon already running with the same unix socket?" >&2
80384c
        echo "Please, stop the process $socketpid or remove $socketfile manually to start the service." >&2
80384c
        exit 1
80384c
    fi
80384c
80384c
    # socket file is a garbage
80384c
    echo "No process is using $socketfile, which means it is a garbage, so it will be removed automatically." >&2
80384c
fi
80384c
80384c
exit 0