Skip to content

Commit

Permalink
fix: no systemd detected (#266)
Browse files Browse the repository at this point in the history
* fix: no systemd detected

* format

* fix ci for OpenSUSE

* drop ci for OpenSUSE

since the newer image does not come with the systemd; and the EOL OSes need extra hack to get the script work
  • Loading branch information
IceCodeNew authored Jan 17, 2023
1 parent b4035a8 commit 5b7125e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/sh-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ jobs:
sudo bash install-release.sh --check
sudo bash install-dat-release.sh
- name: Filed-test on Rocky Linux 8.6
uses: docker://rockylinux:8.6-minimal
with:
args: bash install-release.sh
- name: Filed-test on OpenSUSE 42.1
uses: docker://opensuse/archive:42.1
uses: docker://rockylinux:8.6
with:
args: bash install-release.sh
- name: Filed-test on Arch Linux
Expand Down
13 changes: 5 additions & 8 deletions install-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ install_software() {
}

get_current_version() {
if /usr/local/bin/v2ray -version >/dev/null 2>&1;then
if /usr/local/bin/v2ray -version > /dev/null 2>&1; then
VERSION="$(/usr/local/bin/v2ray -version | awk 'NR==1 {print $2}')"
else
VERSION="$(/usr/local/bin/v2ray version | awk 'NR==1 {print $2}')"
Expand Down Expand Up @@ -380,7 +380,7 @@ install_v2ray() {

install_startup_service_file() {
get_current_version
if [[ "$(echo "${CURRENT_VERSION#v}" | sed 's/-.*//' | awk -F'.' '{print $1}')" -gt "4" ]];then
if [[ "$(echo "${CURRENT_VERSION#v}" | sed 's/-.*//' | awk -F'.' '{print $1}')" -gt "4" ]]; then
START_COMMAND="/usr/local/bin/v2ray run"
else
START_COMMAND="/usr/local/bin/v2ray"
Expand All @@ -397,23 +397,20 @@ install_startup_service_file() {
[Service]
ExecStart=
ExecStart=${START_COMMAND} -confdir $JSONS_PATH" |
tee '/etc/systemd/system/v2ray.service.d/10-donot_touch_multi_conf.conf' > \
'/etc/systemd/system/[email protected]/10-donot_touch_multi_conf.conf'
tee '/etc/systemd/system/v2ray.service.d/10-donot_touch_multi_conf.conf' > '/etc/systemd/system/[email protected]/10-donot_touch_multi_conf.conf'
else
"rm" -f '/etc/systemd/system/v2ray.service.d/10-donot_touch_multi_conf.conf' \
'/etc/systemd/system/[email protected]/10-donot_touch_multi_conf.conf'
echo "# In case you have a good reason to do so, duplicate this file in the same directory and make your customizes there.
# Or all changes you made will be lost! # Refer: https://www.freedesktop.org/software/systemd/man/systemd.unit.html
[Service]
ExecStart=
ExecStart=${START_COMMAND} -config ${JSON_PATH}/config.json" > \
'/etc/systemd/system/v2ray.service.d/10-donot_touch_single_conf.conf'
ExecStart=${START_COMMAND} -config ${JSON_PATH}/config.json" > '/etc/systemd/system/v2ray.service.d/10-donot_touch_single_conf.conf'
echo "# In case you have a good reason to do so, duplicate this file in the same directory and make your customizes there.
# Or all changes you made will be lost! # Refer: https://www.freedesktop.org/software/systemd/man/systemd.unit.html
[Service]
ExecStart=
ExecStart=${START_COMMAND} -config ${JSON_PATH}/%i.json" > \
'/etc/systemd/system/[email protected]/10-donot_touch_single_conf.conf'
ExecStart=${START_COMMAND} -config ${JSON_PATH}/%i.json" > '/etc/systemd/system/[email protected]/10-donot_touch_single_conf.conf'
fi
echo "info: Systemd service files have been installed successfully!"
echo "${red}warning: ${green}The following are the actual parameters for the v2ray service startup."
Expand Down

0 comments on commit 5b7125e

Please sign in to comment.