#!/bin/sh #---------------------------------------------------------------------------- # /var/install/bin/mysql-common-tools-sqlconsole - SQL console for MariaDB/MySQL server # # Creation: 2004-06-22 jv # Last Update: $Id$ # # Copyright (c) 2004 Jens Vehlhaber, jvehlhaber(at)buchenwald(dot)de # Copyright (c) 2012-@@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. #---------------------------------------------------------------------------- #include eislib . /var/install/include/eislib # --------------------------------------------------------------------------- # defaults # --------------------------------------------------------------------------- get_defaults() { # default values . /srv/mysql/defaults.info } # --------------------------------------------------------------------------- # check status and access of MariaDB/MySQL Database # --------------------------------------------------------------------------- check_status() { if [ ! -f ${mysql_pid_file} ] then echo mecho --error 'MariaDB/MySQL Server is not running.' echo exit 1 fi ${mysql_basedir}/${db_mysqladmin} --socket=${mysql_socket} \ status >/dev/null 2>&1 if [ ${?} -ne 0 ] then echo mecho --error -n 'MariaDB/MySQL Server' mecho --std -n " 'root' " mecho --error 'password is required.' mecho --info 'Please set the root password.' echo exit 1 fi } # --------------------------------------------------------------------------- # start console # --------------------------------------------------------------------------- run_list() { color='' if $(grep -qE "^MENU=['\"]/var/install/bin/show-menu['\"]" /etc/config.d/setup) then color='--nocolor' fi /var/install/bin/list-files.cui -t "Select database for sql console"\ -c "Database:" ${color} \ -p ${mysql_datadir} \ -o 2 -d \ -s "${mysql_basedir}/${db_mysql} ${skip_ssl} --socket=${mysql_socket}" \ --helpfile=/var/install/help/${package_name} \ --helpname=${project_name}_MENU_${project_short}CONSOLE \ --helpview } # --------------------------------------------------------------------------- # main # --------------------------------------------------------------------------- main() { package_name="${1}" project_name=$(echo ${package_name} | tr [:lower:] [:upper:]) project_short=$(echo "${project_name}" | sed 's|[[:digit:]]||g') my_path=$(echo "${package_name}" | sed 's|[^[:digit:]]||g') # include config . /etc/config.d/${package_name} eval ssl_use='${'${project_name}'_SSL_USE:-no}' if [ ${my_path:-110} = 114 ] && [ "${ssl_use}" != "yes" ] then skip_ssl='--skip-ssl' fi get_defaults check_status run_list exit 0 } # --------------------------------------------------------------------------- # call function main # --------------------------------------------------------------------------- main "${@}" # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------