From ee5e33f3fe2051e695cb19c28e3eb6474183c9de Mon Sep 17 00:00:00 2001
From: Michael Hierweck <michael@hierweck.de>
Date: Tue, 12 Aug 2014 16:13:26 +0200
Subject: [PATCH] Introduced Phusion Passenger for Dynamic Web.

---
 hsarback/src/de/hsadmin/mods/dom/apache-vhost.vm             |   48 ++++++++++++++---------
 hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java |   20 +++-------
 2 files changed, 35 insertions(+), 33 deletions(-)

diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
index 304de25..1d9bddd 100644
--- a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
+++ b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
@@ -247,20 +247,12 @@
 		domDirsProcessor.appendProcessor(
 				new CreateFileProcessor("/de/hsadmin/mods/dom/index.html.vm", templateVars, dom, domainDir + "/subs-ssl/www/index.html", userName, pacName, "644", false)
 			);
-		if (dom.isDynamic()) {
-			domDirsProcessor.appendProcessor(
-					new CreateFileProcessor("/de/hsadmin/mods/dom/test.cgi.vm", templateVars, dom, domainDir + "/cgi/test.cgi", userName, pacName, "755", false)
-				);
-			domDirsProcessor.appendProcessor(
-					new CreateFileProcessor("/de/hsadmin/mods/dom/test.cgi.vm", templateVars, dom, domainDir + "/cgi-ssl/test.cgi", userName, pacName, "755", false)
-				);
-			domDirsProcessor.appendProcessor(
-					new CopyFileProcessor("/usr/local/src/phpstub/phpstub", domainDir + "/fastcgi/phpstub", userName, pacName, "755")
-				);
-			domDirsProcessor.appendProcessor(
-					new CopyFileProcessor("/usr/local/src/phpstub/phpstub", domainDir + "/fastcgi-ssl/phpstub", userName, pacName, "755")
+		domDirsProcessor.appendProcessor(
+				new CopyFileProcessor("/usr/local/src/phpstub/phpstub", domainDir + "/fastcgi/phpstub", userName, pacName, "755")
 			);
-		}
+		domDirsProcessor.appendProcessor(
+				new CopyFileProcessor("/usr/local/src/phpstub/phpstub", domainDir + "/fastcgi-ssl/phpstub", userName, pacName, "755")
+			);
 		domDirsProcessor.appendProcessor(
 				new ShellProcessor("ln -sf " + domainDir + " /home/doms/ && " +
 						"chown --no-dereference " + userName + ":httpd /home/doms/" + domName 
@@ -283,7 +275,7 @@
 		ifOption(templateVars, query, "multiviews", "+MultiViews", "-MultiViews");
 		ifOption(templateVars, query, "htdocsfallback", Boolean.TRUE, Boolean.FALSE);
 		Processor domSetupProcessor = new CompoundProcessor(
-			new CreateFileProcessor("/de/hsadmin/mods/dom/httpd-vhost.vm", templateVars, dom, "/etc/apache2/sites-available/" + domName + ".tmp", "root", "root", "644", true),
+			new CreateFileProcessor("/de/hsadmin/mods/dom/apache-vhost.vm", templateVars, dom, "/etc/apache2/sites-available/" + domName + ".tmp", "root", "root", "644", true),
 			new ShellProcessor("ls /etc/apache2/pems/" + pac + ".pem >/dev/null 2>&1" +
 					" && sed -i '/SSLCertificate.*default/d' " + "/etc/apache2/sites-available/" + domName + ".tmp" + 
 					" && (ls /etc/apache2/pems/" + pac + ".chain.pem >/dev/null 2>&1 || sed -i '/SSLCertificateChain.*" + pac + "/d' " + "/etc/apache2/sites-available/" + domName + ".tmp )" + 
diff --git a/hsarback/src/de/hsadmin/mods/dom/httpd-vhost.vm b/hsarback/src/de/hsadmin/mods/dom/apache-vhost.vm
similarity index 85%
rename from hsarback/src/de/hsadmin/mods/dom/httpd-vhost.vm
rename to hsarback/src/de/hsadmin/mods/dom/apache-vhost.vm
index 3d8c1a0..9a90cc8 100644
--- a/hsarback/src/de/hsadmin/mods/dom/httpd-vhost.vm
+++ b/hsarback/src/de/hsadmin/mods/dom/apache-vhost.vm
@@ -4,26 +4,30 @@
 #
 
 <VirtualHost ${pac.curINetAddr.inetAddr}:80 ${pac.oldINetAddr.inetAddr}:80>
-
     ServerName ${dom.name}
     ServerAlias *.${dom.name}
     ServerAdmin webmaster@${dom.name}
 
     SuexecUserGroup ${dom.user.name} ${pac.name}
 
+#if( ${dynamicWeb} )    
+    PassengerEnabled on
+    PassengerUser ${dom.user.name}
+    PassengerGroup ${pac.name}
+    PassengerAppRoot /home/doms/${dom.name}/app/
+#end    
+
     DocumentRoot /home/doms/${dom.name}/htdocs
 
-#if( ${dynamicWeb} )
     Alias /cgi-bin/ /home/doms/${dom.name}/cgi/
     Alias /fastcgi-bin/ /home/doms/${dom.name}/fastcgi/
-#end
 
     <Directory />
         Options -ExecCGI ${includes} ${indexes} ${multiviews} +SymLinksIfOwnerMatch
     </Directory>
 
     <Directory /home/doms/${dom.name}/>
-        AllowOverride AuthConfig FileInfo Indexes Limit
+        AllowOverride AuthConfig FileInfo Indexes Limit Options=Includes,Indexes,MultiViews,PassengerNodejs,PassengerPython,PassengerRuby,PassengerAppEnv
     </Directory>
 
 #if( ${dynamicWeb} )
@@ -31,16 +35,18 @@
         SetHandler cgi-script
         Options +ExecCGI ${includes} -Indexes -MultiViews +SymLinksIfOwnerMatch
     </Location>
+#else
+    <Location /cgi-bin/>
+        Redirect 501 /
+    </Location>
+#end
 
+#if( ${dynamicWeb} )
     <Location /fastcgi-bin/>
         SetHandler fcgid-script
         Options +ExecCGI ${includes} -Indexes -MultiViews +SymLinksIfOwnerMatch
     </Location>
 #else
-    <Location /cgi-bin/>
-        Redirect 501 /
-    </Location>
-
     <Location /fastcgi-bin/>
         Redirect 501 /
     </Location>
@@ -67,29 +73,32 @@
     AddType application/x-httpd-php .php .php5 .php4 .php3
     Action application/x-httpd-php /fastcgi-bin/phpstub
 #end
-
 </VirtualHost>
 
 <VirtualHost ${pac.curINetAddr.inetAddr}:443 ${pac.oldINetAddr.inetAddr}:443>
-
     ServerName ${dom.name}
     ServerAlias *.${dom.name}
     ServerAdmin ${dom.user.name}@${dom.name}
 
     SuexecUserGroup ${dom.user.name} ${pac.name}
+    
+#if( ${dynamicWeb} )    
+    PassengerEnabled on
+    PassengerUser ${dom.user.name}
+    PassengerGroup ${pac.name}
+    PassengerAppRoot /home/doms/${dom.name}/app-ssl/
+#end    
 
     SSLEngine On
     SSLCertificateFile /etc/apache2/pems/default.pem
     SSLCertificateChainFile /etc/apache2/pems/default.chain.pem
     SSLCertificateFile /etc/apache2/pems/${pac.name}.pem
     SSLCertificateChainFile /etc/apache2/pems/${pac.name}.chain.pem
-
+       
     DocumentRoot /home/doms/${dom.name}/htdocs-ssl
 
-#if( ${dynamicWeb} )
     Alias /cgi-bin/ /home/doms/${dom.name}/cgi-ssl/
     Alias /fastcgi-bin/ /home/doms/${dom.name}/fastcgi-ssl/
-#end
 
     <Directory />
         SSLRequireSSL On
@@ -97,7 +106,7 @@
     </Directory>
 
     <Directory /home/doms/${dom.name}/>
-        AllowOverride AuthConfig FileInfo Indexes Limit
+        AllowOverride AuthConfig FileInfo Indexes Limit Options=Includes,Indexes,MultiViews,PassengerNodejs,PassengerPython,PassengerRuby,PassengerAppEnv
     </Directory>
 
 #if( ${dynamicWeb} )
@@ -105,16 +114,18 @@
         SetHandler cgi-script
         Options +ExecCGI ${includes} -Indexes -MultiViews +SymLinksIfOwnerMatch
     </Location>
+#else
+    <Location /cgi-bin/>
+        Redirect 501 /
+    </Location>
+#end
 
+#if( ${dynamicWeb} )
     <Location /fastcgi-bin/>
         SetHandler fcgid-script
         Options +ExecCGI ${includes} -Indexes -MultiViews +SymLinksIfOwnerMatch
     </Location>
 #else
-    <Location /cgi-bin/>
-        Redirect 501 /
-    </Location>
-
     <Location /fastcgi-bin/>
         Redirect 501 /
     </Location>
@@ -141,5 +152,4 @@
     AddType application/x-httpd-php .php .php5 .php4 .php3
     Action application/x-httpd-php /fastcgi-bin/phpstub
 #end
-
 </VirtualHost>

--
Gitblit v1.9.0-SNAPSHOT