Skip to content

Commit

Permalink
проверка существования базы данных перед созданием
Browse files Browse the repository at this point in the history
  • Loading branch information
progreccor committed Jun 3, 2020
1 parent efe5bd2 commit 3e2e2de
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions mc.menu
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ shell_patterns=0
RED='\033[0;31m'
LRED='\033[1;31m'
WHITE='\033[0m'
if [[ ! -z "`mysql -uroot -p${MYSQLPASS} -qfsBe "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='%b'" 2>&1`" ]]
then
echo -e "База с именем ${GREEN}%b${WHITE} ${RED}уже сушествует${WHITE}"
exit
fi
r=%d
r=${r#/var/www/}
r=${r%/www*}
Expand Down Expand Up @@ -197,6 +202,11 @@ shell_patterns=0
RED='\033[0;31m'
LRED='\033[1;31m'
WHITE='\033[0m'
if [[ ! -z "`mysql -uroot -p${MYSQLPASS} -qfsBe "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='%f'" 2>&1`" ]]
then
echo -e "База с именем ${GREEN}%b${WHITE} ${RED}уже сушествует${WHITE}"
exit
fi
r=%d
r=${r#/var/www/}
r=${r%/www*}
Expand Down Expand Up @@ -262,7 +272,7 @@ shell_patterns=0
r=%d
r=${r#/var/www/}
r=${r%/www*}
if [[ -z "`mysql -uroot -p${MYSQLPASS} -qfsBe "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='%f'" 2>&1`" ]]
if [[ -z "`mysql -uroot -p${MYSQLPASS} -qfsBe "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='%b'" 2>&1`" ]]
then
echo -e "Базы данных с именем ${GREEN}%b${WHITE} не существует. Создать?"
ask "" Y || $( echo "База не создана, импорт прерван."; exit )
Expand Down Expand Up @@ -568,7 +578,7 @@ k удалить базу данных


+ d /var/www/ & t d
9 нacтpoить пpaвa дocтyпa кaтaлoгa
9 нacтpoить пpaвa дocтyпa кaтaлoгa
GREEN='\033[0;32m'
RED='\033[0;31m'
LRED='\033[1;31m'
Expand Down

0 comments on commit 3e2e2de

Please sign in to comment.