Debian Codegraph @

debian/additions/mysql-systemd-start

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 #
3 # Scripts to run by MySQL systemd service
4 #
5 # Needed argument: pre
6 #
7 # pre mode : try to perform sanity check for configuration, log, data
8
9 # Read a config option from mysql. Note that this will only work if a config
10 # file actually specifies the option, so it's important to specify a default
11 # $1 is application (e.g. mysqld for server)
12 # $2 is option
13 # $3 is default value used if no config value is found
14 get_mysql_optionscip-shell shell shell-project 0.0.0 get_mysql_option().() {
15 result=$(my_print_defaults "$1" | sedscip-shell system . . sed. -n "s/^--$2=//p" | tailscip-shell system . . tail. -n 1)
16 if [scip-shell system . . `[`. -z "$result" ];
17 then
18 result="$3"
19 fi
20 echoscip-shell system . . echo. "$result"
21 }
22 sanityscip-shell shell shell-project 0.0.0 sanity(). () {
23 if [scip-shell system . . `[`. -e /etc/mysql/FROZENscip-shell filesystem . . `/etc/mysql/FROZEN`. -o -h /etc/mysql/FROZENscip-shell filesystem . . `/etc/mysql/FROZEN`. ]; then
24 echoscip-shell system . . echo. "MySQL has been frozen to prevent damage to your system. Please see /etc/mysql/FROZEN for help."
25 exit 1
26 fi
27 if [scip-shell system . . `[`. ! -r /etc/mysql/my.cnfscip-shell filesystem . . `/etc/mysql/my.cnf`. ]; then
28 echoscip-shell system . . echo. "MySQL configuration not found at /etc/mysql/my.cnf. Please create one."
29 exit 1
30 fi
31 datadir=$(get_mysql_optionscip-shell shell shell-project 0.0.0 get_mysql_option(). mysqld datadir "/var/lib/mysqlscip-shell filesystem . . `/var/lib/mysql`.")
32 if [scip-shell system . . `[`. ! -d "${datadir}" ] && [scip-shell system . . `[`. ! -L "${datadir}" ]; then
33 echoscip-shell system . . echo. "MySQL data dir not found at ${datadir}. Please create one."
34 exit 1
35 fi
36
37 if [scip-shell system . . `[`. ! -d "${datadir}/mysql" ] && [scip-shell system . . `[`. ! -L "${datadir}/mysql" ]; then
38 echoscip-shell system . . echo. "MySQL system database not found in ${datadir}. Please run mysqld --initialize."
39 exit 1
40 fi
41
42 # Do a test start to make sure there are no configuration issues or similar
43 # mysqld --verbose --help will output a full listing of settings and plugins.
44 # To do so it needs to initialize the database, so it can be used as a test
45 # for whether or not the server can start. We redirect stdout to /dev/null so
46 # only the error messages are left.
47 result=0
48 output=$(mysqld --verbose --help --innodb-read-only 2>&1 > /dev/nullscip-shell filesystem . . `/dev/null`.) || result=$?
49 if [scip-shell system . . `[`. ! "$result" = "0" ]; then
50 echoscip-shell system . . echo. "ERROR: Unable to start MySQL server:" >&2
51 echoscip-shell system . . echo. "$output" >&2
52 echoscip-shell system . . echo. "Please take a look at https://wiki.debian.org/Teams/MySQL/FAQ for tips on fixing common upgrade issues." >&2
53 echoscip-shell system . . echo. "Once the problem is resolved, restart the service." >&2
54 exit 1
55 fi
56 }
57
58 case $1 in
59 "pre") sanityscip-shell shell shell-project 0.0.0 sanity(). ;;
60 esac