aur/web.patch

133 lines
4.5 KiB
Diff

From 8c709312c74cfc1408139692943cc8590c7c5ed7 Mon Sep 17 00:00:00 2001
From: lzx3in <lzx3in@qunle.cc>
Date: Mon, 3 Nov 2025 14:11:48 +0800
Subject: [PATCH] add support for Arch Linux in web setup script
---
pkg/linux/setup-web.sh | 55 +++++++++++++++++++++++++++++++++++++-----
1 file changed, 49 insertions(+), 6 deletions(-)
diff --git a/pkg/linux/setup-web.sh b/pkg/linux/setup-web.sh
index a575db752..7c7f7e18a 100755
--- a/pkg/linux/setup-web.sh
+++ b/pkg/linux/setup-web.sh
@@ -17,6 +17,7 @@ fi
IS_REDHAT=0
IS_DEBIAN=0
IS_SUSE=0
+IS_ARCH=0
UNAME=$(uname -a)
# Get the distro from the environment
@@ -29,10 +30,15 @@ if [ "${PGADMIN_PLATFORM_TYPE}" == "" ]; then
if grep suse /etc/os-release > /dev/null
then
PLATFORM_TYPE=suse
+ elif grep -q -E "ID=arch|ID=archlinux" /etc/os-release; then
+ PLATFORM_TYPE=arch
+ else
+ echo "Failed to detect the platform from /etc/os-release. Unsupported distribution."
+ exit 1
fi
else
echo "Failed to detect the platform. This may mean you're running on a Linux distribution that isn't supported by pgAdmin."
- echo "Please set the PGADMIN_PLATFORM_TYPE environment variable to one of 'redhat' or 'debian' and try again."
+ echo "Please set the PGADMIN_PLATFORM_TYPE environment variable to one of 'redhat', 'debian', 'suse', or 'arch' and try again."
exit 1
fi
else
@@ -44,21 +50,34 @@ case ${PLATFORM_TYPE} in
echo "Setting up pgAdmin 4 in web mode on a Redhat based platform..."
IS_REDHAT=1
APACHE=httpd
+ APACHE_CONF_DIR="/etc/httpd/conf.d"
+ APACHE_CTL=apachectl
;;
debian)
echo "Setting up pgAdmin 4 in web mode on a Debian based platform..."
IS_DEBIAN=1
APACHE=apache2
+ APACHE_CONF_DIR="/etc/apache2/conf-available"
+ APACHE_CTL=apache2ctl
;;
suse)
echo "Setting up pgAdmin 4 in web mode on a SUSE based platform..."
IS_SUSE=1
APACHE=apache2
+ APACHE_CONF_DIR="/etc/apache2/conf.d"
+ APACHE_CTL=apache2ctl
+ ;;
+ arch)
+ echo "Setting up pgAdmin 4 in web mode on an Arch Linux based platform..."
+ IS_ARCH=1
+ APACHE=httpd
+ APACHE_CONF_DIR="/etc/httpd/conf/extra"
+ APACHE_CTL=apachectl
+ mkdir -p ${APACHE_CONF_DIR}
;;
-
*)
- echo "Invalid value for the PGADMIN_PLATFORM_TYPE environment variable. Please set it to one of 'redhat' or 'debian' and try again."
+ echo "Invalid value for the PGADMIN_PLATFORM_TYPE environment variable. Please set it to one of 'redhat', 'debian', 'suse', or 'arch' and try again."
exit 1
;;
esac
@@ -86,11 +105,13 @@ if [ ${IS_REDHAT} == 1 ]; then
chown apache: /var/log/pgadmin /var/lib/pgadmin -R
elif [ ${IS_SUSE} == 1 ]; then
chown wwwrun: /var/log/pgadmin /var/lib/pgadmin -R
+elif [ ${IS_ARCH} == 1 ]; then
+ chown http:http /var/log/pgadmin /var/lib/pgadmin -R
else
chown www-data: /var/log/pgadmin /var/lib/pgadmin -R
fi
-# Set SELinux up:
+# Set SELinux up (only RedHat)
if [ ${IS_REDHAT} == 1 ]; then
echo "Configuring SELinux..."
setsebool -P httpd_tmp_exec 1 1> /dev/null
@@ -102,8 +123,24 @@ if [ ${IS_REDHAT} == 1 ]; then
restorecon -R -v /var/log/pgadmin 1> /dev/null
fi
-# Setup Apache on Debian/Ubuntu
-if [ ${IS_DEBIAN} == 1 ]; then
+# Setup Apache
+echo "Configuring Apache for pgAdmin 4..."
+
+if [ ${IS_ARCH} == 1 ]; then
+ echo "Setting up Apache configuration for Arch Linux..."
+
+ echo "Enabling required Apache modules..."
+ if [ -f "/etc/httpd/conf/httpd.conf" ]; then
+ if ! grep -q "LoadModule wsgi_module" /etc/httpd/conf/httpd.conf; then
+ echo "LoadModule wsgi_module modules/mod_wsgi.so" >> /etc/httpd/conf/httpd.conf
+ fi
+
+ if ! grep -q "Include conf/extra/pgadmin4.conf" /etc/httpd/conf/httpd.conf; then
+ echo "Include conf/extra/pgadmin4.conf" >> /etc/httpd/conf/httpd.conf
+ fi
+ fi
+
+elif [ ${IS_DEBIAN} == 1 ]; then
if [ ${AUTOMATED} == 1 ]; then
RESPONSE=Y
else
@@ -120,6 +157,12 @@ if [ ${IS_DEBIAN} == 1 ]; then
esac
fi
+echo "Validating Apache configuration..."
+if ! ${APACHE_CTL} configtest; then
+ echo "Error: Apache configuration test failed. Please check the configuration files."
+ exit 1
+fi
+
if pgrep ${APACHE} > /dev/null; then
if [ ${AUTOMATED} == 1 ]; then
RESPONSE=Y
--
2.51.1