Browse Source

[1.6] Fix 2588 Update to 5.2.0 breaks certain functions (#2591)

* PHPmyadmin to 5.2.0
* Fix issue with pma sso not working due to config path changes
* Update version of installed package phpmyadmin
* Switch to new access key
* Prevent 127.0.0.1 added each time v-add-sys-pma-sso runs
* Improve update code
Jaap Marcus 3 years ago
parent
commit
95e646e522

+ 3 - 13
bin/v-add-sys-pma-sso

@@ -41,16 +41,6 @@ if [ -n "$PHPMYADMIN_KEY" ] && [ "$PHPMYADMIN_KEY" != "" ] ; then
     exit 1;
 fi
 
-# Ensure that $HESTIA (/usr/local/hestia/) and other variables are valid.
-if [ -z "$HESTIA" ]; then
-    HESTIA="/usr/local/hestia"
-fi
-
-if [ -z "$HOMEDIR" ] || [ -z "$HESTIA_INSTALL_DIR" ]; then
-    echo "Error: Hestia environment vars not present"
-    exit 2
-fi
-
 if [ -f "/usr/share/phpmyadmin/hestia-sso.php" ]; then 
     echo "Error: hestia-sso.php is already installed"
     exit 2
@@ -61,7 +51,7 @@ if [ -f "/usr/local/hesta/web/api/index.php" ]; then
     exit 2
 fi
 
-if [ "$API" != "yes" ]; then 
+if [ "API_SYSTEM" = "0" ]; then 
     echo "Error: API is not enabled"
     exit 2
 fi
@@ -72,7 +62,7 @@ fi
 
 # Generate the keys to secure everything
 phpmyadminkey=$(generate_password);
-apikey=$($BIN/v-generate-api-key);
+apikey=$($BIN/v-add-access-key 'admin' 'phpmyadmin-sso' 'phpMyAdmin' 'plain');
 
 # copy config dir to /usr/share/phpmyadmin/
 cp -f $HESTIA_INSTALL_DIR/phpmyadmin/hestia-sso.php $PMA_INSTALL/hestia-sso.php
@@ -109,7 +99,7 @@ fi
 
 $BIN/v-change-sys-config-value 'PHPMYADMIN_KEY' "$phpmyadminkey"
 
-if [  "$(echo $API_ALLOWED_IP | grep 127.0.0.1)" != "127.0.0.1" ]; then 
+if [  -z "$(echo $API_ALLOWED_IP | grep 127.0.0.1)"  ]; then 
     $BIN/v-add-sys-api-ip "127.0.0.1"
 fi
 

+ 7 - 2
bin/v-delete-sys-pma-sso

@@ -44,9 +44,14 @@ fi
 #                       Action                             #
 #----------------------------------------------------------#
 
-apikey=$(grep -Po "'API_KEY', '(.*)'" /usr/share/phpmyadmin/hestia-sso.php |  cut "-d'" -f4 )
+apikey=$(grep -Po "'API_KEY', '(.*)'" /usr/share/phpmyadmin/hestia-sso.php |  cut "-d'" -f4  )
 
-$BIN/v-revoke-api-key "$apikey"
+if [ -z $(echo $apikey | grep ":") ]; then
+    $BIN/v-revoke-api-key  "$apikey"
+else
+    apikey=$(grep -Po "'API_KEY', '(.*)'" /usr/share/phpmyadmin/hestia-sso.php |  cut "-d'" -f4 | cut -d ":" -f1 )
+    $BIN/v-delete-access-key "$apikey"
+fi
 
 #remove new files
 rm /usr/share/phpmyadmin/hestia-sso.php

+ 1 - 2
func/upgrade.sh

@@ -597,8 +597,7 @@ upgrade_phpmyadmin() {
             cp -rf phpMyAdmin-$pma_v-all-languages/* /usr/share/phpmyadmin
 
             # Set config and log directory
-            sed -i "s|define('CONFIG_DIR', ROOT_PATH);|define('CONFIG_DIR', '/etc/phpmyadmin/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
-            sed -i "s|define('TEMP_DIR', ROOT_PATH . 'tmp/');|define('TEMP_DIR', '/var/lib/phpmyadmin/tmp/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
+            sed -i "s|'configFile' => ROOT_PATH . 'config.inc.php',|'configFile' => '/etc/phpmyadmin/config.inc.php',|g" /usr/share/phpmyadmin/libraries/vendor_config.php
 
             # Create temporary folder and change permissions
             if [ ! -d /usr/share/phpmyadmin/tmp ]; then

+ 2 - 3
install/hst-install-debian.sh

@@ -33,7 +33,7 @@ VERBOSE='no'
 # Define software versions
 HESTIA_INSTALL_VER='1.6.0~beta-1'
 # Dependencies
-pma_v='5.1.3'
+pma_v='5.2.0'
 rc_v="1.6.0"
 multiphp_v=("5.6" "7.0" "7.1" "7.2" "7.3" "7.4" "8.0" "8.1")
 fpm_v="8.0"
@@ -1541,8 +1541,7 @@ if [ "$mysql" = 'yes' ]; then
     chown root:www-data /usr/share/phpmyadmin/tmp
 
     # Set config and log directory
-    sed -i "s|define('CONFIG_DIR', ROOT_PATH);|define('CONFIG_DIR', '/etc/phpmyadmin/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
-    sed -i "s|define('TEMP_DIR', ROOT_PATH . 'tmp/');|define('TEMP_DIR', '/var/lib/phpmyadmin/tmp/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
+    sed -i "s|'configFile' => ROOT_PATH . 'config.inc.php',|'configFile' => '/etc/phpmyadmin/config.inc.php',|g" /usr/share/phpmyadmin/libraries/vendor_config.php
 
     # Create temporary folder and change permission
     chmod 770 /usr/share/phpmyadmin/tmp

+ 2 - 3
install/hst-install-ubuntu.sh

@@ -33,7 +33,7 @@ VERBOSE='no'
 # Define software versions
 HESTIA_INSTALL_VER='1.6.0~beta-1'
 # Dependencies
-pma_v='5.1.3'
+pma_v='5.2.0'
 rc_v="1.5.2"
 multiphp_v=("5.6" "7.0" "7.1" "7.2" "7.3" "7.4" "8.0" "8.1")
 fpm_v="8.0"
@@ -1605,8 +1605,7 @@ if [ "$mysql" = 'yes' ]; then
     chown root:www-data /usr/share/phpmyadmin/tmp
 
     # Set config and log directory
-    sed -i "s|define('CONFIG_DIR', ROOT_PATH);|define('CONFIG_DIR', '/etc/phpmyadmin/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
-    sed -i "s|define('TEMP_DIR', ROOT_PATH . 'tmp/');|define('TEMP_DIR', '/var/lib/phpmyadmin/tmp/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
+    sed -i "s|'configFile' => ROOT_PATH . 'config.inc.php',|'configFile' => '/etc/phpmyadmin/config.inc.php',|g" /usr/share/phpmyadmin/libraries/vendor_config.php
 
     # Create temporary folder and change permission
     chmod 770 /usr/share/phpmyadmin/tmp

+ 1 - 2
install/upgrade/manual/migrate_phpmyadmin.sh

@@ -83,8 +83,7 @@ then
    chmod 770 -R /var/lib/phpmyadmin/tmp
    
    # Set config and log directory
-   sed -i "s|define('CONFIG_DIR', ROOT_PATH);|define('CONFIG_DIR', '/etc/phpmyadmin/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
-   sed -i "s|define('TEMP_DIR', ROOT_PATH . 'tmp/');|define('TEMP_DIR', '/var/lib/phpmyadmin/tmp');|" /usr/share/phpmyadmin/libraries/vendor_config.php
+   sed -i "s|'configFile' => ROOT_PATH . 'config.inc.php',|'configFile' => '/etc/phpmyadmin/config.inc.php',|g" /usr/share/phpmyadmin/libraries/vendor_config.php
    
    # Generate blowfish
    blowfish=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32)

+ 1 - 1
install/upgrade/upgrade.conf

@@ -36,7 +36,7 @@ UPGRADE_RESTART_SERVICES='true'
 
 # Check if update is required by matching versions if version != current version run update 
 # Set version of phpMyAdmin to install during upgrade if not already installed
-pma_v='5.1.3'
+pma_v='5.2.0'
 
 # Set version of RoundCube (Webmail) to update during upgrade if not already installed
 # Note: only applies to "non-apt installs >= 1.4.0 or manually phased out"

+ 6 - 0
install/upgrade/versions/1.6.0.sh

@@ -82,3 +82,9 @@ if [ -f /etc/nginx/nginx.conf ] && [ "$(grep 'set_real_ip_from 2405:8100::/32' /
     sed -i "/#set_real_ip_from  2a06:98c0::\/29;/d" /etc/nginx/nginx.conf
     sed -i "s/#set_real_ip_from  2400:cb00::\/32;/# set_real_ip_from 2400:cb00::\/32;\n    # set_real_ip_from 2606:4700::\/32;\n    # set_real_ip_from 2803:f800::\/32;\n    # set_real_ip_from 2405:b500::\/32;\n    # set_real_ip_from 2405:8100::\/32;\n    # set_real_ip_from 2a06:98c0::\/29;\n    # set_real_ip_from 2c0f:f248::\/32;/g" /etc/nginx/nginx.conf
 fi
+
+if [ -n "$PHPMYADMIN_KEY" ]; then
+    echo "[ * ] Refresh PMA SSO key due to update phpmyadmin"
+    $BIN/v-delete-sys-pma-sso quiet
+    $BIN/v-add-sys-pma-sso quiet
+fi