#!/bin/sh #---------------------------------------------------------------------------- # /usr/lib/systemd/scripts/mysql-common-mariadb-start-pre - MariaDB Server start pre # # Creation: 2023-10-03 hbfl # Last Update: $Id: mysql-common-tools-connections 106681 2023-10-03 17:22:25Z hbfl # # Copyright (c) 2014-@@YEAR@@ Holger Bruenjes, holgerbruenjes(at)gmx(dot)net # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- # --------------------------------------------------------------------------- # defaults # --------------------------------------------------------------------------- get_defaults() { # default values . /srv/mysql/defaults.info } # --------------------------------------------------------------------------- # check status of MariaDB/MySQL Database # --------------------------------------------------------------------------- check_status() { if [ -f ${mysql_pid_file} ] then exit 1 fi } # --------------------------------------------------------------------------- # check status of MariaDB/MySQL Database # --------------------------------------------------------------------------- sanity_checks() { ERR_LOGGER="logger -p daemon.err -t /usr/lib/systemd/system/${package_name}.service -i" . /etc/config.d/${package_name} # check for buggy options if /usr/bin/grep -q ^expire.logs.days /etc/mysql/my${my_path}.cnf && ! /usr/bin/grep -q ^log.bin /etc/mysql/my${my_path}.cnf then echo "ERROR: Using expire_logs_days without log_bin crashes the server." | $ERR_LOGGER exit 1 fi # check for diskspace shortage if LC_ALL=C BLOCKSIZE= /usr/bin/df --portability "${mysql_datadir:-/srv/mysql/${my_path}}" . | /usr/bin/tail -n 1 | /usr/bin/awk '{ exit ($4>4096) }' then echo "ERROR: The partition with "${mysql_datadir:-/srv/mysql/${my_path}}" is too full!" | $ERR_LOGGER exit 1 fi } # --------------------------------------------------------------------------- # main # --------------------------------------------------------------------------- main() { package_name="${1}" project_name=$(echo "${package_name}" | tr [:lower:] [:upper:]) my_path=$(echo "${package_name}" | sed 's|[^[:digit:]]||g') get_defaults check_status sanity_checks exit 0 } # --------------------------------------------------------------------------- # call function main # --------------------------------------------------------------------------- main "${@}" # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------