More debugging
This commit is contained in:
@@ -13,14 +13,11 @@ if [ ! -e /var/lib/swarmops/upload ]; then
|
||||
if [ "$(ls -l /etc/apache2/sites-enabled/ | wc -l)" = "2" ]; then
|
||||
|
||||
exec 3>&1;
|
||||
dialog_selection=$(dialog --title "Swarmops: Autoconfigure Apache?" --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 Swarmops the default Apache site?" 0 0 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" 2>&1 1>&3);
|
||||
dialog_selection=$(dialog --title "Swarmops: Autoconfigure Apache?" --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 Swarmops the default Apache site?" 0 0 3 1 "Yes please, make Swarmops the default site for port 80" 2 "Create a Swarmops config, please, but don't enable it" 3 "No thanks, don't touch my Apache, that's for me alone" 2>&1 1>&3);
|
||||
exec 3>&-;
|
||||
|
||||
case "$dialog_selection" in
|
||||
1 ) echo "Neither reconfiguring Apache nor creating configuration file."
|
||||
;;
|
||||
|
||||
2 ) echo "Disabling site 000-default; creating/enabling site 000-swarmops."
|
||||
1 ) 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/000-swarmops.conf
|
||||
a2ensite 000-swarmops
|
||||
@@ -37,10 +34,13 @@ if [ ! -e /var/lib/swarmops/upload ]; then
|
||||
fi
|
||||
;;
|
||||
|
||||
3 ) echo "Creating but not enabling the site 'swarmops'. Use a2ensite to enable."
|
||||
2 ) echo "Creating but not enabling the site 'swarmops'. Use a2ensite to enable."
|
||||
cp /usr/share/swarmops/frontend/apache-default-config.txt /etc/apache2/sites-available/swarmops.conf
|
||||
;;
|
||||
|
||||
3 ) echo "Neither reconfiguring Apache nor creating configuration file."
|
||||
;;
|
||||
|
||||
* ) echo "Unknown return code - $dialog_selection"
|
||||
;;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Swarmops.Logic.Support
|
||||
{
|
||||
// Linux - the reason we made this function to begin with
|
||||
|
||||
File.AppendAllText ("/tmp/swarmops-debug.log", DateTime.UtcNow.ToString("yyyy-MM-dd/HH:mm:ss.fff | ") + logEntry + @"\r\n");
|
||||
File.AppendAllLines("/tmp/swarmops-debug.log", new string[] { DateTime.UtcNow.ToString("yyyy-MM-dd/HH:mm:ss.fff | ") + logEntry });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,5 +247,11 @@ namespace Swarmops.Logic.Support
|
||||
return "/etc/swarmops"; // live etc folder
|
||||
}
|
||||
}
|
||||
|
||||
public static bool RequireSsl
|
||||
{
|
||||
get { return Boolean.Parse(GetDefaultedPersistedKey("SslRequired", "false")); } // start out as false, to enable configuration
|
||||
set { Persistence.Key["SslRequired"] = value.ToString(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,10 @@ namespace Swarmops
|
||||
!Request.Url.ToString().StartsWith("http://dev-opentest.swarmops.com") &&
|
||||
!Request.Url.ToString().StartsWith("http://localhost:"))
|
||||
{
|
||||
Response.Redirect (Request.Url.ToString().Replace ("http:", "https:"));
|
||||
if (SystemSettings.RequireSsl)
|
||||
{
|
||||
Response.Redirect (Request.Url.ToString().Replace ("http:", "https:"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -409,6 +409,8 @@ namespace Swarmops.Frontend.Pages.v5.Public
|
||||
/// </summary>
|
||||
public static void InitDatabaseThread()
|
||||
{
|
||||
SwarmopsLog.DebugLog("Initializing Database");
|
||||
|
||||
// Ignore the session object, that method of sharing data didn't work, but a static variable did.
|
||||
|
||||
_initProgress = 1;
|
||||
@@ -514,6 +516,8 @@ namespace Swarmops.Frontend.Pages.v5.Public
|
||||
|
||||
Persistence.Key["SwarmopsInstallationId"] = Guid.NewGuid().ToString();
|
||||
|
||||
SwarmopsLog.DebugLog(" - creating currencies");
|
||||
|
||||
_initMessage = "Initializing currencies...";
|
||||
|
||||
// Create initial currencies (European et al)
|
||||
@@ -535,10 +539,14 @@ namespace Swarmops.Frontend.Pages.v5.Public
|
||||
|
||||
// Create the sandbox
|
||||
|
||||
SwarmopsLog.DebugLog (" - creating Sandbox");
|
||||
|
||||
Organization.Create (0, "Sandbox", "Sandbox", "Sandbox", "swarmops.com", "Ops",
|
||||
rootGeographyId, true,
|
||||
true, 0).EnableEconomy (Currency.FromCode ("EUR"));
|
||||
|
||||
SwarmopsLog.DebugLog(" - complete");
|
||||
|
||||
_initProgress = 100;
|
||||
_initMessage = "Complete.";
|
||||
}
|
||||
@@ -546,6 +554,7 @@ namespace Swarmops.Frontend.Pages.v5.Public
|
||||
{
|
||||
// Use initMessage to push info about what went wrong to the user
|
||||
|
||||
SwarmopsLog.DebugLog (failedException.ToString());
|
||||
_initMessage = failedException.ToString();
|
||||
}
|
||||
|
||||
@@ -682,57 +691,66 @@ namespace Swarmops.Frontend.Pages.v5.Public
|
||||
{
|
||||
// Make sure that no first person exists already, as a security measure
|
||||
|
||||
SwarmopsLog.DebugLog (String.Format("Creating first user: '{0}', '{1}', '{2}'", name, mail, password));
|
||||
|
||||
Person personOne = null;
|
||||
bool personOneExists = false;
|
||||
|
||||
try
|
||||
{
|
||||
personOne = Person.FromIdentity (1);
|
||||
if (Debugger.IsAttached)
|
||||
SwarmopsLog.DebugLog (String.Format ("Creating first user: '{0}', '{1}', '{2}'", name, mail, password));
|
||||
|
||||
Person personOne = null;
|
||||
bool personOneExists = false;
|
||||
|
||||
try
|
||||
{
|
||||
if (personOne.CityName != "Duckville" || personOne.Mail != "noreply@example.com")
|
||||
// these values are returned in debug environments when no person is found
|
||||
personOne = Person.FromIdentity (1);
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
personOneExists = true;
|
||||
if (personOne.CityName != "Duckville" || personOne.Mail != "noreply@example.com")
|
||||
// these values are returned in debug environments when no person is found
|
||||
{
|
||||
personOneExists = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
personOne = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
personOne = null;
|
||||
personOneExists = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception)
|
||||
{
|
||||
personOneExists = true;
|
||||
// We expect this to throw.
|
||||
}
|
||||
|
||||
if (personOneExists || personOne != null)
|
||||
{
|
||||
throw new InvalidOperationException ("Cannot run initialization processes again when initialized.");
|
||||
}
|
||||
|
||||
SwarmopsLog.DebugLog ("- person one did not exist, creating");
|
||||
|
||||
Person newPerson = Person.Create (name, mail, password, string.Empty, string.Empty, string.Empty,
|
||||
string.Empty, string.Empty, DateTime.MinValue, PersonGender.Unknown);
|
||||
|
||||
SwarmopsLog.DebugLog ("- adding participation in Sandbox");
|
||||
|
||||
newPerson.AddParticipation (Organization.Sandbox, DateTime.UtcNow.AddYears (25));
|
||||
// Add membership in Sandbox
|
||||
|
||||
SwarmopsLog.DebugLog ("- creating positions");
|
||||
|
||||
// Initialize staffing to System and Sandbox with the new user
|
||||
|
||||
Positions.CreateSysadminPositions();
|
||||
Positions.CreateOrganizationDefaultPositions (Organization.Sandbox, PositionTitle.Default);
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception e)
|
||||
{
|
||||
// We expect this to throw.
|
||||
SwarmopsLog.DebugLog (e.ToString());
|
||||
throw;
|
||||
}
|
||||
|
||||
if (personOneExists || personOne != null)
|
||||
{
|
||||
throw new InvalidOperationException ("Cannot run initialization processes again when initialized.");
|
||||
}
|
||||
|
||||
SwarmopsLog.DebugLog("- person one did not exist, creating");
|
||||
|
||||
Person newPerson = Person.Create (name, mail, password, string.Empty, string.Empty, string.Empty,
|
||||
string.Empty, string.Empty, DateTime.MinValue, PersonGender.Unknown);
|
||||
|
||||
SwarmopsLog.DebugLog("- adding participation in Sandbox");
|
||||
|
||||
newPerson.AddParticipation (Organization.Sandbox, DateTime.UtcNow.AddYears (25)); // Add membership in Sandbox
|
||||
|
||||
SwarmopsLog.DebugLog ("- creating positions");
|
||||
|
||||
// Initialize staffing to System and Sandbox with the new user
|
||||
|
||||
Positions.CreateSysadminPositions();
|
||||
Positions.CreateOrganizationDefaultPositions(Organization.Sandbox, PositionTitle.Default);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -124,7 +124,10 @@ namespace Swarmops.Pages.Security
|
||||
if (!Request.Url.ToString().StartsWith ("http://dev.swarmops.com/") &&
|
||||
!(Request.Url.ToString().StartsWith ("http://localhost:") && Debugger.IsAttached)) // Debugger.IsAttached is necessary, as link can be faked
|
||||
{
|
||||
Response.Redirect (Request.Url.ToString().Replace ("http:", "https:"));
|
||||
if (SystemSettings.RequireSsl)
|
||||
{
|
||||
Response.Redirect (Request.Url.ToString().Replace ("http:", "https:"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user