update-git-hooks 593 B

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