我希望使用shell脚本在Mac OS上安装多个依赖项。这主要是一个软件的环境设置,我希望使用单个脚本完成,而不是分别运行它们。
目前我的脚本如下所示。我正在使用.command
扩展程序保存脚本文件,当我双击它时,它会安装Homebrew
但是,不会安装更多依赖项,即wine
和stunnel
。知道如何做到这一点?
非常感谢任何帮助。
#!/bin/bash
installCommandLineDevTools(){
if xcode-select --install 2>&1 | grep installed; then
echo command line tools already installed;
else
echo command line developer tools not installed;
echo installing command line tools;
fi
}
installHomeBrew(){
if which brew > /dev/null; then
echo Homebrew is installed
else
echo Homebrew is not installed.
echo Installing Homebrew....
ruby -e "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
}
installWine(){
if ! type which wine > /dev/null; then
echo install latest wine version
brew install wine
else
echo wine already installed;
fi
}
installStunnel(){
if ! type which stunnel > /dev/null; then
echo install latest stunnel
brew install stunnel
else
echo stunnel already installed;
fi
}
#Invoke your functions
installCommandLineTools
installHomeBrew
installWine
installStunnel
答案 0 :(得分:0)
因为道路上已经有葡萄酒或小洞。
在命令中
type which stunnel
which
没用了
可能是
! type stunnel
或
! which stunnel
或
! type stunnel && ! which stunnel