dotfiles/bin/software-install.sh

109 lines
2.9 KiB
Bash
Raw Normal View History

#!/bin/bash
function install_linux_software {
#-------------------------------
# Check the OS and set install command
#-------------------------------
if [ -x "$(which yum)" ]; then
INSTALLCMD="yum install -y"
elif [ -x "$(which apt-get)" ]; then
INSTALLCMD="apt-get install -y"
else
2016-02-18 07:01:05 +00:00
echo "Sorry, I don't know how to install software on this OS yet."
exit 1
fi
#-------------------------------
2016-02-07 18:39:49 +00:00
xargs sudo ${INSTALLCMD} <<-EOF
ack
2016-03-01 10:20:34 +00:00
archey
2016-02-29 11:52:27 +00:00
bash-completion
git
htop
mosh
2016-03-01 10:20:34 +00:00
nmap
2016-03-01 18:59:18 +00:00
p7zip
2016-03-01 10:23:04 +00:00
pv
ss
vim
EOF
}
function install_osx_software {
#-------------------------------
# Install Homebrew if missing
#-------------------------------
if [ ! -x /usr/local/bin/brew ]; then
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
#-------------------------------
# Update Brew formulae if older than 24 hours
find /usr/local/.git -name FETCH_HEAD -mtime +0 -exec brew update \;
# Install homebrew/bundle tap if we don't have it
[ -d /usr/local/Library/Taps/homebrew/homebrew-bundle ] || brew tap homebrew/bundle
#-------------------------------
# Run brew bundle if there's a newer version of Brewfile
#-------------------------------
if [ ~/Brewfile -nt ~/.Brewfile.updated ]; then
brew bundle && touch ~/.Brewfile.updated
fi
#-------------------------------
2016-02-09 08:30:03 +00:00
#-------------------------------
# Upgrade and clean
2016-02-09 08:30:03 +00:00
#-------------------------------
brew upgrade
2016-02-09 08:30:03 +00:00
brew cleanup
brew bundle check || ( cask-upgrade auto && cask-tidy )
brew cask cleanup
2016-02-09 08:30:03 +00:00
#-------------------------------
}
function __remove-cask {
caskBasePath="/opt/homebrew-cask/Caskroom"
local cask="$1"
local caskDirectory="$caskBasePath/$cask"
local versionsToRemove="$(ls -r $caskDirectory | sed 1,1d)"
if [[ -n $versionsToRemove ]]; then
while read versionToRemove ; do
echo "Removing $cask $versionToRemove..."
rm -rf "$caskDirectory/$versionToRemove"
done <<< "$versionsToRemove"
fi
}
function cask-tidy {
while read cask; do
__remove-cask "$cask"
done <<< "$(brew cask list)"
}
echo "#-------------------------------"
echo "# START: $(date)"
echo "#-------------------------------"
#-------------------------------
# Check for Mac OS X
#-------------------------------
if [ $(uname -s) == "Darwin" ]; then
install_osx_software
else
install_linux_software
fi
#-------------------------------
#-------------------------------
# Ensure Vim plugins are up-to-date
#-------------------------------
2016-03-11 10:12:04 +00:00
vim +PluginInstall! +PluginClean! +qall
#-------------------------------
echo "#-------------------------------"
echo "# END: $(date)"
echo "#-------------------------------"
exit 0