]> www.jernoble.com Git - postfix.git/blobdiff - dovecot/setup-dovecot.sh
Add a setup step to Dovecot which grants permission to the postfix database to the...
[postfix.git] / dovecot / setup-dovecot.sh
diff --git a/dovecot/setup-dovecot.sh b/dovecot/setup-dovecot.sh
new file mode 100755 (executable)
index 0000000..7171f19
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+if [[ -z "$( mysql -u root -e 'SELECT User FROM mysql.user WHERE User = "dovecot"' )" ]]; then
+    echo Creating \"dovecot\" user.
+    mysql -u root -e 'CREATE USER "dovecot"@"localhost" IDENTIFIED BY "dovecot"'
+    if [[ -n "$( mysql -u root -e 'SHOW DATABASES LIKE "postfix"' )" ]]; then
+        mysql -u root -e 'GRANT ALL PRIVILEGES ON dovecot.* TO "dovecot"@"localhost"'
+        mysql -u root -e 'FLUSH PRIVILEGES'
+    fi
+fi