I have a Mercurial repository set up on a Linux server, and some (but not all) users have permission to push to it. They connect to the repository over ssh.
These users are members of a unix group together. Below is the script I'm using to alter a repository to allow it to receive pushes from them.
Can this be improved? Are there unnecessary operations in here? Is anything bad style for a bash
script?
#!/bin/bash
if [[ $# -lt 2 ]]; then
echo Usage: $0 directory groupname
exit 1
fi
if ! chown -R :$2 $1; then
echo chown failure
exit 2
fi
if ! find $1/.hg -type d -exec chmod g+s {} \;; then
echo chmod failure
exit 3
fi
if ! find $1 -perm -u+r -exec chmod g+r {} \;; then
echo chmod failure 2
exit 4
fi
if ! find $1 -perm -u+w -exec chmod g+w {} \;; then
echo chmod failure 3
exit 5
fi
if ! find $1 -perm -u+x -exec chmod g+x {} \;; then
echo chmod failure 4
exit 6
fi