forked from mo7amedsalah/DBEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_Database.sh
executable file
·52 lines (40 loc) · 1.31 KB
/
create_Database.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
LC_ALL=C
shopt -s extglob
clear
source "functions"
while true; do
echo "Enter Database Name:"
read database_name
#validate if name of database is true ..
case $database_name in
#validate that the name must have not white spaces..
*\ *)
echo "-----------------------------------------------------------------------"
echo "Invalid database name!! the name must be without no spaces..!! "
;;
#validate that the name must be letters only..
+([[:digit:]]))
echo "-----------------------------------------------------------------------"
echo "Invalid database name!! the name must be letters and do not have whitespaces!!!!!"
;;
#the valid regix for name..
+([a-zA-Z]))
#check if tha database created before ...
check_database_exist "$database_name"
if [ $? -eq 1 ]; then
echo "-----------------------------------------------------------------------"
echo "This database was created before!!!!!!!"
else
#create database..
mkdir $database_name
echo "-----------------------------------------------------------------------"
echo "Database created successfully!!!!!!!!!"
break
fi
;;
*) echo "Invalid database name!! must be alphabetic" ;;
esac
done
echo $(pwd)
source $(pwd)/DatabaseEngine.sh