Skip to content

Commit 95e646e

Browse files
authored
[1.6] Fix 2588 Update to 5.2.0 breaks certain functions (hestiacp#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
1 parent b0ce8a6 commit 95e646e

File tree

8 files changed

+23
-26
lines changed

8 files changed

+23
-26
lines changed

bin/v-add-sys-pma-sso

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@ if [ -n "$PHPMYADMIN_KEY" ] && [ "$PHPMYADMIN_KEY" != "" ] ; then
4141
exit 1;
4242
fi
4343

44-
# Ensure that $HESTIA (/usr/local/hestia/) and other variables are valid.
45-
if [ -z "$HESTIA" ]; then
46-
HESTIA="/usr/local/hestia"
47-
fi
48-
49-
if [ -z "$HOMEDIR" ] || [ -z "$HESTIA_INSTALL_DIR" ]; then
50-
echo "Error: Hestia environment vars not present"
51-
exit 2
52-
fi
53-
5444
if [ -f "/usr/share/phpmyadmin/hestia-sso.php" ]; then
5545
echo "Error: hestia-sso.php is already installed"
5646
exit 2
@@ -61,7 +51,7 @@ if [ -f "/usr/local/hesta/web/api/index.php" ]; then
6151
exit 2
6252
fi
6353

64-
if [ "$API" != "yes" ]; then
54+
if [ "API_SYSTEM" = "0" ]; then
6555
echo "Error: API is not enabled"
6656
exit 2
6757
fi
@@ -72,7 +62,7 @@ fi
7262

7363
# Generate the keys to secure everything
7464
phpmyadminkey=$(generate_password);
75-
apikey=$($BIN/v-generate-api-key);
65+
apikey=$($BIN/v-add-access-key 'admin' 'phpmyadmin-sso' 'phpMyAdmin' 'plain');
7666

7767
# copy config dir to /usr/share/phpmyadmin/
7868
cp -f $HESTIA_INSTALL_DIR/phpmyadmin/hestia-sso.php $PMA_INSTALL/hestia-sso.php
@@ -109,7 +99,7 @@ fi
10999

110100
$BIN/v-change-sys-config-value 'PHPMYADMIN_KEY' "$phpmyadminkey"
111101

112-
if [ "$(echo $API_ALLOWED_IP | grep 127.0.0.1)" != "127.0.0.1" ]; then
102+
if [ -z "$(echo $API_ALLOWED_IP | grep 127.0.0.1)" ]; then
113103
$BIN/v-add-sys-api-ip "127.0.0.1"
114104
fi
115105

bin/v-delete-sys-pma-sso

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,14 @@ fi
4444
# Action #
4545
#----------------------------------------------------------#
4646

47-
apikey=$(grep -Po "'API_KEY', '(.*)'" /usr/share/phpmyadmin/hestia-sso.php | cut "-d'" -f4 )
47+
apikey=$(grep -Po "'API_KEY', '(.*)'" /usr/share/phpmyadmin/hestia-sso.php | cut "-d'" -f4 )
4848

49-
$BIN/v-revoke-api-key "$apikey"
49+
if [ -z $(echo $apikey | grep ":") ]; then
50+
$BIN/v-revoke-api-key "$apikey"
51+
else
52+
apikey=$(grep -Po "'API_KEY', '(.*)'" /usr/share/phpmyadmin/hestia-sso.php | cut "-d'" -f4 | cut -d ":" -f1 )
53+
$BIN/v-delete-access-key "$apikey"
54+
fi
5055

5156
#remove new files
5257
rm /usr/share/phpmyadmin/hestia-sso.php

func/upgrade.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,7 @@ upgrade_phpmyadmin() {
597597
cp -rf phpMyAdmin-$pma_v-all-languages/* /usr/share/phpmyadmin
598598

599599
# Set config and log directory
600-
sed -i "s|define('CONFIG_DIR', ROOT_PATH);|define('CONFIG_DIR', '/etc/phpmyadmin/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
601-
sed -i "s|define('TEMP_DIR', ROOT_PATH . 'tmp/');|define('TEMP_DIR', '/var/lib/phpmyadmin/tmp/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
600+
sed -i "s|'configFile' => ROOT_PATH . 'config.inc.php',|'configFile' => '/etc/phpmyadmin/config.inc.php',|g" /usr/share/phpmyadmin/libraries/vendor_config.php
602601

603602
# Create temporary folder and change permissions
604603
if [ ! -d /usr/share/phpmyadmin/tmp ]; then

install/hst-install-debian.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ VERBOSE='no'
3333
# Define software versions
3434
HESTIA_INSTALL_VER='1.6.0~beta-1'
3535
# Dependencies
36-
pma_v='5.1.3'
36+
pma_v='5.2.0'
3737
rc_v="1.6.0"
3838
multiphp_v=("5.6" "7.0" "7.1" "7.2" "7.3" "7.4" "8.0" "8.1")
3939
fpm_v="8.0"
@@ -1541,8 +1541,7 @@ if [ "$mysql" = 'yes' ]; then
15411541
chown root:www-data /usr/share/phpmyadmin/tmp
15421542

15431543
# Set config and log directory
1544-
sed -i "s|define('CONFIG_DIR', ROOT_PATH);|define('CONFIG_DIR', '/etc/phpmyadmin/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
1545-
sed -i "s|define('TEMP_DIR', ROOT_PATH . 'tmp/');|define('TEMP_DIR', '/var/lib/phpmyadmin/tmp/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
1544+
sed -i "s|'configFile' => ROOT_PATH . 'config.inc.php',|'configFile' => '/etc/phpmyadmin/config.inc.php',|g" /usr/share/phpmyadmin/libraries/vendor_config.php
15461545

15471546
# Create temporary folder and change permission
15481547
chmod 770 /usr/share/phpmyadmin/tmp

install/hst-install-ubuntu.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ VERBOSE='no'
3333
# Define software versions
3434
HESTIA_INSTALL_VER='1.6.0~beta-1'
3535
# Dependencies
36-
pma_v='5.1.3'
36+
pma_v='5.2.0'
3737
rc_v="1.5.2"
3838
multiphp_v=("5.6" "7.0" "7.1" "7.2" "7.3" "7.4" "8.0" "8.1")
3939
fpm_v="8.0"
@@ -1605,8 +1605,7 @@ if [ "$mysql" = 'yes' ]; then
16051605
chown root:www-data /usr/share/phpmyadmin/tmp
16061606

16071607
# Set config and log directory
1608-
sed -i "s|define('CONFIG_DIR', ROOT_PATH);|define('CONFIG_DIR', '/etc/phpmyadmin/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
1609-
sed -i "s|define('TEMP_DIR', ROOT_PATH . 'tmp/');|define('TEMP_DIR', '/var/lib/phpmyadmin/tmp/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
1608+
sed -i "s|'configFile' => ROOT_PATH . 'config.inc.php',|'configFile' => '/etc/phpmyadmin/config.inc.php',|g" /usr/share/phpmyadmin/libraries/vendor_config.php
16101609

16111610
# Create temporary folder and change permission
16121611
chmod 770 /usr/share/phpmyadmin/tmp

install/upgrade/manual/migrate_phpmyadmin.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ then
8383
chmod 770 -R /var/lib/phpmyadmin/tmp
8484

8585
# Set config and log directory
86-
sed -i "s|define('CONFIG_DIR', ROOT_PATH);|define('CONFIG_DIR', '/etc/phpmyadmin/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
87-
sed -i "s|define('TEMP_DIR', ROOT_PATH . 'tmp/');|define('TEMP_DIR', '/var/lib/phpmyadmin/tmp');|" /usr/share/phpmyadmin/libraries/vendor_config.php
86+
sed -i "s|'configFile' => ROOT_PATH . 'config.inc.php',|'configFile' => '/etc/phpmyadmin/config.inc.php',|g" /usr/share/phpmyadmin/libraries/vendor_config.php
8887

8988
# Generate blowfish
9089
blowfish=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32)

install/upgrade/upgrade.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ UPGRADE_RESTART_SERVICES='true'
3636

3737
# Check if update is required by matching versions if version != current version run update
3838
# Set version of phpMyAdmin to install during upgrade if not already installed
39-
pma_v='5.1.3'
39+
pma_v='5.2.0'
4040

4141
# Set version of RoundCube (Webmail) to update during upgrade if not already installed
4242
# Note: only applies to "non-apt installs >= 1.4.0 or manually phased out"

install/upgrade/versions/1.6.0.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,9 @@ if [ -f /etc/nginx/nginx.conf ] && [ "$(grep 'set_real_ip_from 2405:8100::/32' /
8282
sed -i "/#set_real_ip_from 2a06:98c0::\/29;/d" /etc/nginx/nginx.conf
8383
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
8484
fi
85+
86+
if [ -n "$PHPMYADMIN_KEY" ]; then
87+
echo "[ * ] Refresh PMA SSO key due to update phpmyadmin"
88+
$BIN/v-delete-sys-pma-sso quiet
89+
$BIN/v-add-sys-pma-sso quiet
90+
fi

0 commit comments

Comments
 (0)