0013312: install from dump with url
authorPhilipp Schüle <p.schuele@metaways.de>
Wed, 5 Jul 2017 16:51:39 +0000 (18:51 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 6 Jul 2017 07:12:26 +0000 (09:12 +0200)
https://forge.tine20.org/view.php?id=13312

Change-Id: Ibee8cd3bca268d1b46a86967034ba1826e6258f5
Reviewed-on: http://gerrit.tine20.com/customers/5027
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Setup/Controller.php
tine20/Setup/Server/Cli.php

index 96a85eb..bbb4ba9 100644 (file)
@@ -1448,8 +1448,36 @@ class Setup_Controller
             throw new Setup_Exception('Tinebase already installed!');
         }
 
             throw new Setup_Exception('Tinebase already installed!');
         }
 
-        $mysqlBackupFile = $options['backupDir'] . '/tine20_mysql.sql.bz2';
-        if (! file_exists($mysqlBackupFile)) {
+        $mysqlBackupFile = null;
+        if (isset($options['backupDir'])) {
+            $mysqlBackupFile = $options['backupDir'] . '/tine20_mysql.sql.bz2';
+        } else if (isset($options['backupUrl'])) {
+            // download files first and put them in temp dir
+            $tempDir = Tinebase_Core::getTempDir();
+            foreach (array(
+                         array('file' => 'tine20_config.tar.bz2', 'param' => 'config'),
+                         array('file' => 'tine20_mysql.sql.bz2', 'param' => 'db'),
+                         array('file' => 'tine20_files.tar.bz2', 'param' => 'files')
+                    ) as $download) {
+                if (isset($options[$download['param']])) {
+                    $fileUrl = $options['backupUrl'] . '/' . $download['file'];
+                        Setup_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Downloading ' . $fileUrl);
+                    $targetFile = $tempDir . DIRECTORY_SEPARATOR . $download['file'];
+                    if ($download['param'] === 'db') {
+                        $mysqlBackupFile = $targetFile;
+                    }
+                    file_put_contents(
+                        $targetFile,
+                        fopen($fileUrl, 'r')
+                    );
+                }
+            }
+            $options['backupDir'] = $tempDir;
+        } else {
+            throw new Setup_Exception("backupDir or backupUrl param required");
+        }
+
+        if (! $mysqlBackupFile || ! file_exists($mysqlBackupFile)) {
             throw new Setup_Exception("$mysqlBackupFile not found");
         }
 
             throw new Setup_Exception("$mysqlBackupFile not found");
         }
 
index d275679..f137838 100644 (file)
@@ -45,7 +45,8 @@ class Setup_Server_Cli implements Tinebase_Server_Interface
                 'uninstall-s'               => 'Uninstall application [All] or comma separated list',
                 'install_dump'              => 'Install Tine from a backup
                          Examples:
                 'uninstall-s'               => 'Uninstall application [All] or comma separated list',
                 'install_dump'              => 'Install Tine from a backup
                          Examples:
-                           setup.php --install_dump -- db=1 files=1 backupDir=/backup/tine20',
+                           setup.php --install_dump -- db=1 files=1 backupDir=/backup/tine20
+                           setup.php --install_dump -- db=1 files=1 backupUrl=https://username:password@example.org/mydump',
                 'list-s'                    => 'List installed applications',
                 'sync_accounts_from_ldap'   => 'Import user and groups from ldap',
                     'dbmailldap'            => 'Only usable with sync_accounts_from_ldap. Fetches dbmail email user data from LDAP.',
                 'list-s'                    => 'List installed applications',
                 'sync_accounts_from_ldap'   => 'Import user and groups from ldap',
                     'dbmailldap'            => 'Only usable with sync_accounts_from_ldap. Fetches dbmail email user data from LDAP.',