Skip to content

Commit 6542cb4

Browse files
committed
Fix Phase 1 critical issues
- Fix #2738, #2769, #2724: Migrate from AdminerEvo to AdminerNeo * AdminerEvo project has been archived * Updated to use AdminerNeo v1.0.2 from GitHub releases * Added proper error handling and file validation - Fix #2731, #2697: ElasticSearch version detection * Improved regex to extract version numbers from any position * Added validation to ensure proper version format * Added fallback to known stable version (8.16.1) if detection fails - Fix #2761, #2727: PostgreSQL schema permissions for NC 30+ * Added GRANT CREATE ON SCHEMA public for fresh installations * Added migration fix in update script for existing installations * PostgreSQL 15+ requires explicit schema permissions - Fix #2701, #2674: GeoBlock installation improvements * Better error handling for apache2-dev dependency conflicts * Added dependency fix attempts before failing * Improved compilation error messages * Added verification that apxs tool is available * Better progress feedback during compilation
1 parent 0fe3e7a commit 6542cb4

File tree

5 files changed

+179
-13
lines changed

5 files changed

+179
-13
lines changed

apps/adminer.sh

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
44

55
true
6-
SCRIPT_NAME="Adminer"
7-
SCRIPT_EXPLAINER="Adminer is a full-featured database management tool written in PHP."
6+
SCRIPT_NAME="AdminerNeo"
7+
SCRIPT_EXPLAINER="AdminerNeo is a full-featured database management tool written in PHP.
8+
It's a fork of Adminer, continuing development after AdminerEvo was archived.
9+
More info: https://github.com/adminerneo/adminerneo"
810
# shellcheck source=lib.sh
911
source /var/scripts/fetch_lib.sh
1012

@@ -52,13 +54,51 @@ a2enmod ssl
5254
# Install Adminer
5355
apt-get update -q4 & spinner_loading
5456
install_if_not adminer
55-
curl_to_dir "https://download.adminerevo.org/latest/adminer" "adminer-pgsql.zip" "$ADMINERDIR"
57+
58+
# AdminerEvo project has been archived, switching to AdminerNeo
59+
# See: https://github.com/adminerneo/adminerneo
60+
ADMINER_VERSION="1.0.2"
61+
ADMINER_DOWNLOAD_URL="https://github.com/adminerneo/adminerneo/releases/download/v${ADMINER_VERSION}/adminerneo-${ADMINER_VERSION}-pgsql.zip"
62+
63+
print_text_in_color "$ICyan" "Downloading AdminerNeo version ${ADMINER_VERSION}..."
64+
if ! curl_to_dir "https://github.com/adminerneo/adminerneo/releases/download/v${ADMINER_VERSION}/" "adminerneo-${ADMINER_VERSION}-pgsql.zip" "$ADMINERDIR"
65+
then
66+
msg_box "Failed to download AdminerNeo. The download URL may have changed.
67+
68+
Please report this issue to: $ISSUES
69+
70+
Attempted to download from:
71+
$ADMINER_DOWNLOAD_URL"
72+
exit 1
73+
fi
74+
5675
install_if_not unzip
5776
# Unzip the latest version
58-
unzip "$ADMINERDIR"/adminer-pgsql.zip -d "$ADMINERDIR"
59-
rm -f "$ADMINERDIR"/adminer-pgsql.zip
60-
# curl_to_dir "https://raw.githubusercontent.com/Niyko/Hydra-Dark-Theme-for-Adminer/master" "adminer.css" "$ADMINERDIR"
61-
mv "$ADMINERDIR"/adminer-pgsql.php "$ADMINERDIR"/adminer.php
77+
if ! unzip -o "$ADMINERDIR"/adminerneo-${ADMINER_VERSION}-pgsql.zip -d "$ADMINERDIR"
78+
then
79+
msg_box "Failed to extract AdminerNeo archive. Please report this to $ISSUES"
80+
exit 1
81+
fi
82+
83+
rm -f "$ADMINERDIR"/adminerneo-${ADMINER_VERSION}-pgsql.zip
84+
85+
# AdminerNeo uses different naming convention
86+
if [ -f "$ADMINERDIR"/adminerneo-${ADMINER_VERSION}-pgsql.php ]; then
87+
mv "$ADMINERDIR"/adminerneo-${ADMINER_VERSION}-pgsql.php "$ADMINERDIR"/adminer.php
88+
elif [ -f "$ADMINERDIR"/adminerneo-pgsql.php ]; then
89+
mv "$ADMINERDIR"/adminerneo-pgsql.php "$ADMINERDIR"/adminer.php
90+
else
91+
# Fallback: find any .php file and use it
92+
ADMINER_PHP_FILE=$(find "$ADMINERDIR" -maxdepth 1 -name "*.php" -type f | head -1)
93+
if [ -n "$ADMINER_PHP_FILE" ]; then
94+
mv "$ADMINER_PHP_FILE" "$ADMINERDIR"/adminer.php
95+
else
96+
msg_box "Could not find AdminerNeo PHP file after extraction. Please report this to $ISSUES"
97+
exit 1
98+
fi
99+
fi
100+
101+
print_text_in_color "$IGreen" "AdminerNeo ${ADMINER_VERSION} successfully downloaded and extracted!"
62102

63103
# Only add TLS 1.3 on Ubuntu later than 22.04
64104
if version 22.04 "$DISTRO" 24.04.10

lib.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,22 @@ fulltextsearch_install() {
184184
ELASTIC_USER_PASSWORD=$(gen_passwd "$SHUF" '[:lower:]')
185185
FULLTEXTSEARCH_IMAGE_NAME=fulltextsearch_es01
186186
FULLTEXTSEARCH_SERVICE=nextcloud-fulltext-elasticsearch-worker.service
187+
187188
# Gets the version from the latest tag here: https://github.com/docker-library/official-images/blob/master/library/elasticsearch
188-
FULLTEXTSEARCH_IMAGE_NAME_LATEST_TAG="$(curl -s -m 900 https://raw.githubusercontent.com/docker-library/official-images/refs/heads/master/library/elasticsearch | grep "Tags:" | head -1 | awk '{print $2}')"
189+
# Use limit=500 to ensure we get version tags, not just SHA tags
190+
# Extract version numbers (format: X.XX.X), sort them, and get the latest
191+
FULLTEXTSEARCH_IMAGE_NAME_LATEST_TAG="$(curl -s -m 900 'https://raw.githubusercontent.com/docker-library/official-images/refs/heads/master/library/elasticsearch' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' | sort -V | tail -1)"
192+
193+
# Validate that we got a proper version number
194+
if ! echo "$FULLTEXTSEARCH_IMAGE_NAME_LATEST_TAG" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'
195+
then
196+
print_text_in_color "$IRed" "Failed to detect ElasticSearch version. Got: '$FULLTEXTSEARCH_IMAGE_NAME_LATEST_TAG'"
197+
print_text_in_color "$ICyan" "Falling back to known stable version..."
198+
FULLTEXTSEARCH_IMAGE_NAME_LATEST_TAG="8.16.1"
199+
fi
200+
201+
print_text_in_color "$ICyan" "ElasticSearch version detected: $FULLTEXTSEARCH_IMAGE_NAME_LATEST_TAG"
202+
189203
# Legacy, changed 2023-09-21
190204
DOCKER_IMAGE_NAME=es01
191205
# Legacy, not used at all

network/geoblock.sh

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,32 +81,103 @@ then
8181
fi
8282

8383
##### GeoIP script (Apache Setup)
84-
# Install requirements
84+
# Install requirements
8585
yes | add-apt-repository ppa:maxmind/ppa
8686
apt-get update -q4 & spinner_loading
8787
install_if_not libmaxminddb0
8888
install_if_not libmaxminddb-dev
8989
install_if_not mmdb-bin
90-
install_if_not apache2-dev
90+
91+
# Install apache2-dev with dependency resolution
92+
# Handle conflicts with Sury PPA packages
93+
print_text_in_color "$ICyan" "Installing apache2-dev (this may take a moment)..."
94+
if ! apt-get install -y apache2-dev 2>&1 | tee /tmp/apache2-dev-install.log
95+
then
96+
print_text_in_color "$IYellow" "Warning: apache2-dev installation encountered issues."
97+
print_text_in_color "$ICyan" "Attempting to resolve dependency conflicts..."
98+
99+
# Try to fix broken dependencies
100+
if apt-get install -f -y
101+
then
102+
print_text_in_color "$IGreen" "Dependencies fixed, retrying apache2-dev installation..."
103+
if ! apt-get install -y apache2-dev
104+
then
105+
msg_box "Failed to install apache2-dev even after fixing dependencies.
106+
107+
This is likely due to conflicts with PHP PPA packages (e.g., Sury PPA).
108+
The error log has been saved to /tmp/apache2-dev-install.log
109+
110+
Please report this issue to: $ISSUES
111+
Include the contents of /tmp/apache2-dev-install.log"
112+
exit 1
113+
fi
114+
else
115+
msg_box "Could not resolve apache2-dev dependency conflicts.
116+
117+
The error log has been saved to /tmp/apache2-dev-install.log
118+
119+
Please report this issue to: $ISSUES
120+
Include the contents of /tmp/apache2-dev-install.log"
121+
exit 1
122+
fi
123+
fi
124+
125+
# Verify apxs is available before attempting compilation
126+
if ! command -v apxs2 >/dev/null 2>&1 && ! command -v apxs >/dev/null 2>&1
127+
then
128+
msg_box "Error: apxs/apxs2 tool not found even after installing apache2-dev.
129+
130+
This tool is required to compile the MaxMindDB Apache module.
131+
Please report this issue to: $ISSUES"
132+
exit 1
133+
fi
134+
135+
print_text_in_color "$IGreen" "apache2-dev and apxs successfully installed!"
91136

92137
# maxminddb_module https://github.com/maxmind/mod_maxminddb
93138
cd /tmp
94139
curl_to_dir https://github.com/maxmind/mod_maxminddb/releases/download/1.2.0/ mod_maxminddb-1.2.0.tar.gz /tmp
95140
tar -xzf mod_maxminddb-1.2.0.tar.gz
96141
cd mod_maxminddb-1.2.0
142+
143+
print_text_in_color "$ICyan" "Compiling MaxMindDB Apache module..."
97144
if ./configure
98145
then
99-
make install
146+
if make
147+
then
148+
if make install
149+
then
150+
print_text_in_color "$IGreen" "MaxMindDB Apache module compiled and installed successfully!"
151+
else
152+
msg_box "Failed to install MaxMindDB module. Please report this to $ISSUES"
153+
exit 1
154+
fi
155+
else
156+
msg_box "Failed to compile MaxMindDB module. Please report this to $ISSUES"
157+
exit 1
158+
fi
159+
100160
# Delete conf made by module
101161
rm -f /etc/apache2/mods-enabled/maxminddb.conf
162+
102163
# Check if module is enabled
103164
if ! apachectl -M | grep -i "maxminddb"
104165
then
105-
msg_box "Couldn't install the Apache module for MaxMind. Please report this to $ISSUES"
166+
msg_box "Couldn't load the Apache module for MaxMind after installation. Please report this to $ISSUES"
106167
exit 1
107168
fi
169+
170+
print_text_in_color "$IGreen" "MaxMindDB module loaded in Apache successfully!"
171+
108172
# Cleanup
173+
cd /tmp
109174
rm -rf mod_maxminddb-1.2.0 mod_maxminddb-1.2.0.tar.gz
175+
else
176+
msg_box "Failed to configure MaxMindDB module compilation.
177+
178+
This usually means apxs/apxs2 is not properly installed.
179+
Please report this issue to: $ISSUES"
180+
exit 1
110181
fi
111182

112183
# Enable modules

nextcloud_install_production.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,13 +362,26 @@ done
362362
apt-get update -q4 & spinner_loading
363363
install_if_not postgresql
364364

365-
# Create DB
365+
# Create DB with proper permissions for Nextcloud 30+
366+
# PostgreSQL 15+ requires explicit schema permissions
366367
cd /tmp
367368
sudo -u postgres psql <<END
368369
CREATE USER $PGDB_USER WITH PASSWORD '$PGDB_PASS';
369370
CREATE DATABASE nextcloud_db WITH OWNER $PGDB_USER TEMPLATE template0 ENCODING 'UTF8';
371+
\c nextcloud_db
372+
GRANT CREATE ON SCHEMA public TO $PGDB_USER;
373+
GRANT ALL ON SCHEMA public TO $PGDB_USER;
374+
ALTER DATABASE nextcloud_db OWNER TO $PGDB_USER;
370375
END
376+
377+
if [ $? -ne 0 ]; then
378+
print_text_in_color "$IRed" "Failed to create PostgreSQL database with proper permissions!"
379+
print_text_in_color "$ICyan" "Please report this to $ISSUES"
380+
exit 1
381+
fi
382+
371383
print_text_in_color "$ICyan" "PostgreSQL password: $PGDB_PASS"
384+
print_text_in_color "$IGreen" "PostgreSQL database created with schema permissions for Nextcloud 30+"
372385
systemctl restart postgresql.service
373386

374387
# Install Apache

nextcloud_update.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,34 @@ then
8484
fi
8585
fi
8686

87+
# Fix PostgreSQL schema permissions for Nextcloud 30+ (if PostgreSQL is installed)
88+
# PostgreSQL 15+ requires explicit schema permissions that weren't needed before
89+
if is_this_installed postgresql-common
90+
then
91+
# Get database info
92+
ncdb
93+
94+
# Check if we need to apply the fix (test if user can create tables)
95+
if sudo -u postgres psql -d "$NCDB" -c "SELECT has_schema_privilege('$NCUSER', 'public', 'CREATE');" 2>/dev/null | grep -q "f"
96+
then
97+
print_text_in_color "$ICyan" "Applying PostgreSQL schema permission fix for Nextcloud 30+..."
98+
99+
# Apply the fix
100+
if sudo -u postgres psql -d "$NCDB" <<END
101+
GRANT CREATE ON SCHEMA public TO $NCUSER;
102+
GRANT ALL ON SCHEMA public TO $NCUSER;
103+
END
104+
then
105+
print_text_in_color "$IGreen" "PostgreSQL schema permissions updated successfully!"
106+
else
107+
print_text_in_color "$IYellow" "Warning: Could not update PostgreSQL schema permissions."
108+
print_text_in_color "$IYellow" "This may cause issues with Nextcloud 30+ upgrades."
109+
print_text_in_color "$ICyan" "You can try to fix this manually by running:"
110+
print_text_in_color "$ICyan" "sudo -u postgres psql -d $NCDB -c 'GRANT CREATE ON SCHEMA public TO $NCUSER;'"
111+
fi
112+
fi
113+
fi
114+
87115
# Set product name
88116
if home_sme_server
89117
then

0 commit comments

Comments
 (0)