mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-01-11 16:22:45 +00:00
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
This commit is contained in:
parent
1393f981bc
commit
3287fa4d80
5 changed files with 50 additions and 5 deletions
6
.github/workflows/release.yml
vendored
6
.github/workflows/release.yml
vendored
|
|
@ -17,7 +17,8 @@ on:
|
||||||
- '**.go'
|
- '**.go'
|
||||||
- 'go.mod'
|
- 'go.mod'
|
||||||
- 'go.sum'
|
- 'go.sum'
|
||||||
- 'x-ui.service'
|
- 'x-ui.service.debian'
|
||||||
|
- 'x-ui.service.rhel'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
@ -78,7 +79,8 @@ jobs:
|
||||||
|
|
||||||
mkdir x-ui
|
mkdir x-ui
|
||||||
cp xui-release 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/
|
cp x-ui.sh x-ui/
|
||||||
mv x-ui/xui-release x-ui/x-ui
|
mv x-ui/xui-release x-ui/x-ui
|
||||||
mkdir x-ui/bin
|
mkdir x-ui/bin
|
||||||
|
|
|
||||||
13
install.sh
13
install.sh
|
|
@ -668,7 +668,18 @@ install_x-ui() {
|
||||||
rc-update add x-ui
|
rc-update add x-ui
|
||||||
rc-service x-ui start
|
rc-service x-ui start
|
||||||
else
|
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 daemon-reload
|
||||||
systemctl enable x-ui
|
systemctl enable x-ui
|
||||||
systemctl start x-ui
|
systemctl start x-ui
|
||||||
|
|
|
||||||
19
update.sh
19
update.sh
|
|
@ -615,6 +615,8 @@ update_x-ui() {
|
||||||
echo -e "${green}Removing old x-ui version...${plain}"
|
echo -e "${green}Removing old x-ui version...${plain}"
|
||||||
rm /usr/bin/x-ui -f >/dev/null 2>&1
|
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 -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 -f >/dev/null 2>&1
|
||||||
rm /usr/local/x-ui/x-ui.sh -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}"
|
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-update add x-ui >/dev/null 2>&1
|
||||||
rc-service x-ui start >/dev/null 2>&1
|
rc-service x-ui start >/dev/null 2>&1
|
||||||
else
|
else
|
||||||
echo -e "${green}Installing systemd unit...${plain}"
|
if [ -f "x-ui.service" ]; then
|
||||||
cp -f x-ui.service /etc/systemd/system/ >/dev/null 2>&1
|
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
|
chown root:root /etc/systemd/system/x-ui.service >/dev/null 2>&1
|
||||||
systemctl daemon-reload >/dev/null 2>&1
|
systemctl daemon-reload >/dev/null 2>&1
|
||||||
systemctl enable x-ui >/dev/null 2>&1
|
systemctl enable x-ui >/dev/null 2>&1
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ After=network.target
|
||||||
Wants=network.target
|
Wants=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
|
EnvironmentFile=-/etc/default/x-ui
|
||||||
Environment="XRAY_VMESS_AEAD_FORCED=false"
|
Environment="XRAY_VMESS_AEAD_FORCED=false"
|
||||||
Type=simple
|
Type=simple
|
||||||
WorkingDirectory=/usr/local/x-ui/
|
WorkingDirectory=/usr/local/x-ui/
|
||||||
16
x-ui.service.rhel
Normal file
16
x-ui.service.rhel
Normal 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
|
||||||
Loading…
Reference in a new issue