update-git-hooks 589 B

12345678910111213141516171819
  1. #!/usr/bin/env bash
  2. # This script will update the post-receive hooks of multiple bare git repos
  3. #
  4. for i in /var/lib/git/gogs-repositories/bryan/*/hooks/post-receive; do
  5. # Get repo name
  6. rn="${i%/hooks/post-receive}"
  7. rn="${rn##*/}"
  8. # Don't duplicate the line if it already exists
  9. while IFS= read -r line; do
  10. [[ "$line" == "git push --mirror git@github.com:cryobry/${rn}" ]] && continue
  11. done < "$i"
  12. # Append the line
  13. #echo "git push --mirror git@github.com:cryobry/${rn} to $i"
  14. echo "git push --mirror git@github.com:cryobry/${rn}" >> "$i"
  15. done