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