私はLinuxサーバにMercurialリポジトリを設定しましたが、一部のユーザ(すべてではない)がプッシュする権限を持っています。彼らはsshを介してリポジトリに接続します。UnixグループのメンバにMercurialを設定する
これらのユーザーは、一緒にUNIXグループのメンバーです。以下は私がリポジトリからプッシュを受け取れるようにリポジトリを変更するために使用しているスクリプトです。
これを改善できますか?ここに不必要な操作はありますか? bash
スクリプトに何か悪いスタイルがありますか?
#!/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
もっと新しいGNUが見つけました(これは比較的遅く実装されていますが、これは古くからPOSIXにあります)... "-exec .... {} +"を知っています。 xargsが行うことを効果的に実行します。 – TheBonsai
ACL拡張を指摘してくれてありがとう。私があなたのリンクから見つけた別のオプションは、mercurial-server(http://mercurial.selenic.com/wiki/SharedSSH)でした。私は今、私の脚本を、ジョン、TheBonsai、そしてあなたの変更と一緒に固執すると思います。 –