summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-02-03 08:32:34 -0800
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-02-03 08:32:34 -0800
commitb5329487161e9bbe4d95c69563f8b13ca4ea43c9 (patch)
treea523bc861c844ab5bd63c04734055013e4330df6
parent56e216f33ca0db21336cc8dc1f7e09a834267772 (diff)
parentf457f974d052ca50c808bd73582985818c605474 (diff)
downloadgitlab-shell-b5329487161e9bbe4d95c69563f8b13ca4ea43c9.tar.gz
Merge pull request #93 from raphendyr/patch-3
Remove hard coded home
-rwxr-xr-xsupport/rewrite-hooks.sh22
1 files changed, 8 insertions, 14 deletions
diff --git a/support/rewrite-hooks.sh b/support/rewrite-hooks.sh
index 3c96b6f..e2ebb91 100755
--- a/support/rewrite-hooks.sh
+++ b/support/rewrite-hooks.sh
@@ -3,25 +3,19 @@
# $1 is an optional argument specifying the location of the repositories directory.
# Defaults to /home/git/repositories if not provided
-home_dir="/home/git"
-src=${1:-"$home_dir/repositories"}
+src=${1:-"$HOME/repositories"}
function create_link_in {
- ln -s -f "$home_dir/gitlab-shell/hooks/update" "$1/hooks/update"
+ ln -s -f "$HOME/gitlab-shell/hooks/update" "$1/hooks/update"
}
-for dir in `ls "$src/"`
-do
- if [ -d "$src/$dir" ]; then
- if [[ "$dir" =~ ^.*\.git$ ]]
- then
- create_link_in "$src/$dir"
+for dir in "$src/"*; do
+ if [ -d "$dir" ]; then
+ if [ "$dir" != "${dir%.git}" ]; then
+ create_link_in "$dir"
else
- for subdir in `ls "$src/$dir/"`
- do
- if [ -d "$src/$dir/$subdir" ] && [[ "$subdir" =~ ^.*\.git$ ]]; then
- create_link_in "$src/$dir/$subdir"
- fi
+ for subdir in "$dir/"*.git; do
+ create_link_in "$subdir"
done
fi
fi