Last active
December 29, 2015 11:19
-
-
Save rochacon/7663162 to your computer and use it in GitHub Desktop.
Simple setup of git repository update hook to run Chef solo
This file contains 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 | |
if [[ $# -lt 2 ]]; then | |
echo "Usage: setup-git-push-deploy.sh hostname project" | |
exit 1; | |
fi | |
host="$1" | |
PROJECT="$2" | |
ssh -A "$host" <<EOF | |
set -e | |
echo -e 'Host github.com\n\tStrictHostKeyChecking no\n' >> ~/.ssh/config | |
git clone --bare git@github.com:$PROJECT.git | |
echo -e "#!/bin/bash\nsudo chef-solo -c \$HOME/chef-solo/solo.rb -j \$HOME/chef-solo/dna.json" > ~/$PROJECT.git/hooks/update | |
chmod +x ~/$PROJECT.git/hooks/update | |
echo 'Now run: git remote add <name> $USER@$host:~/$(basename $PROJECT).git' | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment