Compare commits

...

7 commits

Author SHA1 Message Date
Mikhail Grigorev
bd6d16de0c
Merge 94b9abca62 into 260eedf8c4 2025-12-29 11:19:34 +05:00
Wyatt
260eedf8c4
fix: add missing is_domain helper function to x-ui.sh (#3612)
Some checks failed
Release 3X-UI / build (386) (push) Has been cancelled
Release 3X-UI / build (amd64) (push) Has been cancelled
Release 3X-UI / build (arm64) (push) Has been cancelled
Release 3X-UI / build (armv5) (push) Has been cancelled
Release 3X-UI / build (armv6) (push) Has been cancelled
Release 3X-UI / build (armv7) (push) Has been cancelled
Release 3X-UI / build (s390x) (push) Has been cancelled
Release 3X-UI / Build for Windows (push) Has been cancelled
The is_domain function was being called in ssl_cert_issue() but was never
defined in x-ui.sh, causing 'Invalid domain format' errors for valid domains.

Added is_ipv4, is_ipv6, is_ip, and is_domain helper functions to match
the definitions in install.sh and update.sh.

Co-authored-by: wyatt <wyatt@Wyatts-MacBook-Air.local>
2025-12-28 16:38:26 +01:00
Mikhail Grigorev
94b9abca62 Fixed unit filename 2025-12-24 19:36:48 +05:00
Mikhail Grigorev
2a99726b6c Fixed copy unit 2025-12-22 11:17:40 +05:00
Mikhail Grigorev
cfccaa259c Remove ARGS 2025-12-19 18:24:51 +05:00
Mikhail Grigorev
420b4e49c9 Added support for older releases 2025-12-19 18:03:30 +05:00
Mikhail Grigorev
f5eab61903 Added EnvironmentFile to systemd unit 2025-12-19 17:56:31 +05:00
6 changed files with 64 additions and 5 deletions

View file

@ -17,7 +17,8 @@ on:
- '**.go'
- 'go.mod'
- 'go.sum'
- 'x-ui.service'
- 'x-ui.service.debian'
- 'x-ui.service.rhel'
jobs:
build:
@ -78,7 +79,8 @@ jobs:
mkdir x-ui
cp xui-release x-ui/
cp x-ui.service x-ui/
cp x-ui.service.debian x-ui/
cp x-ui.service.rhel x-ui/
cp x-ui.sh x-ui/
mv x-ui/xui-release x-ui/x-ui
mkdir x-ui/bin

View file

@ -653,7 +653,18 @@ install_x-ui() {
rc-update add x-ui
rc-service x-ui start
else
if [ -f "x-ui.service" ]; then
cp -f x-ui.service /etc/systemd/system/
else
case "${release}" in
ubuntu | debian | armbian)
cp -f x-ui.service.debian /etc/systemd/system/x-ui.service
;;
*)
cp -f x-ui.service.rhel /etc/systemd/system/x-ui.service
;;
esac
fi
systemctl daemon-reload
systemctl enable x-ui
systemctl start x-ui

View file

@ -615,6 +615,8 @@ update_x-ui() {
echo -e "${green}Removing old x-ui version...${plain}"
rm /usr/bin/x-ui -f >/dev/null 2>&1
rm /usr/local/x-ui/x-ui.service -f >/dev/null 2>&1
rm /usr/local/x-ui/x-ui.service.debain -f >/dev/null 2>&1
rm /usr/local/x-ui/x-ui.service.rhel -f >/dev/null 2>&1
rm /usr/local/x-ui/x-ui -f >/dev/null 2>&1
rm /usr/local/x-ui/x-ui.sh -f >/dev/null 2>&1
echo -e "${green}Removing old xray version...${plain}"
@ -676,8 +678,21 @@ update_x-ui() {
rc-update add x-ui >/dev/null 2>&1
rc-service x-ui start >/dev/null 2>&1
else
if [ -f "x-ui.service" ]; then
echo -e "${green}Installing systemd unit...${plain}"
cp -f x-ui.service /etc/systemd/system/ >/dev/null 2>&1
else
case "${release}" in
ubuntu | debian | armbian)
echo -e "${green}Installing debian-like systemd unit...${plain}"
cp -f x-ui.service.debian /etc/systemd/system/x-ui.service >/dev/null 2>&1
;;
*)
echo -e "${green}Installing rhel-like systemd unit...${plain}"
cp -f x-ui.service.rhel /etc/systemd/system/x-ui.service >/dev/null 2>&1
;;
esac
fi
chown root:root /etc/systemd/system/x-ui.service >/dev/null 2>&1
systemctl daemon-reload >/dev/null 2>&1
systemctl enable x-ui >/dev/null 2>&1

View file

@ -4,6 +4,7 @@ After=network.target
Wants=network.target
[Service]
EnvironmentFile=-/etc/default/x-ui
Environment="XRAY_VMESS_AEAD_FORCED=false"
Type=simple
WorkingDirectory=/usr/local/x-ui/

16
x-ui.service.rhel Normal file
View file

@ -0,0 +1,16 @@
[Unit]
Description=x-ui Service
After=network.target
Wants=network.target
[Service]
EnvironmentFile=-/etc/sysconfig/x-ui
Environment="XRAY_VMESS_AEAD_FORCED=false"
Type=simple
WorkingDirectory=/usr/local/x-ui/
ExecStart=/usr/local/x-ui/x-ui
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target

14
x-ui.sh
View file

@ -19,6 +19,20 @@ function LOGI() {
echo -e "${green}[INF] $* ${plain}"
}
# Simple helpers for domain/IP validation
is_ipv4() {
[[ "$1" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]] && return 0 || return 1
}
is_ipv6() {
[[ "$1" =~ : ]] && return 0 || return 1
}
is_ip() {
is_ipv4 "$1" || is_ipv6 "$1"
}
is_domain() {
[[ "$1" =~ ^([A-Za-z0-9](-*[A-Za-z0-9])*\.)+[A-Za-z]{2,}$ ]] && return 0 || return 1
}
# check root
[[ $EUID -ne 0 ]] && LOGE "ERROR: You must be root to run this script! \n" && exit 1