-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_db.sh
More file actions
executable file
·54 lines (42 loc) · 1001 Bytes
/
create_db.sh
File metadata and controls
executable file
·54 lines (42 loc) · 1001 Bytes
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
#!/usr/bin/bash
clear
echo
list_databases
echo
echo -e "${GREEN}Creating Database${NC}"
while [[ true ]]; do
echo -ne "${PROMPT}Enter The Name Of The Database : ${NC}"
if ! read db_name; then
return
fi
#rejecting spaces in db name
if [[ "$db_name" = *" "* ]]; then
echo
echo -e "${RED}Spaces Are Not Allowed!${NC}"
continue
fi
#disallowing special characters in db names
if [[ $db_name == *['!'@#\$%^\&*()-+\.\/]* ]]; then
echo
echo -e "${RED} ! @ # $ % ^ () + . - are not allowed!${NC}"
continue
fi
#check if empty string entered
if ! is_not_null $db_name; then
echo
echo -e "${RED}Name Cannot Be Null${NC}"
continue
fi
#check if input name exist otherwise create db
if find_database $db_name; then
echo
echo -e "${RED}Database already exists, Please Enter Another Name!${NC}"
continue
else
#create the database folder
mkdir "./Databases/$db_name"
echo
echo -e "${GREEN} $db_name Database Created Successfully${NC}"
return
fi
done