#!/bin/sh #---------------------------------------------------------------------------- # /var/install/bin/mysql-common-tools-userlist - MariaDB/MySQL Server list user # # Creation: 2004-06-09 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 # check if use cui version #. /etc/config.d/setup # --------------------------------------------------------------------------- # 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 -n --error 'MariaDB/MySQL Server' mecho -n --std " 'root' " mecho --error 'password is required.' mecho --info 'Please set the root password.' echo exit 1 fi } # --------------------------------------------------------------------------- # list user # --------------------------------------------------------------------------- run_list() { # if [ "${MENU}" = "/var/install/bin/show-menu.cui" ] # then # ${base_dir}/list-mysql.cui --title="MariaDB/MySQL user:" \ # --server=unix:${socket} \ # --database=mysql \ # --user=root \ # --query="SELECT user, host, select_priv, insert_priv, grant_priv FROM user" \ # --helpfile=/var/install/help/mariadb \ # --helpname=MARIADB_MENU_USERLIST # exit 0 # fi clrhome mecho --info 'List all MariaDB/MySQL user' ${mysql_basedir}/${db_mysql} --socket=${mysql_socket} ${skip_ssl} \ -e "use mysql;SELECT user,host,select_priv,insert_priv,grant_priv FROM user;" anykey } # --------------------------------------------------------------------------- # main # --------------------------------------------------------------------------- main() { package_name="${1}" project_name=$(echo ${package_name} | tr [:lower:] [:upper:]) 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 # ---------------------------------------------------------------------------