setup-db-mariadb.sh 1.33 KB
Newer Older
David Trattnig's avatar
David Trattnig committed
1
#!/bin/bash
David Trattnig's avatar
David Trattnig committed
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

# Check if databases are already set-up
if test -f "$LOCKFILE_DB"; then
  echo "Aura Engine Databases are already existing! Skipping..."
else
  # Create random password
  PASS_ENGINE="$(openssl rand -base64 24)"

  # Create databases and users
  echo "--- SETTING UP DATABASE AND USERS ---"
  echo "Please enter the MySQL/MariaDB root password!"
  stty -echo
  printf "Password: "
  read rootpasswd
  stty echo
  printf "\n"
  echo "---"
  
  echo "Creating database for Aura Engine..."
  mysql -uroot -p${rootpasswd} -e "CREATE DATABASE aura_engine CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
  mysql -uroot -p${rootpasswd} -e "CREATE USER 'aura'@'localhost' IDENTIFIED BY '${PASS_ENGINE}';"
  mysql -uroot -p${rootpasswd} -e "GRANT ALL PRIVILEGES ON aura_engine.* TO 'aura'@'localhost';"
  mysql -uroot -p${rootpasswd} -e "FLUSH PRIVILEGES;"
  echo "Done."
  
  echo "Installing MySQL/MariaDB Libraries..."
  apt-get install mariadb-server libmariadbclient-dev
  echo "Done."
  
  echo
  echo
  echo "Please note your database credentials for the next configuration steps:"
  echo "-----------------------------------------------------------------------"
  echo " Database: 'aura_engine'"
  echo " User:     'aura'"
  echo " Password: '${PASS_ENGINE}'"
  echo "-----------------------------------------------------------------------"
  echo

fi