feat(bash): prompt for PostgreSQL (#4472)

* feat(install): prompt for SQLite vs PostgreSQL during install

* fix(install): write env file to per-distro path and handle pg-install failure

The env file was hardcoded to /etc/default/x-ui, but RHEL/Fedora units read
/etc/sysconfig/x-ui, Arch reads /etc/conf.d/x-ui, and Alpine OpenRC auto-
sources /etc/conf.d/x-ui. PostgreSQL selection was silently dropped on every
distro except Debian. Also initdb on openSUSE (service wouldn't start) and
prompt the operator on local-install failure instead of silently demoting
to SQLite.

* fix(scripts): make x-ui.sh and update.sh PostgreSQL-aware

update.sh ran setting -show and migrate without sourcing the env file, so
PostgreSQL users had migrations applied to the SQLite default and settings
introspection read the wrong DB. Sourcing the per-distro env file at the
start of update_x-ui exports XUI_DB_TYPE/XUI_DB_DSN to all binary calls.

x-ui.sh now shows the active backend in View Current Settings (password
masked) and removes the env file on uninstall so a later reinstall doesn't
inherit a stale DSN.
This commit is contained in:
Sanaei
2026-05-23 19:52:37 +02:00
committed by GitHub
parent 95aebf1d83
commit b71ed1e3ee
3 changed files with 205 additions and 0 deletions
+27
View File
@@ -105,6 +105,31 @@ gen_random_string() {
| head -c "$length"
}
xui_env_file_path() {
case "${release}" in
ubuntu | debian | armbian)
echo "/etc/default/x-ui"
;;
arch | manjaro | parch | alpine)
echo "/etc/conf.d/x-ui"
;;
*)
echo "/etc/sysconfig/x-ui"
;;
esac
}
load_xui_env() {
local env_file
env_file="$(xui_env_file_path)"
if [[ -r "$env_file" ]]; then
set -a
# shellcheck disable=SC1090
source "$env_file"
set +a
fi
}
install_base() {
echo -e "${green}Updating and install dependency packages...${plain}"
case "${release}" in
@@ -775,6 +800,8 @@ config_after_update() {
update_x-ui() {
cd ${xui_folder%/x-ui}/
load_xui_env
if [ -f "${xui_folder}/x-ui" ]; then
current_xui_version=$(${xui_folder}/x-ui -v)
echo -e "${green}Current x-ui version: ${current_xui_version}${plain}"