Skip to content

Instantly share code, notes, and snippets.

@rochacon
Last active December 29, 2015 11:19
Show Gist options
  • Save rochacon/7663162 to your computer and use it in GitHub Desktop.
Save rochacon/7663162 to your computer and use it in GitHub Desktop.
Simple setup of git repository update hook to run Chef solo
#!/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