From e3a56ac51862df2a47cbd07f2fc2d31c71edf775 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Tue, 15 Mar 2016 18:40:18 +0100 Subject: [PATCH] Added Apache autoconfiguration to install --- .../templates/control-common-sprint.template | 4 +-- .../templates/postinst-frontend.template | 25 +++++++++++++++++++ Site5/Pages/v5/Public/Initialize.aspx.cs | 14 ++++++++--- Site5/apache-default-config.txt | 21 ++++++++++++++++ 4 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 Site5/apache-default-config.txt diff --git a/BuildFiles/Packaging/templates/control-common-sprint.template b/BuildFiles/Packaging/templates/control-common-sprint.template index 58fc1968..a5489468 100644 --- a/BuildFiles/Packaging/templates/control-common-sprint.template +++ b/BuildFiles/Packaging/templates/control-common-sprint.template @@ -2,10 +2,10 @@ Package: swarmops-common Version: --BuildNumber-- Architecture: all Maintainer: Rick Falkvinge (swarmops-maintain@falkvinge.net) -Depends: libmono-system-componentmodel-composition4.0-cil (>= 3.2.8),libmono-system-web-services4.0-cil (>= 3.2.8),libmono-system-web-extensions4.0-cil (>= 3.2.8),libmono-system-componentmodel-composition4.0-cil (>= 3.2.8),fonts-liberation,libmono-system-numerics4.0-cil +Depends: dialog (>= 1.1), libmono-system-componentmodel-composition4.0-cil (>= 3.2.8),libmono-system-web-services4.0-cil (>= 3.2.8),libmono-system-web-extensions4.0-cil (>= 3.2.8),libmono-system-componentmodel-composition4.0-cil (>= 3.2.8),fonts-liberation,libmono-system-numerics4.0-cil Conflicts: swarmops-common-internal,swarmops-common-stable Homepage: http://swarmops.com/ Description: Swarmops Common Swarmops is a swarm activist administration system. This package contains the common components between - front-end and back-end. + frontend and backend. diff --git a/BuildFiles/Packaging/templates/postinst-frontend.template b/BuildFiles/Packaging/templates/postinst-frontend.template index f5967518..30db576b 100644 --- a/BuildFiles/Packaging/templates/postinst-frontend.template +++ b/BuildFiles/Packaging/templates/postinst-frontend.template @@ -7,6 +7,31 @@ if [ ! -e /var/lib/swarmops/upload ]; then mkdir -p /var/lib/swarmops/upload chown www-data:www-data /var/lib/swarmops/upload chmod 777 /var/lib/swarmops/upload + +#If there's only 000-default in apache sites, assume new install + if [ "$(ls -l /var/apache/sites-enabled/ | wc-l)" = "2" ]; then + + echo "Dialog branch was triggered (this is for debug purposes)" + + dialog --menu "This seems to be a new installation of Swarmops Frontend on a newly installed Apache. Would you like to create the necessary site directives and make it the default Apache site?" 12 70 3 1 "No thanks, don't touch my Apache, that's for me alone" 2 "Yes please, make Swarmops the default site for port 80" 3 "Create a Swarmops config, please, but don't enable it" + dialog_return_value = $? + + case $dialog_return_value in + 1) + echo "Neither reconfiguring Apache nor creating configuration file." + 2) + echo "Disabling site 000-default; creating/enabling site 000-swarmops." + a2dissite 000-default + cp /usr/share/swarmops/frontend/apache-default-config.txt /etc/apache2/sites-available + a2ensite 000-swarmops + /etc/init.d/apache2 force-reload + 3) + echo "Creating but not enabling 000-swarmops." + cp SOMETHING /etc/apache2/sites-available + esac + + fi + fi # make sure the web frontend (and its init routine) can write to machineKey.config diff --git a/Site5/Pages/v5/Public/Initialize.aspx.cs b/Site5/Pages/v5/Public/Initialize.aspx.cs index ada93263..29adeff3 100644 --- a/Site5/Pages/v5/Public/Initialize.aspx.cs +++ b/Site5/Pages/v5/Public/Initialize.aspx.cs @@ -73,11 +73,17 @@ namespace Swarmops.Frontend.Pages.v5.Public // If we're running on Localhost, disable the "is this your server?" question - string localAddress = HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"]; - if (localAddress == "127.0.0.1" || localAddress == "::1") + if (IsLocalhost()) { - this.TextServerName.Text = "(localhost)"; - this.TextServerAddress.Text = localAddress; + this.TextServerName.Text = @"(localhost)"; + if (HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"] == "::1") + { + this.TextServerAddress.Text = @"IPv6 Loopback"; + } + else + { + this.TextServerAddress.Text = @"IPv4 Loopback"; + } this.TextServerName.Enabled = false; this.TextServerAddress.Enabled = false; } diff --git a/Site5/apache-default-config.txt b/Site5/apache-default-config.txt new file mode 100644 index 00000000..4ff276a4 --- /dev/null +++ b/Site5/apache-default-config.txt @@ -0,0 +1,21 @@ +ServerName swarmops-frontend +ServerAdmin swarmops-frontend@swarmops.com +DocumentRoot /usr/share/swarmops/frontend/ + +# Explicitly specify Mono version 4 +MonoServerPath swarmops-frontend "/usr/bin/mod-mono-server4" + +# Uncomment the below to enable debugging: +# MonoDebug swarmops-frontend true + +MonoApplications swarmops-frontend "/:/usr/share/swarmops/frontend/" + + Allow from all + Order allow,deny + SetHandler mono + SetOutputFilter DEFLATE + SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip dont-vary + + + AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript +