Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/roundcube/roundcubemail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2022-01-26 00:11:00 +0300
committerThomas Bruederli <thomas@roundcube.net>2022-01-26 00:11:00 +0300
commitb82ae59da04622c2f6bbce372c124e9c851bb806 (patch)
treedf394e7f650f36d480b2183cd3b3b039803d721e
parent3c5547195fcaa19c6d73f5b5a1f5c880beeb6eab (diff)
Add utils script to initialize or update databasepr-docker-db-init-update
This can be used by the Docker images where we don't know whether the confgured database is already initialized.
-rwxr-xr-xbin/init-or-update-db.sh45
1 files changed, 45 insertions, 0 deletions
diff --git a/bin/init-or-update-db.sh b/bin/init-or-update-db.sh
new file mode 100755
index 000000000..8601dc44e
--- /dev/null
+++ b/bin/init-or-update-db.sh
@@ -0,0 +1,45 @@
+#!/usr/bin/env php
+<?php
+/*
+ +-----------------------------------------------------------------------+
+ | This file is part of the Roundcube Webmail client |
+ | |
+ | Copyright (C) The Roundcube Dev Team |
+ | |
+ | Licensed under the GNU General Public License version 3 or |
+ | any later version with exceptions for skins & plugins. |
+ | See the README file for a full license statement. |
+ | |
+ | PURPOSE: |
+ | Create or update database schema |
+ +-----------------------------------------------------------------------+
+ | Author: Thomas Bruederli <thomas@roundcube.net> |
+ +-----------------------------------------------------------------------+
+*/
+
+define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
+
+require_once INSTALL_PATH . 'program/include/clisetup.php';
+
+// get arguments
+$opts = rcube_utils::get_opt([
+ 'd' => 'dir',
+]);
+
+if (empty($opts['dir'])) {
+ rcube::raise_error("Database schema directory not specified (--dir).", false, true);
+}
+
+// Check if directory exists
+if (!file_exists($opts['dir'])) {
+ rcube::raise_error("Specified database schema directory doesn't exist.", false, true);
+}
+
+$db = rcmail_utils::db();
+
+if (in_array($db->table_name('system'), (array)$db->list_tables())) {
+ echo "Checking for database schema updates..." . PHP_EOL;
+ rcmail_utils::db_update($opts['dir'], 'roundcube', null, ['errors' => true]);
+} else {
+ rcmail_utils::db_init($opts['dir']);
+}