Commits

Zhang Huangbin  committed 23a0400

iRedAdmin now works on OpenBSD.
Warning: To run iRedAdmin, we have to make Apache unchrooted. Will try to make iRedAdmin work with chroot later.

  • Participants
  • Parent commits 3fb56c3

Comments (0)

Files changed (7)

File iRedMail/functions/apache_php.sh

 
     if [ X"${DISTRO}" == X'OPENBSD' ]; then
         # Enable httpd.
-        echo 'httpd_flags="-DSSL"' >> ${RC_CONF_LOCAL}
+        # Note: iRedAdmin doesn't work with chroot.
+        echo 'httpd_flags="-DSSL -u"' >> ${RC_CONF_LOCAL}
 
         # Create /var/www/dev/*random.
         cd /var/www/dev/ && /dev/MAKEDEV random

File iRedMail/functions/iredadmin.sh

     chown -R ${IREDADMIN_HTTPD_USER}:${IREDADMIN_HTTPD_GROUP} settings.ini
     chmod 0400 settings.ini
 
-    if [ X"${DISTRO}" != X'OPENBSD' ]; then
-        ECHO_DEBUG "Create directory alias for iRedAdmin."
-        perl -pi -e 's#^(</VirtualHost>)#WSGIScriptAlias /iredadmin "$ENV{HTTPD_SERVERROOT}/iredadmin/iredadmin.py/"\n${1}#' ${HTTPD_SSL_CONF}
-        perl -pi -e 's#^(</VirtualHost>)#Alias /iredadmin/static "$ENV{HTTPD_SERVERROOT}/iredadmin/static/"\n${1}#' ${HTTPD_SSL_CONF}
+    if [ X"${DISTRO}" == X'OPENBSD' ]; then
+        # Change file owner
+        # iRedAdmin is not running as user 'iredadmin' on OpenBSD
+        chown -R ${HTTPD_USER}:${HTTPD_GROUP} settings.ini
     fi
 
     backup_file ${IREDADMIN_HTTPD_CONF}
-    cat > ${IREDADMIN_HTTPD_CONF} <<EOF
+    ECHO_DEBUG "Create directory alias for iRedAdmin."
+
+    if [ X"${DISTRO}" == X'OPENBSD' ]; then
+        # Create directory alias.
+        perl -pi -e 's#^(</VirtualHost>)#Alias /iredadmin/static "$ENV{IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}/static"\n${1}#' ${HTTPD_SSL_CONF}
+        perl -pi -e 's#^(</VirtualHost>)#ScriptAlias /iredadmin "$ENV{IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}/iredadmin.py"\n${1}#' ${HTTPD_SSL_CONF}
+
+        # There's no wsgi module for Apache available on OpenBSD, so
+        # iRedAdmin runs as CGI program.
+        cat > ${IREDADMIN_HTTPD_CONF} <<EOF
+AddType text/html .py
+AddHandler cgi-script .py
+
+<Directory "${IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}">
+    Options +ExecCGI +FollowSymLinks
+    Order allow,deny
+    Allow from all
+
+    <IfModule mod_rewrite.c>
+        RewriteEngine on
+        RewriteBase /
+        RewriteCond %{REQUEST_FILENAME} !-f
+        RewriteCond %{REQUEST_FILENAME} !-d
+        RewriteCond %{REQUEST_URI} !^/favicon.ico$
+        RewriteCond %{REQUEST_URI} !^(/.*)+iredadmin.py/
+        RewriteRule ^(.*)$ iredadmin.py/\$1 [PT]
+        RewriteRule ^/(static/.*)$ /static/\$1 [QSA,L,PT]
+    </IfModule>
+</Directory>
+EOF
+    else
+        perl -pi -e 's#^(</VirtualHost>)#Alias /iredadmin/static "$ENV{IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}/static/"\n${1}#' ${HTTPD_SSL_CONF}
+        perl -pi -e 's#^(</VirtualHost>)#WSGIScriptAlias /iredadmin "$ENV{IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}/iredadmin.py/"\n${1}#' ${HTTPD_SSL_CONF}
+
+        # iRedAdmin runs as WSGI application with Apache + mod_wsgi
+        cat > ${IREDADMIN_HTTPD_CONF} <<EOF
 WSGISocketPrefix /var/run/wsgi
 WSGIDaemonProcess iredadmin user=${IREDADMIN_HTTPD_USER} threads=15
 WSGIProcessGroup ${IREDADMIN_HTTPD_GROUP}
     Allow from all
 </Directory>
 EOF
-
-    if [ X"${DISTRO}" == X'OPENBSD' ]; then
-        mv ${IREDADMIN_HTTPD_CONF} ${IREDADMIN_HTTPD_CONF}.bak
     fi
 
     ECHO_DEBUG "Import iredadmin database template."

File iRedMail/functions/packages.sh

         # Don't use python-3
         gentoo_mask_package '<=dev-lang/python-3.0'
     elif [ X"${DISTRO}" == X'OPENBSD' ]; then
-        ALL_PKGS="${ALL_PKGS} py-jinja2 py-webpy py-mysql"
+        ALL_PKGS="${ALL_PKGS} py-jinja2 py-webpy py-mysql py-flup"
     fi
 
     #############

File iRedMail/pkgs/MD5.misc

-f2592ee6516442f7a8547c88cecec981  misc/iRedAdmin-0.1.7.tar.bz2
+f05b7d2e8fc8113d425a5c8f8361a12c  misc/iRedAdmin-0.1.7.tar.bz2
 529bd9131e796e368b68b9aec9c885d0  misc/roundcubemail-0.7.2.tar.gz
 78ca61eb5d7913963f8e42eb3b4f0e95  misc/phpldapadmin-1.2.2.tgz
 ab181a3fffc89e5d5c4ebd62ccfe396b  misc/phpMyAdmin-3.4.9-all-languages.tar.bz2

File iRedMail/pkgs/MD5.openbsd

-f2592ee6516442f7a8547c88cecec981  misc/iRedAdmin-0.1.7.tar.bz2
+f05b7d2e8fc8113d425a5c8f8361a12c  misc/iRedAdmin-0.1.7.tar.bz2
 92d01ee4a167ddc7f67f866640674b89  misc/iRedAPD-1.3.7.tar.bz2

File iRedMail/pkgs/MD5.ubuntu.lucid

-f2592ee6516442f7a8547c88cecec981  misc/iRedAdmin-0.1.7.tar.bz2
+f05b7d2e8fc8113d425a5c8f8361a12c  misc/iRedAdmin-0.1.7.tar.bz2
 529bd9131e796e368b68b9aec9c885d0  misc/roundcubemail-0.7.2.tar.gz
 92d01ee4a167ddc7f67f866640674b89  misc/iRedAPD-1.3.7.tar.bz2
 ea3030b376d389bbe447f88dfaf832f2  misc/phpPgAdmin-5.0.4.tar.bz2

File iRedMail/pkgs/SHASUM.freebsd.misc

-e88e066622f40dc95e6f63891fc25223e411c377  misc/iRedAdmin-0.1.7.tar.bz2
+695678c2580997ec33bb5b0b51aaaa7d115c78e5  misc/iRedAdmin-0.1.7.tar.bz2
 5fd486f001f62b2c89778bcb2c276219dfbe1751  misc/iRedAPD-1.3.7.tar.bz2