diff --git a/entrypoint.sh b/entrypoint.sh index 1340933..0ca8f82 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,3 +1,8 @@ #!/usr/bin/env bash -cp /var/www/html/sample-config/* /var/www/html/config/ +echo Removing old sample config files… +rm /var/www/html/config/*.sample.ini +echo Copying new sample config files… +cp /var/www/html/default-config/config.default.ini /var/www/html/config/config.sample.ini +cp /var/www/html/default-config/services.default.ini /var/www/html/config/services.sample.ini +echo Running HTTPD… exec apache2-foreground diff --git a/src/core/init.php b/src/core/init.php index 2239eba..b35a251 100644 --- a/src/core/init.php +++ b/src/core/init.php @@ -22,30 +22,33 @@ class Init { $loader->request_page(); } private function get_config(){ - // define the config file location - $config = Core::root_dir()."/config/config.ini"; + // parse the default config file for default values + $default_config = parse_ini_file(Core::root_dir()."/default-config/config.default.ini", true); + // define the custom config file location + $config_file = Core::root_dir()."/config/config.ini"; + $config = array(); + if (file_exists($config_file)) { + // if a custom config file exists then parse that file too + $config = parse_ini_file($config_file, true); + } + // merge the default config with the custom config + Core::$Config = array_merge($default_config,$config); - // if it doesn't exist, use the sample file - // YOU REALLY SHOULD HAVE YOUR OWN CONFIG FILE!!! + // parse the default services file for default values + $default_services = parse_ini_file(Core::root_dir()."/default-config/services.default.ini", true); - if (!file_exists($config)) { - $config = Core::root_dir()."/sample-config/config.sample.ini"; + // define the custom services file location + $services_file = Core::root_dir()."/config/services.ini"; + $services = array(); + if (file_exists($services_file)) { + // if a custom config file exists then parse that file too + $services = parse_ini_file($services_file, true); } - // define services file location - $services = Core::root_dir()."/config/services.ini"; + // merge the default config with the custom config + Core::$Config["Services"] = array_merge($default_services,$services); - // if it doesn't exist, use the sample file - // YOU REALLY SHOULD HAVE YOUR OWN SERVICES FILE!!! - - if (!file_exists($services)) { - $services = Core::root_dir()."/sample-config/services.sample.ini"; - } - - // Store the config settings in the Core::Config variable - // the "true" means it's going to parse the headers as well. - Core::$Config = parse_ini_file($config, true); - Core::$Config["Services"] = parse_ini_file($services, true); + // get the current git commit, if it exists. For testing Core::$Config["CommitID"] = Core::get_current_git_commit(); } } diff --git a/src/core/init/core.php b/src/core/init/core.php index 6748e1a..afb9331 100644 --- a/src/core/init/core.php +++ b/src/core/init/core.php @@ -1,6 +1,6 @@ $service){ + if (!$service["Enabled"]) { + continue; + } $response->content[$key] = $service; } @@ -130,7 +133,7 @@ class Response { public $url; public $content_type = "json"; public $message; - public $headers_set = false; + // public $headers_set = false; public $content = array(); public function __construct(){ // add requested page to response. I don't know why, but it could helpful for diagnostics at some point diff --git a/src/sample-config/config.sample.ini b/src/default-config/config.default.ini similarity index 59% rename from src/sample-config/config.sample.ini rename to src/default-config/config.default.ini index 6651564..7439b2c 100644 --- a/src/sample-config/config.sample.ini +++ b/src/default-config/config.default.ini @@ -4,13 +4,10 @@ ; The URL of this application BaseURL = "https://autoconfig.example.com" - - -; Set the base email domain for use with this service -Domain = example.com +; Set the email domains for use with this service. The first one is primary. +; each will need their own DNS A record for autoconfig.domain.name +Domain[] = example.com +Domain[] = example2.com ; If you use a different domain to authenticate with, enter it here LogonDomain = example.local - -; Change to true if you need the domain/logondomain to form part of the username -RequireAuthDomain = false diff --git a/src/sample-config/services.sample.ini b/src/default-config/services.default.ini similarity index 56% rename from src/sample-config/services.sample.ini rename to src/default-config/services.default.ini index 6d3f804..4ec9d89 100644 --- a/src/sample-config/services.sample.ini +++ b/src/default-config/services.default.ini @@ -1,6 +1,9 @@ ; The Incoming mail Server Config [InMail] +; Enable this service +Enabled = true + ; Mail Type, i.e. IMAP, POP3 Type = "IMAP" @@ -13,6 +16,15 @@ Port = 993 ; The socket type : SSL, STARTTLS, or NONE SocketType = SSL +; Use Secure Password Authentication +SPA = false + +; Change to true if you need the domain/logondomain to form part of the username +UsernameIsFQDN = false + +; Do you need to authenticate to your mail server? You should! so this should be false! +NoAuthRequired = false + ; Authentication type, ;"password-cleartext" : Send password in the clear ; (dangerous, if SSL isn't used either). @@ -23,9 +35,14 @@ SocketType = SSL ; the Windows login mechanism. Authentication = password-cleartext + + ; The Outgoing mail server config [OutMail] +; Enable this service +Enabled = true + ; Mail type, likely to only be SMTP Type = "SMTP" @@ -41,30 +58,53 @@ SocketType = SSL ; See InMail > Authentication Authentication = password-cleartext +; Use Secure Password Authentication +SPA = false + +; Change to true if you need the domain/logondomain to form part of the username +UsernameIsFQDN = false + +; Do you need to authenticate to your mail server? You should! so this should be false! +NoAuthRequired = false + +; Use POP Authentication? You probably shouldn't be. +POPAuth = false + +; This setting is here to limit errors, I'm not sure what it does yet. +SMTPLast = false ; Currently not implemented, see https://wiki.mozilla.org/Thunderbird:Autoconfiguration:ConfigFileFormat -;[Calendar] -;Server = "https://example.com/remote.php/dav/" -;Port = 443 -;Type = CalDAV -;Authentication = http-basic +[Calendar] +; Disable this service +Enabled = false +Server = "https://example.com/remote.php/dav/" +Port = 443 +Type = CalDAV +Authentication = http-basic +UsernameIsFQDN = false ; Currently not implemented, see https://wiki.mozilla.org/Thunderbird:Autoconfiguration:ConfigFileFormat -;[AddressBook] -;Server = "https://example.com/remote.php/dav/" -;Port = 443 -;Type = CardDAV -;Authentication = http-basic +[AddressBook] +; Disable this service +Enabled = false +Server = "https://example.com/remote.php/dav/" +Port = 443 +Type = CardDAV +Authentication = http-basic +UsernameIsFQDN = false ; Currently not implemented, see https://wiki.mozilla.org/Thunderbird:Autoconfiguration:ConfigFileFormat -;[WebMail] -;Server = https://mail.example.com -;UsernameDivID = "username" -;UsernameDivName = "username" -;PasswordDivName = "password" -;SubmitButtonID = "submit" -;SubmitButtonName = "submit" +[WebMail] +; Disable this service +Enabled = false +Server = https://mail.example.com +UsernameDivID = "username" +UsernameDivName = "username" +PasswordDivName = "password" +SubmitButtonID = "submit" +SubmitButtonName = "submit" +UsernameIsFQDN = false ; In theory, additional custom services can be configured and will be displayed with diff --git a/src/public/autoconfig.php b/src/public/autoconfig.php index 0571599..3d91f35 100644 --- a/src/public/autoconfig.php +++ b/src/public/autoconfig.php @@ -13,17 +13,19 @@ $data = Core::get_get_data(); $email_provided = false; $display_name = false; $emailaddress = false; -if ($data["emailaddress"]) { +if (isset($data["emailaddress"])) { $email_address = $data["emailaddress"]; $display_name = $email_address; $email_provided = true; } else if ($data["path"]) { $query = parse_url($data["path"]); - $email_address = explode("=",$query["query"]); - if ($email_address[0] == "emailaddress") { - $email_address = $email[1]; - $email_provided = true; - $display_name = $email_address; + if (isset($query["query"])){ + $email_address = explode("=",$query["query"]); + if ($email_address[0] == "emailaddress") { + $email_address = $email_address[1]; + $email_provided = true; + $display_name = $email_address; + } } } if ($email_provided) { @@ -38,10 +40,12 @@ if ($email_provided) { // https://wiki.mozilla.org/Thunderbird:Autoconfiguration:ConfigFileFormat ?> - "> - + "> + + + - "> @@ -51,7 +55,7 @@ if ($email_provided) { "> @@ -61,7 +65,7 @@ if ($email_provided) { "> @@ -69,7 +73,7 @@ if ($email_provided) { "> @@ -77,7 +81,7 @@ if ($email_provided) { " /> diff --git a/src/public/autodiscover.php b/src/public/autodiscover.php index 6f50fe4..ded1799 100644 --- a/src/public/autodiscover.php +++ b/src/public/autodiscover.php @@ -8,38 +8,38 @@ preg_match("/\(.*?)\<\/EMailAddress\>/", $data, $matches); // // // -// psw@wilde.cloud +// your@email.address // http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a // // echo '';?> - + email settings - - + - +