#!/bin/bash

# accès à root depuis le container web pour phpMyAdmin (#1792)
activer_phpmyadmin=$(CreoleGet activer_phpmyadmin non)
mode_conteneur_actif=$(CreoleGet mode_conteneur_actif)

if [ "$activer_phpmyadmin" = 'oui' -a $mode_conteneur_actif = 'oui' ];then
	container_ip_web=$(CreoleGet container_ip_web)
	sql="CREATE USER IF NOT EXISTS root@$container_ip_web;"
	sql="${sql} GRANT ALL PRIVILEGES ON *.* TO root@$container_ip_web WITH GRANT OPTION; FLUSH PRIVILEGES;"
	CreoleRun "echo \"${sql}\" | mysql --defaults-file=/etc/mysql/debian.cnf" "mysql"
fi

exit 0
