Server IP : 127.0.0.2 / Your IP : 18.119.172.175 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/mysql/ |
Upload File : |
#!/bin/bash # # Scripts to run by MySQL systemd service # # Needed argument: pre | post # # pre mode : try to perform sanity check for configuration, log, data # post mode : ping server until answer is received # Read a config option from mysql. Note that this will only work if a config # file actually specifies the option, so it's important to specify a default # $1 is application (e.g. mysqld for server) # $2 is option # $3 is default value used if no config value is found get_mysql_option() { result=$(my_print_defaults "$1" | sed -n "s/^--$2=//p" | tail -n 1) if [ -z "$result" ]; then result="$3" fi echo "$result" } sanity () { if [ ! -r /etc/mysql/my.cnf ]; then echo "MySQL configuration not found at /etc/mysql/my.cnf. Please create one." exit 1 fi datadir=$(get_mysql_option mysqld datadir "/var/lib/mysql") if [ ! -d "${datadir}" ] && [ ! -L "${datadir}" ]; then echo "MySQL data dir not found at ${datadir}. Please create one." exit 1 fi if [ ! -d "${datadir}/mysql" ] && [ ! -L "${datadir}/mysql" ]; then echo "MySQL system database not found in ${datadir}. Please run mysqld --initialize." exit 1 fi } pinger () { server_up=false for i in $(seq 1 30); do sleep 1 if mysqladmin ping >/dev/null 2>&1; then server_up=true break fi done if [ ! $server_up ]; then echo "MySQL server not started" exit 1 fi } case $1 in "pre") sanity ;; "post") pinger ;; esac