3 create_irreco_database_main
()
8 --create-db) create_irreco_database_create
"${ARGS[@]:1}";;
9 --set-perms) create_irreco_database_set_perms
"${ARGS[@]:1}";;
10 --help|
help|
-h) create_irreco_database_usage
;;
11 *) echo "Error: Unknown command \"$COMMAND\"";
12 create_irreco_database_usage
;
17 create_irreco_database_usage
()
20 echo "Usage: $SCRIPT_NAME COMMAND"
24 echo " Creates Irreco Database if it does not exists already."
26 echo " Create user which can to modify Irreco Database."
30 create_irreco_database_get_root
()
33 echo "Give user which has permissions to create new databases. "
34 echo "That is probably the MySQL root user."
35 echo -n "Username (root): "
38 if [[ "$MYSQL_USERNAME" == "" ]]; then
43 read -s MYSQL_PASSWORD
48 create_irreco_database_create
()
50 create_irreco_database_get_root
51 echo "Creating database ..."
52 mysql
--user="$MYSQL_USERNAME" --password="$MYSQL_PASSWORD" --batch \
54 if [[ "$?" == "0" ]]; then
59 create_irreco_database_set_perms
()
61 create_irreco_database_get_root
62 echo "Give password for irreco user."
66 echo "Creating irreco user ..."
67 create_irreco_database_set_perms_sql | \
68 mysql
--user="$MYSQL_USERNAME" --password="$MYSQL_PASSWORD" --batch
71 create_irreco_database_set_perms_sql
()
73 IRRECO_PERMS
='INSERT,DELETE,UPDATE,SELECT,LOCK TABLES'
75 echo 'grant '"$IRRECO_PERMS"' on `irreco`.* to irreco@localhost;'
76 echo 'grant '"$IRRECO_PERMS"' on `irreco`.* to irreco@127.0.0.1;'
77 echo "set password for irreco@localhost = password('$IRRECO_PASSWORD');"
78 echo "set password for irreco@127.0.0.1 = password('$IRRECO_PASSWORD');"
81 create_irreco_database_main
"$@"