From c3ebd755b9e0b042b06ade6daaeacbf39a86895e Mon Sep 17 00:00:00 2001 From: IceCodeNew <32576256+IceCodeNew@users.noreply.github.com> Date: Fri, 25 Sep 2020 14:29:53 +0800 Subject: [PATCH 1/3] Introduce a more convenient way to detect systemd Refer: https://manpages.ubuntu.com/manpages/focal/en/man3/sd_booted.3.html --- install-release.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/install-release.sh b/install-release.sh index 4aec23e..96597c7 100644 --- a/install-release.sh +++ b/install-release.sh @@ -93,7 +93,14 @@ identify_the_operating_system_and_architecture() { echo "error: Don't use outdated Linux distributions." exit 1 fi - if [[ -z "$(ls -l /sbin/init | grep systemd)" ]]; then + # Do not combine this judgment condition with the following judgment condition. + ## Be aware of Linux distribution like Gentoo, which kernel supports switch between Systemd and OpenRC. + ### Refer: https://github.com/v2fly/fhs-install-v2ray/issues/84#issuecomment-688574989 + if [[ -f /.dockerenv ]] || grep -q 'docker\|lxc' /proc/1/cgroup && [[ "$(type -P systemctl)" ]]; then + true + elif [[ -d /run/systemd/system ]] || grep -q systemd <(ls -l /sbin/init); then + true + else echo "error: Only Linux distributions using systemd are supported." exit 1 fi From 8e5c2e067f246800d90ab909b57c79798a432f5a Mon Sep 17 00:00:00 2001 From: IceCodeNew <32576256+IceCodeNew@users.noreply.github.com> Date: Fri, 25 Sep 2020 15:16:06 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=A8=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E9=A2=84=E8=A3=85=20`curl`=20=E7=9A=84=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E4=B8=8A=E8=84=9A=E6=9C=AC=E4=BC=9A=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install-release.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/install-release.sh b/install-release.sh index 96597c7..7bdbee4 100644 --- a/install-release.sh +++ b/install-release.sh @@ -28,7 +28,7 @@ green=$(tput setaf 2) reset=$(tput sgr0) curl() { - $(type -P curl) -L -q --retry 5 --retry-delay 10 --retry-max-time 60 "$@" + $(type -P curl) -L -q --retry 5 --retry-delay 10 --retry-max-time 60 "$@" } check_if_running_as_root() { @@ -108,8 +108,8 @@ identify_the_operating_system_and_architecture() { PACKAGE_MANAGEMENT_INSTALL='apt install -y --no-install-recommends' PACKAGE_MANAGEMENT_REMOVE='apt purge' elif [[ "$(type -P dnf)" ]]; then - PACKAGE_MANAGEMENT_INSTALL='dnf install -y' - PACKAGE_MANAGEMENT_REMOVE='dnf remove' + PACKAGE_MANAGEMENT_INSTALL='dnf install -y' + PACKAGE_MANAGEMENT_REMOVE='dnf remove' elif [[ "$(type -P yum)" ]]; then PACKAGE_MANAGEMENT_INSTALL='yum install -y' PACKAGE_MANAGEMENT_REMOVE='yum remove' @@ -180,7 +180,7 @@ judgment_parameters() { install_software() { COMPONENT="$1" - command -v "$COMPONENT" > /dev/null 2>&1 && return + type -P "$COMPONENT" > /dev/null 2>&1 && return if ${PACKAGE_MANAGEMENT_INSTALL} "$COMPONENT"; then echo "info: $COMPONENT is installed." else @@ -219,7 +219,6 @@ get_version() { fi # Get V2Ray release version number TMP_FILE="$(mktemp)" - install_software curl # DO NOT QUOTE THESE `${PROXY}` VARIABLES! if ! curl ${PROXY} -sS -H "Accept: application/vnd.github.v3+json" -o "$TMP_FILE" 'https://api.github.com/repos/v2fly/v2ray-core/releases/latest'; then "rm" "$TMP_FILE" @@ -502,6 +501,7 @@ main() { decompression "$LOCAL_FILE" else # Normal way + install_software curl get_version NUMBER="$?" if [[ "$NUMBER" -eq '0' ]] || [[ "$FORCE" -eq '1' ]] || [[ "$NUMBER" -eq 2 ]]; then From 3540fe109c60b52f201dffae0f44d9666b1f9cbc Mon Sep 17 00:00:00 2001 From: IceCodeNew <32576256+IceCodeNew@users.noreply.github.com> Date: Fri, 25 Sep 2020 15:56:39 +0800 Subject: [PATCH 3/3] assume yes to remove action; sync repo while installing package Fix https://github.com/v2fly/fhs-install-v2ray/pull/141/checks?check_run_id=1164621937 --- install-release.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/install-release.sh b/install-release.sh index 7bdbee4..460bd89 100644 --- a/install-release.sh +++ b/install-release.sh @@ -106,19 +106,19 @@ identify_the_operating_system_and_architecture() { fi if [[ "$(type -P apt)" ]]; then PACKAGE_MANAGEMENT_INSTALL='apt install -y --no-install-recommends' - PACKAGE_MANAGEMENT_REMOVE='apt purge' + PACKAGE_MANAGEMENT_REMOVE='apt purge -y --auto-remove' elif [[ "$(type -P dnf)" ]]; then PACKAGE_MANAGEMENT_INSTALL='dnf install -y' - PACKAGE_MANAGEMENT_REMOVE='dnf remove' + PACKAGE_MANAGEMENT_REMOVE='dnf remove -y' elif [[ "$(type -P yum)" ]]; then PACKAGE_MANAGEMENT_INSTALL='yum install -y' - PACKAGE_MANAGEMENT_REMOVE='yum remove' + PACKAGE_MANAGEMENT_REMOVE='yum remove -y' elif [[ "$(type -P zypper)" ]]; then - PACKAGE_MANAGEMENT_INSTALL='zypper install -y' - PACKAGE_MANAGEMENT_REMOVE='zypper remove' + PACKAGE_MANAGEMENT_INSTALL='zypper install -y --no-recommends' + PACKAGE_MANAGEMENT_REMOVE='zypper remove -yu' elif [[ "$(type -P pacman)" ]]; then - PACKAGE_MANAGEMENT_INSTALL='pacman -S --noconfirm' - PACKAGE_MANAGEMENT_REMOVE='pacman -R' + PACKAGE_MANAGEMENT_INSTALL='pacman -Syu --noconfirm' + PACKAGE_MANAGEMENT_REMOVE='pacman -Rsun --noconfirm' else echo "error: The script does not support the package manager in this operating system." exit 1