2014-02-25 14:56:53 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# We check if there is already a process using the socket file,
|
|
|
|
# since otherwise the systemd service file could report false
|
|
|
|
# positive result when starting and mysqld_safe could remove
|
|
|
|
# a socket file, which is actually being used by a different daemon.
|
|
|
|
|
2021-04-21 08:30:46 +00:00
|
|
|
source "`dirname ${BASH_SOURCE[0]}`/mariadb-scripts-common"
|
2014-02-25 14:56:53 +00:00
|
|
|
|
2014-05-05 10:36:12 +00:00
|
|
|
if test -e "$socketfile" ; then
|
2014-02-25 14:56:53 +00:00
|
|
|
echo "Socket file $socketfile exists." >&2
|
2014-05-05 10:36:12 +00:00
|
|
|
|
|
|
|
# no write permissions
|
|
|
|
if ! test -w "$socketfile" ; then
|
|
|
|
echo "Not enough permission to write to the socket file $socketfile, which is suspicious." >&2
|
|
|
|
echo "Please, remove $socketfile manually to start the service." >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# not a socket file
|
|
|
|
if ! test -S "$socketfile" ; then
|
|
|
|
echo "The file $socketfile is not a socket file, which is suspicious." >&2
|
|
|
|
echo "Please, remove $socketfile manually to start the service." >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# some process uses the socket file
|
2021-04-21 08:30:46 +00:00
|
|
|
response=`@bindir@/mariadb-admin --no-defaults --socket="$socketfile" --user=UNKNOWN_MYSQL_USER --connect-timeout="${CHECKSOCKETTIMEOUT:-10}" ping 2>&1`
|
2018-09-19 14:22:19 +00:00
|
|
|
if [ $? -eq 0 ] || echo "$response" | grep -q "Access denied for user" ; then
|
2021-04-21 08:30:46 +00:00
|
|
|
echo "Is another MariaDB daemon already running with the same unix socket?" >&2
|
2018-06-05 08:54:13 +00:00
|
|
|
echo "Please, stop the process using the socket $socketfile or remove the file manually to start the service." >&2
|
2014-05-05 10:36:12 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# socket file is a garbage
|
|
|
|
echo "No process is using $socketfile, which means it is a garbage, so it will be removed automatically." >&2
|
2014-02-25 14:56:53 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|