From: Guilhem Moulin <guilhem@debian.org>
Date: Sat, 8 Jun 2019 00:44:47 +0200
Subject: Fix INSTALL_PATH for bin/*.sh and tests/bootstrap.php

These scripts get installed to /usr/share/roundcube/bin, but
INSTALL_PATH should be /var/lib/roundcube/.  Fixed/updated with

    sed -ri "s#(\\s*define\\s*\\(\\s*(['\"])INSTALL_PATH\\2)\\s*,.*#\\1, '/var/lib/roundcube/');#" \
            bin/*.sh installer/index.php program/include/iniset.php

Except:

  - bin/install-jsdeps.sh, where we keep define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' ); and
  - bin/updatecss.sh, where we use define('INSTALL_PATH', './');

We also edit tests/bootstrap.php to use the RCUBE_INSTALL_PATH environment variable.

Forwarded: not-needed
---
 bin/cleandb.sh             | 2 +-
 bin/decrypt.sh             | 2 +-
 bin/deluser.sh             | 2 +-
 bin/gc.sh                  | 2 +-
 bin/indexcontacts.sh       | 2 +-
 bin/initdb.sh              | 2 +-
 bin/installto.sh           | 2 +-
 bin/moduserprefs.sh        | 2 +-
 bin/msgexport.sh           | 2 +-
 bin/msgimport.sh           | 2 +-
 bin/update.sh              | 2 +-
 bin/updatecss.sh           | 2 +-
 bin/updatedb.sh            | 2 +-
 installer/index.php        | 2 +-
 program/include/iniset.php | 2 +-
 tests/bootstrap.php        | 2 +-
 16 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/bin/cleandb.sh b/bin/cleandb.sh
index 711f32b..b5db662 100755
--- a/bin/cleandb.sh
+++ b/bin/cleandb.sh
@@ -17,7 +17,7 @@
  +-----------------------------------------------------------------------+
 */
 
-define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
+define('INSTALL_PATH', '/var/lib/roundcube/');
 
 require INSTALL_PATH.'program/include/clisetup.php';
 
diff --git a/bin/decrypt.sh b/bin/decrypt.sh
index b684cd6..965daf0 100755
--- a/bin/decrypt.sh
+++ b/bin/decrypt.sh
@@ -50,7 +50,7 @@
  *  - you are dealing with counterfeit header data.
  */
 
-define('INSTALL_PATH', realpath(__DIR__ .'/..') . '/');
+define('INSTALL_PATH', '/var/lib/roundcube/');
 
 require INSTALL_PATH . 'program/include/clisetup.php';
 
diff --git a/bin/deluser.sh b/bin/deluser.sh
index 37ea2df..1c4d8f9 100755
--- a/bin/deluser.sh
+++ b/bin/deluser.sh
@@ -19,7 +19,7 @@
  +-----------------------------------------------------------------------+
 */
 
-define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
+define('INSTALL_PATH', '/var/lib/roundcube/');
 
 require_once INSTALL_PATH . 'program/include/clisetup.php';
 
diff --git a/bin/gc.sh b/bin/gc.sh
index e83d18e..41caab6 100755
--- a/bin/gc.sh
+++ b/bin/gc.sh
@@ -17,7 +17,7 @@
  +-----------------------------------------------------------------------+
 */
 
-define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
+define('INSTALL_PATH', '/var/lib/roundcube/');
 
 require INSTALL_PATH.'program/include/clisetup.php';
 
diff --git a/bin/indexcontacts.sh b/bin/indexcontacts.sh
index 3fcff80..8b55ca2 100755
--- a/bin/indexcontacts.sh
+++ b/bin/indexcontacts.sh
@@ -18,7 +18,7 @@
  +-----------------------------------------------------------------------+
 */
 
-define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
+define('INSTALL_PATH', '/var/lib/roundcube/');
 
 require_once INSTALL_PATH.'program/include/clisetup.php';
 ini_set('memory_limit', -1);
diff --git a/bin/initdb.sh b/bin/initdb.sh
index a98bbf5..fd8e8cb 100755
--- a/bin/initdb.sh
+++ b/bin/initdb.sh
@@ -18,7 +18,7 @@
  +-----------------------------------------------------------------------+
 */
 
-define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
+define('INSTALL_PATH', '/var/lib/roundcube/');
 
 require_once INSTALL_PATH . 'program/include/clisetup.php';
 
diff --git a/bin/installto.sh b/bin/installto.sh
index 757edf6..595415b 100755
--- a/bin/installto.sh
+++ b/bin/installto.sh
@@ -18,7 +18,7 @@
  +-----------------------------------------------------------------------+
 */
 
-define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
+define('INSTALL_PATH', '/var/lib/roundcube/');
 
 require_once INSTALL_PATH . 'program/include/clisetup.php';
 
diff --git a/bin/moduserprefs.sh b/bin/moduserprefs.sh
index b3402df..a29dcd8 100755
--- a/bin/moduserprefs.sh
+++ b/bin/moduserprefs.sh
@@ -17,7 +17,7 @@
  +-----------------------------------------------------------------------+
 */
 
-define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
+define('INSTALL_PATH', '/var/lib/roundcube/');
 
 require_once INSTALL_PATH.'program/include/clisetup.php';
 
diff --git a/bin/msgexport.sh b/bin/msgexport.sh
index 42624e5..54ef252 100755
--- a/bin/msgexport.sh
+++ b/bin/msgexport.sh
@@ -14,7 +14,7 @@
  +-----------------------------------------------------------------------+
 */
 
-define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
+define('INSTALL_PATH', '/var/lib/roundcube/');
 ini_set('memory_limit', -1);
 
 require_once INSTALL_PATH.'program/include/clisetup.php';
diff --git a/bin/msgimport.sh b/bin/msgimport.sh
index e7dd5cb..3c07a81 100755
--- a/bin/msgimport.sh
+++ b/bin/msgimport.sh
@@ -14,7 +14,7 @@
  +-----------------------------------------------------------------------+
 */
 
-define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
+define('INSTALL_PATH', '/var/lib/roundcube/');
 ini_set('memory_limit', -1);
 
 require_once INSTALL_PATH.'program/include/clisetup.php';
diff --git a/bin/update.sh b/bin/update.sh
index 13f0846..c123385 100755
--- a/bin/update.sh
+++ b/bin/update.sh
@@ -18,7 +18,7 @@
  +-----------------------------------------------------------------------+
 */
 
-define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
+define('INSTALL_PATH', '/var/lib/roundcube/');
 
 require_once INSTALL_PATH . 'program/include/clisetup.php';
 
diff --git a/bin/updatecss.sh b/bin/updatecss.sh
index cac7201..71c94eb 100755
--- a/bin/updatecss.sh
+++ b/bin/updatecss.sh
@@ -17,7 +17,7 @@
  +-----------------------------------------------------------------------+
 */
 
-define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
+define('INSTALL_PATH', './');
 
 require_once INSTALL_PATH . 'program/include/clisetup.php';
 
diff --git a/bin/updatedb.sh b/bin/updatedb.sh
index 133d4a4..fbd48ac 100755
--- a/bin/updatedb.sh
+++ b/bin/updatedb.sh
@@ -18,7 +18,7 @@
  +-----------------------------------------------------------------------+
 */
 
-define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
+define('INSTALL_PATH', '/var/lib/roundcube/');
 
 require_once INSTALL_PATH . 'program/include/clisetup.php';
 
diff --git a/installer/index.php b/installer/index.php
index c645378..e3d089f 100644
--- a/installer/index.php
+++ b/installer/index.php
@@ -38,7 +38,7 @@
 
 ini_set('display_errors', 1);
 
-define('INSTALL_PATH', realpath(__DIR__ . '/../').'/');
+define('INSTALL_PATH', '/var/lib/roundcube/');
 
 require INSTALL_PATH . 'program/include/iniset.php';
 
diff --git a/program/include/iniset.php b/program/include/iniset.php
index 6f9946e..c4ab39f 100644
--- a/program/include/iniset.php
+++ b/program/include/iniset.php
@@ -28,7 +28,7 @@ define('RCMAIL_VERSION', '1.6-git');
 define('RCMAIL_START', microtime(true));
 
 if (!defined('INSTALL_PATH')) {
-    define('INSTALL_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/');
+    define('INSTALL_PATH', '/var/lib/roundcube/');
 }
 
 if (!defined('RCMAIL_CONFIG_DIR')) {
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index e0204d58..6cfd610 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -22,7 +22,7 @@ if (php_sapi_name() != 'cli') {
     die("Not in shell mode (php-cli)");
 }
 
-if (!defined('INSTALL_PATH')) define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
+define('INSTALL_PATH', getenv('RCUBE_INSTALL_PATH') . '/');
 
 define('ROUNDCUBE_TEST_MODE', true);
 define('TESTS_DIR', __DIR__ . '/');
