From 947fd4fae109503fcc00a21991a51de0e7f392db Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Sat, 3 Jan 2026 07:27:39 +0100 Subject: fix --- install.sh | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 56 insertions(+), 7 deletions(-) (limited to 'install.sh') diff --git a/install.sh b/install.sh index 4dba8f17..efa4d535 100644 --- a/install.sh +++ b/install.sh @@ -671,21 +671,70 @@ install_x-ui() { rc-update add x-ui rc-service x-ui start else + # Install systemd service file + service_installed=false + if [ -f "x-ui.service" ]; then - cp -f x-ui.service ${xui_service}/ - else + echo -e "${green}Found x-ui.service in extracted files, installing...${plain}" + cp -f x-ui.service ${xui_service}/ >/dev/null 2>&1 + if [[ $? -eq 0 ]]; then + service_installed=true + fi + fi + + if [ "$service_installed" = false ]; then + case "${release}" in + ubuntu | debian | armbian) + if [ -f "x-ui.service.debian" ]; then + echo -e "${green}Found x-ui.service.debian in extracted files, installing...${plain}" + cp -f x-ui.service.debian ${xui_service}/x-ui.service >/dev/null 2>&1 + if [[ $? -eq 0 ]]; then + service_installed=true + fi + fi + ;; + *) + if [ -f "x-ui.service.rhel" ]; then + echo -e "${green}Found x-ui.service.rhel in extracted files, installing...${plain}" + cp -f x-ui.service.rhel ${xui_service}/x-ui.service >/dev/null 2>&1 + if [[ $? -eq 0 ]]; then + service_installed=true + fi + fi + ;; + esac + fi + + # If service file not found in tar.gz, download from GitHub + if [ "$service_installed" = false ]; then + echo -e "${yellow}Service files not found in tar.gz, downloading from GitHub...${plain}" case "${release}" in ubuntu | debian | armbian) - cp -f x-ui.service.debian ${xui_service}/x-ui.service + curl -4fLRo ${xui_service}/x-ui.service https://raw.githubusercontent.com/MHSanaei/3x-ui/main/x-ui.service.debian >/dev/null 2>&1 ;; *) - cp -f x-ui.service.rhel ${xui_service}/x-ui.service + curl -4fLRo ${xui_service}/x-ui.service https://raw.githubusercontent.com/MHSanaei/3x-ui/main/x-ui.service.rhel >/dev/null 2>&1 ;; esac + + if [[ $? -ne 0 ]]; then + echo -e "${red}Failed to install x-ui.service from GitHub${plain}" + exit 1 + fi + service_installed=true + fi + + if [ "$service_installed" = true ]; then + echo -e "${green}Setting up systemd unit...${plain}" + chown root:root ${xui_service}/x-ui.service >/dev/null 2>&1 + chmod 644 ${xui_service}/x-ui.service >/dev/null 2>&1 + systemctl daemon-reload + systemctl enable x-ui + systemctl start x-ui + else + echo -e "${red}Failed to install x-ui.service file${plain}" + exit 1 fi - systemctl daemon-reload - systemctl enable x-ui - systemctl start x-ui fi echo -e "${green}x-ui ${tag_version}${plain} installation finished, it is running now..." -- cgit v1.2.3