Blame SOURCES/mysql-check-socket.sh

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