|
|
7a7e4c |
#!/bin/sh
|
|
|
7a7e4c |
|
|
|
7a7e4c |
# We check if there is already a process using the socket file,
|
|
|
7a7e4c |
# since otherwise the systemd service file could report false
|
|
|
7a7e4c |
# positive result when starting and mysqld_safe could remove
|
|
|
7a7e4c |
# a socket file, which is actually being used by a different daemon.
|
|
|
7a7e4c |
|
|
|
7a7e4c |
source "`dirname ${BASH_SOURCE[0]}`/mysql-scripts-common"
|
|
|
7a7e4c |
|
|
|
7a7e4c |
if test -e "$socketfile" ; then
|
|
|
7a7e4c |
echo "Socket file $socketfile exists." >&2
|
|
|
7a7e4c |
|
|
|
7a7e4c |
# no write permissions
|
|
|
7a7e4c |
if ! test -w "$socketfile" ; then
|
|
|
7a7e4c |
echo "Not enough permission to write to the socket file $socketfile, which is suspicious." >&2
|
|
|
7a7e4c |
echo "Please, remove $socketfile manually to start the service." >&2
|
|
|
7a7e4c |
exit 1
|
|
|
7a7e4c |
fi
|
|
|
7a7e4c |
|
|
|
7a7e4c |
# not a socket file
|
|
|
7a7e4c |
if ! test -S "$socketfile" ; then
|
|
|
7a7e4c |
echo "The file $socketfile is not a socket file, which is suspicious." >&2
|
|
|
7a7e4c |
echo "Please, remove $socketfile manually to start the service." >&2
|
|
|
7a7e4c |
exit 1
|
|
|
7a7e4c |
fi
|
|
|
7a7e4c |
|
|
|
7a7e4c |
# some process uses the socket file
|
|
|
7a7e4c |
response=`@bindir@/mysqladmin --no-defaults --socket="$socketfile" --user=UNKNOWN_MYSQL_USER --connect-timeout="${CHECKSOCKETTIMEOUT:-10}" ping 2>&1`
|
|
|
7a7e4c |
if [ $? -eq 0 ] || echo "$response" | grep -q "Access denied for user" ; then
|
|
|
7a7e4c |
echo "Is another MySQL daemon already running with the same unix socket?" >&2
|
|
|
7a7e4c |
echo "Please, stop the process using the socket $socketfile or remove the file manually to start the service." >&2
|
|
|
7a7e4c |
exit 1
|
|
|
7a7e4c |
fi
|
|
|
7a7e4c |
|
|
|
7a7e4c |
# socket file is a garbage
|
|
|
7a7e4c |
echo "No process is using $socketfile, which means it is a garbage, so it will be removed automatically." >&2
|
|
|
7a7e4c |
fi
|
|
|
7a7e4c |
|
|
|
7a7e4c |
exit 0
|