Last active
August 29, 2015 14:23
-
-
Save schubert/70b3c3e23d30e8fc690b to your computer and use it in GitHub Desktop.
hawq-checkman-bootstrap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CHECKMAN_INTERVAL=30 # Seconds between running checks | |
CHECKMAN_VERSION=25d77c1 | |
get_ci_infrastructure_repo() { | |
mkdir -p ~/workspace/ | |
if [ ! -e ~/workspace/ci-infrastructure ]; then | |
git clone [email protected]:Pivotal-DataFabric/ci-infrastructure.git ~/workspace/ci-infrastructure | |
else | |
pushd ~/workspace/ci-infrastructure | |
git pull -r | |
popd | |
echo "CI Infrastructure available and updated" | |
fi | |
} | |
get_checkman_aggregate_repo() { | |
if [ ! -e ~/workspace/checkman-aggregate ]; then | |
git clone [email protected]:Pivotal-DataFabric/checkman-aggregate.git ~/workspace/checkman-aggregate | |
else | |
pushd ~/workspace/checkman-aggregate | |
git pull -r | |
popd | |
echo "checkman-aggregate available and updated" | |
fi | |
} | |
get_pulse_checkman_repo() { | |
if [ ! -e ~/workspace/pulse-checkman ]; then | |
git clone [email protected]:Pivotal-DataFabric/pulse-checkman.git ~/workspace/pulse-checkman | |
else | |
pushd ~/workspace/pulse-checkman | |
git pull -r | |
popd | |
echo "pulse-checkman available and updated" | |
fi | |
} | |
install_checkman() { | |
if [ -e /Applications/Checkman.app/Contents/Info.plist ]; then | |
installed_checkman_version=$(/usr/libexec/PlistBuddy -c "Print 'Git SHA'" /Applications/Checkman.app/Contents/Info.plist) | |
if [ "${installed_checkman_version}" = "${CHECKMAN_VERSION}" ]; then | |
echo "Already have latest checkman installed, skipping" | |
skip_install=1 | |
fi | |
fi | |
if [ "${skip_install}" != 1 ]; then | |
curl https://raw.githubusercontent.com/cppforlife/checkman/master/bin/install > /tmp/checkman_install.sh | |
bash /tmp/checkman_install.sh | |
if [ $? != 0 ]; then | |
echo "Error installing checkman." | |
exit 1 | |
fi | |
rm -f ~/Checkman/example | |
fi | |
} | |
set_up_jenkins_check() { | |
pushd ~/workspace/ci-infrastructure/checkman | |
if [ -e /Applications/Checkman.app/Contents/Resources/jenkins_build.check.orig ]; then | |
cp -f /Applications/Checkman.app/Contents/Resources/jenkins_build.check.orig /Applications/Checkman.app/Contents/Resources/jenkins_build.check | |
else | |
cp -f /Applications/Checkman.app/Contents/Resources/jenkins_build.check /Applications/Checkman.app/Contents/Resources/jenkins_build.check.orig | |
fi | |
patch -t /Applications/Checkman.app/Contents/Resources/jenkins_build.check jenkins_build.check.patch | |
popd | |
} | |
configure_checkman_defaults() { | |
defaults write com.tomato.Checkman checkRunInterval -int $CHECKMAN_INTERVAL | |
stickies_setting=$(defaults read com.tomato.Checkman stickies.disabled || echo false) | |
if [ "${stickies_setting}" = "false" ]; then | |
defaults write com.tomato.Checkman stickies.disabled -bool YES | |
fi | |
} | |
link_checkfiles() { | |
mkdir -p ~/Checkman/ | |
shopt -s dotglob | |
for filepath in ~/workspace/ci-infrastructure/checkman/checkfiles/*; do | |
[[ -e $filepath ]] || break | |
local filename | |
filename=$(basename "$filepath") | |
if [ -f "$HOME/Checkman/.$filename" ] || [ -h "$HOME/Checkman/.$filename" ] ; then | |
if [ -f "$HOME/Checkman/$filename" ] || [ -h "$HOME/Checkman/$filename" ] ; then | |
echo "ALERT: you have similar files in ~/Checkman named $filename and .$filename: one is hidden. Links neither created nor updated for these." | |
else | |
ln -hf "$filepath" "$HOME/Checkman/.$filename" | |
echo "checkfile $filename already linked and hidden. Keeping hidden" | |
fi | |
else | |
shasum1=$(shasum "$filepath" | cut -f 1 -d ' ') | |
shasum2=$(shasum "$HOME/Checkman/$filename" | cut -f 1 -d ' ') | |
if [ "${shasum1}" = "${shasum2}" ]; then | |
echo "Checfile $filename is the same as $HOME/Checkman/$filename, skipping re-link." | |
else | |
ln -hf "$filepath" "$HOME/Checkman/$filename" | |
echo "Checkfile $filename linked from CI Infrastructure to Checkman/" | |
fi | |
fi | |
done | |
} | |
_main() { | |
get_ci_infrastructure_repo | |
get_checkman_aggregate_repo | |
get_pulse_checkman_repo | |
install_checkman | |
set_up_jenkins_check | |
configure_checkman_defaults | |
link_checkfiles | |
} | |
_main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment