Zhang Huangbin avatar Zhang Huangbin committed dc36968

Enable iRedAdmin for PostgreSQL backend.
List all unsupported releases.

Comments (0)

Files changed (5)

iRedMail/conf/global

         elif grep '\ 6' /etc/redhat-release &>/dev/null; then
             # version 6.x
             export DISTRO_VERSION='6'
+        else
+            export UNSUPPORTED_RELEASE='YES'
         fi
 
         # Get distribution name as DISTRO_CODENAME
         elif grep '^Scientific' /etc/redhat-release &>/dev/null; then
             # Scientific Linux
             export DISTRO_CODENAME='Scientific'
+        else
+            export UNSUPPORTED_RELEASE='YES'
         fi
 
         export PKG_ARCH=".${ARCH}"
         # Get major release version number
         export DISTRO_VERSION="$(cat /etc/debian_version | cut -b 1)"
 
+        # Set distro code name and unsupported releases:
+        # - 4: Etch
+        # - 5: Lenny
         if [ X"${DISTRO_VERSION}" == X'6' ]; then
             export DISTRO_CODENAME='squeeze'
-        fi
 
-        # Override settings.
-        if [ X"${DISTRO_CODENAME}" == X"squeeze" ]; then
+            # Override settings.
             export SHELL_NOLOGIN='/usr/sbin/nologin'
-        fi
-
-        # Unsupported releases
-        # - 4: Etch
-        # - 5: Lenny
-        if [ X"${DISTRO_VERSION}" == X'4' \
-            -o X"${DISTRO_VERSION}" == X'5' \
-            ]; then
+        else
             export UNSUPPORTED_RELEASE='YES'
         fi
 
         export DISTRO='GENTOO'
 
     else
-        # Not support yet.
-        echo "Your distrobution is not supported yet."
-        exit 255
+        export UNSUPPORTED_RELEASE='YES'
     fi
 elif [ X"${KERNEL_NAME}" == X"FreeBSD" ]; then
     export DISTRO='FREEBSD'
 if [ X"${UNSUPPORTED_RELEASE}" == X'YES' ]; then
     cat <EOF
 ********* ERROR *********
-Release version of the operating system on this server is unsupported by iRedMail,
-please access below link to get the latest iRedMail and a list of supported
-Linux/BSD distributions and release versions.
+Release version of the operating system on this server is unsupported by
+iRedMail, please access below link to get the latest iRedMail and a list
+of supported Linux/BSD distributions and release versions.
 
 http://www.iredmail.org/download.html
 

iRedMail/conf/iredadmin

 export IREDADMIN_TARBALL="iRedAdmin-${IREDADMIN_VERSION}.tar.bz2"
 export IREDADMIN_URL="http://iredmail.googlecode.com/files/${IREDADMIN_TARBALL}"
 export IREDADMIN_HTTPD_ROOT="${HTTPD_SERVERROOT}/iRedAdmin-${IREDADMIN_VERSION}"
+export IREDADMIN_HTTPD_ROOT_SYMBOL_LINK="${HTTPD_SERVERROOT}/iredadmin"
 
 # Run iRedAdmin with Apache + mod_wsgi, but as a low privilege user/group.
 export IREDADMIN_HOME_DIR='/home/iredadmin'

iRedMail/dialog/config_via_dialog.sh

 +------------+               +---------------------------+
 | MySQL      | Roundcube     | iRedAdmin, phpMyAdmin     |
 +------------+               +---------------------------+
-| PostgreSQL |               | phpPgAdmin                |
+| PostgreSQL |               | iRedAdmin, phpPgAdmin     |
 +------------+---------------+---------------------------+
 TIP: Use SPACE key to select item.
 " 20 76 3 \

iRedMail/dialog/optional_components.sh

 " 20 76 8 \
     "DKIM signing/verification" "DomainKeys Identified Mail" "on" \
     "Roundcubemail" "WebMail program (PHP, AJAX)" "on" \
+    "iRedAdmin" "Official web-based Admin Panel" "on" \
     "phpPgAdmin" "Web-based MySQL management tool" "on" \
     "Awstats" "Advanced web and mail log analyzer" "on" \
     "Fail2ban" "Ban IP with too many password failures" "on" \

iRedMail/functions/iredadmin.sh

 
     # Backup database.
     export MYSQL_BACKUP_DATABASES="${MYSQL_BACKUP_DATABASES} ${IREDADMIN_DB_NAME}"
+    export PGSQL_BACKUP_DATABASES="${PGSQL_BACKUP_DATABASES} ${IREDADMIN_DB_NAME}"
 
     # Create a low privilege user as httpd daemon user.
     if [ X"${KERNEL_NAME}" == X"FreeBSD" ]; then
 
     # Create symbol link, so that we don't need to modify apache
     # conf.d/iredadmin.conf file after upgrading this component.
-    ln -s ${IREDADMIN_HTTPD_ROOT} ${HTTPD_SERVERROOT}/iredadmin 2>/dev/null
+    ln -s ${IREDADMIN_HTTPD_ROOT} ${IREDADMIN_HTTPD_ROOT_SYMBOL_LINK} 2>/dev/null
 
     ECHO_DEBUG "Set correct permission for iRedAdmin: ${IREDADMIN_HTTPD_ROOT}."
     chown -R ${IREDADMIN_HTTPD_USER}:${IREDADMIN_HTTPD_GROUP} ${IREDADMIN_HTTPD_ROOT}
     # Copy sample configure file.
     cd ${IREDADMIN_HTTPD_ROOT}/
 
-    if [ X"${BACKEND}" == X"OPENLDAP" ]; then
+    if [ X"${BACKEND}" == X'OPENLDAP' ]; then
         cp settings.ini.ldap.sample settings.ini
-    elif [ X"${BACKEND}" == X"MYSQL" ]; then
+    elif [ X"${BACKEND}" == X'MYSQL' ]; then
+        cp settings.ini.mysql.sample settings.ini
+    elif [ X"${BACKEND}" == X'PGSQL' ]; then
         cp settings.ini.mysql.sample settings.ini
     fi
 
 
 AddType text/html .py
 
-<Directory ${HTTPD_SERVERROOT}/iredadmin/>
+<Directory ${IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}/>
     Order allow,deny
     Allow from all
 </Directory>
 EOF
 
     ECHO_DEBUG "Import iredadmin database template."
-    mysql -h${MYSQL_SERVER} -P${MYSQL_SERVER_PORT} -u${MYSQL_ROOT_USER} -p"${MYSQL_ROOT_PASSWD}" <<EOF
+    if [ X"${BACKEND}" == X'OPENLDAP' -o X"${BACKEND}" == X'MYSQL' ]; then
+        mysql -h${SQL_SERVER} -P${SQL_SERVER_PORT} -u${MYSQL_ROOT_USER} -p"${MYSQL_ROOT_PASSWD}" <<EOF
 # Create databases.
 CREATE DATABASE ${IREDADMIN_DB_NAME} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
 
 USE ${IREDADMIN_DB_NAME};
 SOURCE ${IREDADMIN_HTTPD_ROOT}/docs/samples/iredadmin.sql;
 GRANT SELECT,INSERT,UPDATE,DELETE ON ${IREDADMIN_DB_NAME}.* TO "${IREDADMIN_DB_USER}"@localhost IDENTIFIED BY "${IREDADMIN_DB_PASSWD}";
-
 FLUSH PRIVILEGES;
 EOF
 
-    # Import addition tables.
-    if [ X"${BACKEND}" == X"OPENLDAP" ]; then
-        mysql -h${MYSQL_SERVER} -P${MYSQL_SERVER_PORT} -u${MYSQL_ROOT_USER} -p"${MYSQL_ROOT_PASSWD}" <<EOF
+        # Import addition tables.
+        if [ X"${BACKEND}" == X"OPENLDAP" ]; then
+            mysql -h${SQL_SERVER} -P${SQL_SERVER_PORT} -u${MYSQL_ROOT_USER} -p"${MYSQL_ROOT_PASSWD}" <<EOF
 USE ${IREDADMIN_DB_NAME};
 SOURCE ${SAMPLE_DIR}/dovecot/used_quota.sql;
 SOURCE ${SAMPLE_DIR}/dovecot/imap_share_folder.sql;
 FLUSH PRIVILEGES;
 EOF
+        fi
+
+    elif [ X"${BACKEND}" == X'PGSQL' ]; then
+        cp -f ${IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}/docs/samples/iredadmin.pgsql ${PGSQL_DATA_DIR}/ >/dev/null
+        chmod 0777 ${PGSQL_DATA_DIR}/iredadmin.pgsql >/dev/null
+        su - ${PGSQL_SYS_USER} -c "psql -d template1" >/dev/null <<EOF
+-- Create database
+CREATE DATABASE ${IREDADMIN_DB_NAME} WITH TEMPLATE template0 ENCODING 'UTF8';
+-- Create user
+CREATE USER ${IREDADMIN_DB_USER} WITH ENCRYPTED PASSWORD '${IREDADMIN_DB_PASSWD}' NOSUPERUSER NOCREATEDB NOCREATEROLE;
+\c ${IREDADMIN_DB_NAME};
+\i ${PGSQL_DATA_DIR}/iredadmin.pgsql;
+-- Grant permissions
+GRANT INSERT,UPDATE,DELETE,SELECT on sessions,log,updatelog to ${IREDADMIN_DB_USER};
+GRANT UPDATE,USAGE,SELECT ON log_id_seq TO ${IREDADMIN_DB_USER};
+EOF
+        rm -f ${PGSQL_DATA_DIR}/iredadmin.pgsql
     fi
 
     ECHO_DEBUG "Configure iRedAdmin."
     # [iredadmin] section.
     ECHO_DEBUG "Configure iredadmin database related settings."
     sed -i.tmp \
-        -e "/\[iredadmin\]/,/\[/ s#\(^host =\).*#\1 ${MYSQL_SERVER}#" \
-        -e "/\[iredadmin\]/,/\[/ s#\(^port =\).*#\1 ${MYSQL_SERVER_PORT}#" \
+        -e "/\[iredadmin\]/,/\[/ s#\(^host =\).*#\1 ${SQL_SERVER}#" \
+        -e "/\[iredadmin\]/,/\[/ s#\(^port =\).*#\1 ${SQL_SERVER_PORT}#" \
         -e "/\[iredadmin\]/,/\[/ s#\(^db =\).*#\1 ${IREDADMIN_DB_NAME}#" \
         -e "/\[iredadmin\]/,/\[/ s#\(^user =\).*#\1 ${IREDADMIN_DB_USER}#" \
         -e "/\[iredadmin\]/,/\[/ s#\(^passwd =\).*#\1 ${IREDADMIN_DB_PASSWD}#" \
             -e "/\[ldap\]/,/\[/ s#\(^bind_pw =\).*#\1 ${LDAP_ADMIN_PW}#" \
             settings.ini
 
-    elif [ X"${BACKEND}" == X"MYSQL" ]; then
-        # Change backend.
-        sed -i.tmp -e "/\[general\]/,/\[/ s#\(^backend =\).*#\1 mysql#" settings.ini
-
-        ECHO_DEBUG "Configure MySQL backend related settings."
+    elif [ X"${BACKEND}" == X"MYSQL" -o X"${BACKEND}" == X'PGSQL' ]; then
+        ECHO_DEBUG "Configure MySQL related settings."
         sed -i.tmp \
-            -e "/\[vmaildb\]/,/\[/ s#\(^host =\).*#\1 ${MYSQL_SERVER}#" \
-            -e "/\[vmaildb\]/,/\[/ s#\(^port =\).*#\1 ${MYSQL_SERVER_PORT}#" \
+            -e "/\[vmaildb\]/,/\[/ s#\(^host =\).*#\1 ${SQL_SERVER}#" \
+            -e "/\[vmaildb\]/,/\[/ s#\(^port =\).*#\1 ${SQL_SERVER_PORT}#" \
             -e "/\[vmaildb\]/,/\[/ s#\(^db =\).*#\1 ${VMAIL_DB}#" \
             -e "/\[vmaildb\]/,/\[/ s#\(^user =\).*#\1 ${VMAIL_DB_ADMIN_USER}#" \
             -e "/\[vmaildb\]/,/\[/ s#\(^passwd =\).*#\1 ${VMAIL_DB_ADMIN_PASSWD}#" \
     ECHO_DEBUG "Configure Policyd related settings."
     sed -i.tmp \
         -e "/\[policyd\]/,/\[/ s#\(^enabled =\).*#\1 True#" \
-        -e "/\[policyd\]/,/\[/ s#\(^host =\).*#\1 ${MYSQL_SERVER}#" \
-        -e "/\[policyd\]/,/\[/ s#\(^port =\).*#\1 ${MYSQL_SERVER_PORT}#" \
+        -e "/\[policyd\]/,/\[/ s#\(^host =\).*#\1 ${SQL_SERVER}#" \
+        -e "/\[policyd\]/,/\[/ s#\(^port =\).*#\1 ${SQL_SERVER_PORT}#" \
         -e "/\[policyd\]/,/\[/ s#\(^db =\).*#\1 ${POLICYD_DB_NAME}#" \
         -e "/\[policyd\]/,/\[/ s#\(^user =\).*#\1 ${POLICYD_DB_USER}#" \
         -e "/\[policyd\]/,/\[/ s#\(^passwd =\).*#\1 ${POLICYD_DB_PASSWD}#" \
         settings.ini
 
 
-    # Ubuntu 11.10 uses Policyd-2 which is not yet supported in iRedAdmin.
-    if [ X"${DISTRO_CODENAME}" == X"oneiric" \
-        -o X"${DISTRO_CODENAME}" == X"precise" \
-        ]; then
+    # Policyd-2 (cluebringer) is not yet supported in iRedAdmin.
+    if [ X"${USE_CLUEBRINGER}" == X'YES' ]; then
         sed -i.tmp -e "/\[policyd\]/,/\[/ s#\(^enabled =\).*#\1 False#" settings.ini
     fi
 
         -e "/\[amavisd\]/,/\[/ s#\(^server =\).*#\1 ${AMAVISD_SERVER}#" \
         -e "/\[amavisd\]/,/\[/ s#\(^quarantine_port =\).*#\1 ${AMAVISD_QUARANTINE_PORT}#" \
         -e "/\[amavisd\]/,/\[/ s#\(^logging_into_sql =\).*#\1 True#" \
-        -e "/\[amavisd\]/,/\[/ s#\(^host =\).*#\1 ${MYSQL_SERVER}#" \
-        -e "/\[amavisd\]/,/\[/ s#\(^port =\).*#\1 ${MYSQL_SERVER_PORT}#" \
+        -e "/\[amavisd\]/,/\[/ s#\(^host =\).*#\1 ${SQL_SERVER}#" \
+        -e "/\[amavisd\]/,/\[/ s#\(^port =\).*#\1 ${SQL_SERVER_PORT}#" \
         -e "/\[amavisd\]/,/\[/ s#\(^db =\).*#\1 ${AMAVISD_DB_NAME}#" \
         -e "/\[amavisd\]/,/\[/ s#\(^user =\).*#\1 ${AMAVISD_DB_USER}#" \
         -e "/\[amavisd\]/,/\[/ s#\(^passwd =\).*#\1 ${AMAVISD_DB_PASSWD}#" \
 
         [policyd]
         enabled = True
-        host = ${MYSQL_SERVER}
-        port = ${MYSQL_SERVER_PORT}
+        host = ${SQL_SERVER}
+        port = ${SQL_SERVER_PORT}
         db = ${POLICYD_DB_NAME}
         user = ${POLICYD_DB_USER}
         passwd = ${POLICYD_DB_PASSWD}
         server = ${AMAVISD_SERVER}
         quarantine_port = ${AMAVISD_QUARANTINE_PORT}
         logging_into_sql = True
-        host = ${MYSQL_SERVER}
-        port = ${MYSQL_SERVER_PORT}
+        host = ${SQL_SERVER}
+        port = ${SQL_SERVER_PORT}
         db = ${AMAVISD_DB_NAME}
         user = ${AMAVISD_DB_USER}
         passwd = ${AMAVISD_DB_PASSWD}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.