diff --git a/docker/db/99-permitions.sh b/docker/db/99-permitions.sh index 4db2714d918d6b5235e464a7ca933bad364b72a7..071bd9c0b58a5e79b7749117496f6d67b780bf8e 100644 --- a/docker/db/99-permitions.sh +++ b/docker/db/99-permitions.sh @@ -1,9 +1,26 @@ #!/bin/bash MRP=$MYSQL_ROOT_PASSWORD -echo "CREATE USER IF NOT EXISTS 'smartdata_admin' IDENTIFIED BY '$MYSQL_PASSWORD';" | mysql -u root --password=$MRP -echo "CREATE USER IF NOT EXISTS 'smartdata' IDENTIFIED BY '$MYSQL_PASSWORD';" | mysql -u root --password=$MRP -echo "CREATE USER IF NOT EXISTS 'tutorial' IDENTIFIED BY '$MYSQL_PASSWORD';" | mysql -u root --password=$MRP -echo "GRANT ALL PRIVILEGES ON *.* TO 'smartdata_admin';" | mysql -u root --password=$MRP -echo "GRANT ALL PRIVILEGES ON *.* TO 'smartdata';" | mysql -u root --password=$MRP -echo "GRANT ALL PRIVILEGES ON *.* TO 'tutorial';" | mysql -u root --password=$MRP +# Initialize variable +db_command_path="" + +# Check for mariadb command +if command -v mariadb &> /dev/null +then + db_command_path=$(command -v mariadb) +elif command -v mysql &> /dev/null +then + # Check for mysql command + db_command_path=$(command -v mysql) +else + echo "Neither mariadb nor mysql command found." + exit 1 +fi + +echo "CREATE USER IF NOT EXISTS 'smartdata_admin' IDENTIFIED BY '$MYSQL_PASSWORD';" | $db_command_path -u root --password=$MRP +echo "CREATE USER IF NOT EXISTS 'smartdata' IDENTIFIED BY '$MYSQL_PASSWORD';" | $db_command_path -u root --password=$MRP +echo "CREATE USER IF NOT EXISTS 'tutorial' IDENTIFIED BY '$MYSQL_PASSWORD';" | $db_command_path -u root --password=$MRP + +echo "GRANT ALL PRIVILEGES ON *.* TO 'smartdata_admin';" | $db_command_path -u root --password=$MRP +echo "GRANT ALL PRIVILEGES ON *.* TO 'smartdata';" | $db_command_path -u root --password=$MRP +echo "GRANT ALL PRIVILEGES ON *.* TO 'tutorial';" | $db_command_path -u root --password=$MRP