All,
I would like to invoke a bash script (to do some rsync magic) towards the end of my post-commit hook.
Here is what my post commit hook looks like:
#!/bin/bash REPOS="$1" REV="$2" SVNLOOK="/usr/bin/svnlook" AWK="/usr/bin/awk" temp_dir="/var/www/vhosts/domain.com/temp"$(date +"%s") # to avoid conflict, append unix timestamp webroot_dev="/var/www/vhosts/domain.com/dev.project.com" webroot_alpha="/var/www/vhosts/domain.com/alpha.project.com" webroot_beta="/var/www/vhosts/domain.com/beta.project.com" webroot_live="/var/www/vhosts/domain.com/project.com" repo_dev="file:///var/svn/Echo/branches/Dev" repo_alpha="file:///var/svn/Echo/trunk" repo_beta="file:///var/svn/Echo/branches/Beta" repo_live="file:///var/svn/Echo/branches/Live" is_dev=`$SVNLOOK dirs-changed -r "$REV" "$REPOS" | grep -c "Dev"` is_alpha=`$SVNLOOK dirs-changed -r "$REV" "$REPOS" | grep -c "trunk"` is_beta=`$SVNLOOK dirs-changed -r "$REV" "$REPOS" | grep -c "Beta"` is_live=`$SVNLOOK dirs-changed -r "$REV" "$REPOS" | grep -c "Live"` # Export from svn to web root; save previous version in ???.project.com.bkp if [ $is_dev -gt 0 ]; then rev="$SVNLOOK youngest $repo_dev"; svn export "$repo_dev" "$temp_dir" --force rm -rf "${webroot_dev}.bkp" mv -f "${webroot_dev}/" "${webroot_dev}.bkp" mv -f "$temp_dir" "$webroot_dev" date +%s > "${webroot_dev}/public/ex/config/version.txt" cp "/usr/local/bin/scripts/releases/override.dev.ini" "${webroot_dev}/public/ex/config/ini/override.ini" chown -R apache:apache "$webroot_dev" chown -R apache:apache "${webroot_dev}.bkp" cp -p -R "${webroot_dev}.bkp/public/uploads/avatars" "${webroot_dev}/public/uploads" sh /var/svn/Echo/hooks/testing.sh # -- THIS IS WHAT FAILS elif [ $is_alpha -gt 0 ]; then svn export "$repo_alpha" "$temp_dir" --force rm -rf "${webroot_alpha}.bkp" mv -f "${webroot_alpha}/" "${webroot_alpha}.bkp" mv -f "$temp_dir" "$webroot_alpha" date +%s > "${webroot_alpha}/public/ex/config/version.txt" chown -R apache:apache "$webroot_alpha" chown -R apache:apache "${webroot_alpha}.bkp" cp -p -R "${webroot_alpha}.bkp/public/uploads/avatars" "${webroot_alpha}/public/uploads" elif [ $is_beta -gt 0 ]; then : elif [ $is_live -gt 0 ]; then : fi
The script I am trying to call is "testing.sh", here is what the code looks like:
#!/bin/bash rsync -rtvu --cvs-exclude --delete /var/www/vhosts/domain.com/dev.project.com/ -e "ssh -i /var/svn/Project/hooks/testing.pem" ec2-user@ipaddress:/home/ec2-user/testing/
The error I am getting is the following:
post-commit hook failed (exit code 255) with output: Host key verification failed. rsync: connection unexpectedly closed (0 bytes received so far) [sender] rsync error: unexplained error (code 255) at io.c(463) [sender=2.6.8]
Update: This all works fine if I execute testing.sh manually from the same location. The host key error is only reported when the bash script is executed via the post-commit hook.
-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
as thessh
argument to deal with the prompt.