Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Grigorev <sleuthhound@gmail.com>2026-01-03 05:37:48 +0300
committerGitHub <noreply@github.com>2026-01-03 05:37:48 +0300
commit3287fa4d80672f9f5fcf90e6059a190939445297 (patch)
tree0f55caef9541032253c71aeea7c7c36285c11799
parent1393f981bc313118b3ffde0b469cc07abdeb24c8 (diff)
Added EnvironmentFile to systemd unit (#3606)
* Added EnvironmentFile to systemd unit * Added support for older releases * Remove ARGS * Fixed copy unit * Fixed unit filename * Update update.sh
-rw-r--r--.github/workflows/release.yml6
-rw-r--r--install.sh13
-rwxr-xr-xupdate.sh19
-rw-r--r--x-ui.service.debian (renamed from x-ui.service)1
-rw-r--r--x-ui.service.rhel16
5 files changed, 50 insertions, 5 deletions
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 6c2a6989..563e1113 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -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
diff --git a/install.sh b/install.sh
index 1009f047..d3f15409 100644
--- a/install.sh
+++ b/install.sh
@@ -668,7 +668,18 @@ install_x-ui() {
rc-update add x-ui
rc-service x-ui start
else
- cp -f x-ui.service /etc/systemd/system/
+ 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
diff --git a/update.sh b/update.sh
index 6da238b1..021167c1 100755
--- a/update.sh
+++ b/update.sh
@@ -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.debian -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}"
@@ -677,8 +679,21 @@ update_x-ui() {
rc-update add x-ui >/dev/null 2>&1
rc-service x-ui start >/dev/null 2>&1
else
- echo -e "${green}Installing systemd unit...${plain}"
- cp -f x-ui.service /etc/systemd/system/ >/dev/null 2>&1
+ 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
diff --git a/x-ui.service b/x-ui.service.debian
index e911ef56..037f88bb 100644
--- a/x-ui.service
+++ b/x-ui.service.debian
@@ -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/
diff --git a/x-ui.service.rhel b/x-ui.service.rhel
new file mode 100644
index 00000000..30652d52
--- /dev/null
+++ b/x-ui.service.rhel
@@ -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