Merge pull request #139 from v2fly/develop

switch from `command` to `type`; put `dnf` ahead of `yum`; assume yes
pull/148/head
IceCodeNew 2020-09-25 00:27:42 +08:00 committed by GitHub
commit 00226173ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 13 deletions

View File

@ -97,21 +97,20 @@ identify_the_operating_system_and_architecture() {
echo "error: Only Linux distributions using systemd are supported."
exit 1
fi
if [[ "$(command -v apt)" ]]; then
PACKAGE_MANAGEMENT_INSTALL='apt install'
PACKAGE_MANAGEMENT_REMOVE='apt remove'
elif [[ "$(command -v yum)" ]]; then
PACKAGE_MANAGEMENT_INSTALL='yum install'
PACKAGE_MANAGEMENT_REMOVE='yum remove'
if [[ "$(command -v dnf)" ]]; then
PACKAGE_MANAGEMENT_INSTALL='dnf install'
if [[ "$(type -P apt)" ]]; then
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'
fi
elif [[ "$(command -v zypper)" ]]; then
PACKAGE_MANAGEMENT_INSTALL='zypper install'
elif [[ "$(type -P yum)" ]]; then
PACKAGE_MANAGEMENT_INSTALL='yum install -y'
PACKAGE_MANAGEMENT_REMOVE='yum remove'
elif [[ "$(type -P zypper)" ]]; then
PACKAGE_MANAGEMENT_INSTALL='zypper install -y'
PACKAGE_MANAGEMENT_REMOVE='zypper remove'
elif [[ "$(command -v pacman)" ]]; then
PACKAGE_MANAGEMENT_INSTALL='pacman -S'
elif [[ "$(type -P pacman)" ]]; then
PACKAGE_MANAGEMENT_INSTALL='pacman -S --noconfirm'
PACKAGE_MANAGEMENT_REMOVE='pacman -R'
else
echo "error: The script does not support the package manager in this operating system."