Add script to automatically installs the tmux with package manager based on the system type, both linux and macos are supported
This commit is contained in:
optimouskiller 2021-03-19 18:28:03 +08:00
parent d7c052d41d
commit ccedd18c3c
1 changed files with 45 additions and 0 deletions

View File

@ -24,3 +24,48 @@ fi
if ! type mockgen >/dev/null 2>&1; then
go get github.com/golang/mock/mockgen
fi
function Get_PM_Name()
{
PM=''
if [ "$(uname)" == "Darwin" ]; then
DISTRO='MacOS'
PM='brew'
elif grep -Eqii "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
DISTRO='CentOS'
PM='yum'
elif grep -Eqi "Red Hat Enterprise Linux Server" /etc/issue || grep -Eq "Red Hat Enterprise Linux Server" /etc/*-release; then
DISTRO='RHEL'
PM='yum'
elif grep -Eqi "Aliyun" /etc/issue || grep -Eq "Aliyun" /etc/*-release; then
DISTRO='Aliyun'
PM='yum'
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
DISTRO='Fedora'
PM='yum'
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
DISTRO='Debian'
PM='apt-get'
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
DISTRO='Ubuntu'
PM='apt-get'
elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then
DISTRO='Raspbian'
PM='apt-get'
else
DISTRO='unknow'
fi
print_blue "Your OS distribution is detected as: "$DISTRO;
eval "$1=$PM"
}
print_blue "===> 4. Install tmux with package manager"
PM_NAME=''
Get_PM_Name PM_NAME
if [ -n "$PM_NAME" ]; then
if [ "$PM_NAME" == "brew" ]; then
$PM_NAME install tmux
else
sudo $PM_NAME install -y tmux
fi
fi