Skip to content

Commit

Permalink
switch from command to type; put dnf ahead of yum; assume yes
Browse files Browse the repository at this point in the history
0. command -v could return an alias while type -P will force a PATH search
1. There are distribution that has aliases for `apt` or `yum` while its prefer package manager is not `apt` nor ``yum
2. Assume yes for the call we made to all kind of package managers
  • Loading branch information
IceCodeNew committed Sep 24, 2020
1 parent ae9e64f commit e574e2a
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions install-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down

0 comments on commit e574e2a

Please sign in to comment.