git subrepo commit (merge) mailcow/src/mailcow-dockerized

subrepo: subdir:   "mailcow/src/mailcow-dockerized"
  merged:   "02ae5285"
upstream: origin:   "https://github.com/mailcow/mailcow-dockerized.git"
  branch:   "master"
  commit:   "649a5c01"
git-subrepo: version:  "0.4.3"
  origin:   "???"
  commit:   "???"
Change-Id: I870ad468fba026cc5abf3c5699ed1e12ff28b32b
diff --git a/mailcow/src/mailcow-dockerized/data/web/inc/init_db.inc.php b/mailcow/src/mailcow-dockerized/data/web/inc/init_db.inc.php
index 8010bbd..c43afbf 100644
--- a/mailcow/src/mailcow-dockerized/data/web/inc/init_db.inc.php
+++ b/mailcow/src/mailcow-dockerized/data/web/inc/init_db.inc.php
@@ -3,7 +3,7 @@
   try {

     global $pdo;

 

-    $db_version = "28112020_1210";

+    $db_version = "01072021_0630";

 

     $stmt = $pdo->query("SHOW TABLES LIKE 'versions'");

     $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));

@@ -152,9 +152,9 @@
           "id" => "INT NOT NULL AUTO_INCREMENT",

           "destination" => "VARCHAR(255) NOT NULL",

           "nexthop" => "VARCHAR(255) NOT NULL",

-          "username" => "VARCHAR(255) NOT NULL",

-          "password" => "VARCHAR(255) NOT NULL",

-          "lookup_mx" => "TINYINT(1) NOT NULL DEFAULT '1'",

+          "username" => "VARCHAR(255) NOT NULL DEFAULT ''",

+          "password" => "VARCHAR(255) NOT NULL DEFAULT ''",

+          "is_mx_based" => "TINYINT(1) NOT NULL DEFAULT '0'",

           "active" => "TINYINT(1) NOT NULL DEFAULT '1'"

         ),

         "keys" => array(

@@ -319,7 +319,8 @@
             "" => array("username")

           ),

           "key" => array(

-            "domain" => array("domain")

+            "domain" => array("domain"),

+            "kind" => array("kind")

           )

         ),

         "attr" => "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC"

@@ -442,7 +443,9 @@
         "cols" => array(

           "address" => "VARCHAR(255) NOT NULL",

           "goto" => "TEXT NOT NULL",

-          "validity" => "INT(11) NOT NULL"

+          "created" => "DATETIME(0) NOT NULL DEFAULT NOW(0)",

+          "modified" => "DATETIME ON UPDATE CURRENT_TIMESTAMP",

+          "validity" => "INT(11)"

         ),

         "keys" => array(

           "primary" => array(

@@ -505,6 +508,27 @@
         ),

         "attr" => "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC"

       ),

+      "sasl_log" => array(

+        "cols" => array(

+          "service" => "VARCHAR(32) NOT NULL DEFAULT ''",

+          "app_password" => "INT",

+          "username" => "VARCHAR(255) NOT NULL",

+          "real_rip" => "VARCHAR(64) NOT NULL",

+          "datetime" => "DATETIME(0) NOT NULL DEFAULT NOW(0)"

+        ),

+        "keys" => array(

+          "primary" => array(

+            "" => array("service", "real_rip", "username")

+          ),

+          "key" => array(

+            "username" => array("username"),

+            "service" => array("service"),

+            "datetime" => array("datetime"),

+            "real_rip" => array("real_rip")

+          )

+        ),

+        "attr" => "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC"

+      ),

       "quota2" => array(

         "cols" => array(

           "username" => "VARCHAR(255) NOT NULL",

@@ -567,6 +591,8 @@
           "protocol_access" => "TINYINT(1) NOT NULL DEFAULT '1'",

           "smtp_ip_access" => "TINYINT(1) NOT NULL DEFAULT '1'",

           "alias_domains" => "TINYINT(1) NOT NULL DEFAULT '0'",

+          "mailbox_relayhost" => "TINYINT(1) NOT NULL DEFAULT '1'",

+          "domain_relayhost" => "TINYINT(1) NOT NULL DEFAULT '1'",

           "domain_desc" => "TINYINT(1) NOT NULL DEFAULT '0'"

           ),

         "keys" => array(

@@ -972,6 +998,7 @@
           }

         }

       }

+

       // Migrate tls_enforce_* options

       if ($table == 'mailbox') {

         $stmt = $pdo->query("SHOW TABLES LIKE 'mailbox'");

@@ -988,6 +1015,7 @@
           }

         }

       }

+

       $stmt = $pdo->query("SHOW TABLES LIKE '" . $table . "'"); 

       $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));

       if ($num_results != 0) {

@@ -1179,6 +1207,8 @@
     $pdo->query("UPDATE `pushover` SET `attributes` =  JSON_SET(`attributes`, '$.only_x_prio', \"0\") WHERE JSON_VALUE(`attributes`, '$.only_x_prio') IS NULL;");

     // mailbox

     $pdo->query("UPDATE `mailbox` SET `attributes` = '{}' WHERE `attributes` = '' OR `attributes` IS NULL;");

+    $pdo->query("UPDATE `mailbox` SET `attributes` =  JSON_SET(`attributes`, '$.passwd_update', \"0\") WHERE JSON_VALUE(`attributes`, '$.passwd_update') IS NULL;");

+    $pdo->query("UPDATE `mailbox` SET `attributes` =  JSON_SET(`attributes`, '$.relayhost', \"0\") WHERE JSON_VALUE(`attributes`, '$.relayhost') IS NULL;");

     $pdo->query("UPDATE `mailbox` SET `attributes` =  JSON_SET(`attributes`, '$.force_pw_update', \"0\") WHERE JSON_VALUE(`attributes`, '$.force_pw_update') IS NULL;");

     $pdo->query("UPDATE `mailbox` SET `attributes` =  JSON_SET(`attributes`, '$.sogo_access', \"1\") WHERE JSON_VALUE(`attributes`, '$.sogo_access') IS NULL;");

     $pdo->query("UPDATE `mailbox` SET `attributes` =  JSON_SET(`attributes`, '$.imap_access', \"1\") WHERE JSON_VALUE(`attributes`, '$.imap_access') IS NULL;");

@@ -1226,6 +1256,7 @@
 }

 if (php_sapi_name() == "cli") {

   include '/web/inc/vars.inc.php';

+  include '/web/inc/functions.docker.inc.php';

   // $now = new DateTime();

   // $mins = $now->getOffset() / 60;

   // $sgn = ($mins < 0 ? -1 : 1);