]> id.pley.net Git - postfix.git/blobdiff - postfixadmin/setup-postfixadmin.sh
Reorganize files around subprojects.
[postfix.git] / postfixadmin / setup-postfixadmin.sh
diff --git a/postfixadmin/setup-postfixadmin.sh b/postfixadmin/setup-postfixadmin.sh
new file mode 100755 (executable)
index 0000000..7fcb269
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+if [[ -z "$( mysql -u root -e 'SELECT User FROM mysql.user WHERE User = "postfix"' )" ]]; then
+    echo Creating \"postfix\" user.
+    mysql -u root -e 'CREATE USER "postfix"@"localhost" IDENTIFIED BY "postfix"'
+fi
+
+if [[ -z "$( mysql -u root -e 'SHOW DATABASES LIKE "postfix"' )" ]]; then
+    echo Creating \"postfix\" database.
+    mysql -u root -e 'CREATE DATABASE postfix'
+    mysql -u root -e 'GRANT ALL PRIVILEGES ON postfix.* TO "postfix"@"localhost"'
+    mysql -u root -e 'FLUSH PRIVILEGES'
+fi
+
+if [[ ! -d /usr/local/share/postfixadmin ]]; then
+    echo Installing postfixadmin
+    if [[ ! -d postfixadmin-code ]]; then
+        svn checkout svn://svn.code.sf.net/p/postfixadmin/code/tags/postfixadmin-2.3.8 postfixadmin-code
+    fi
+
+    sudo rsync -av --exclude '.svn' postfixadmin-code/ /usr/local/share/postfixadmin
+fi
+
+if [[ config.local.php -nt /usr/local/share/postfixadmin/config.local.php ]]; then
+    echo Configuring postfixadmin.
+    sudo cp config.local.php /usr/local/share/postfixadmin/config.local.php
+fi
+
+if [[ postfixadmin.conf -nt /etc/httpd/conf.d/postfixadmin.conf ]]; then
+    echo Configuring postfixadmin in Apache.
+    sudo cp postfixadmin.conf /etc/httpd/conf.d/postfixadmin.conf
+fi
+sudo yum install php-imap