.dotfiles/helpers/installer.sh

36 lines
632 B
Bash
Raw Normal View History

2020-11-08 21:55:05 +01:00
isInstalled() {
if [ "$(which $1)" != "" ]; then
return 0
fi
return 1
}
installOptional() {
echo "install optional '$*'"
# Check if any of the listed programs are installed
# if not install the first one;
for prog in "$@"; do
if isInstalled $prog; then
echo "$prog is installed"
break
fi
done
install $1
}
install() {
# Check if program is already installed
if isInstalled $1; then
2021-06-22 13:05:12 +02:00
echo "$1 is already installed"
2020-11-08 21:55:05 +01:00
else
echo " - installing $1 ..."
apt-get install $1 -y >/dev/null
2021-06-22 13:05:12 +02:00
echo " ✓ finished"
2020-11-08 21:55:05 +01:00
fi
}
[[ "${1}" != "--source-only" ]] && install "${@}"