aboutsummaryrefslogtreecommitdiff
path: root/server/mkrepo
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-10-17 17:25:09 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-10-17 17:25:09 +0200
commit19ff8ac28a266b60d28cf3d9cf7464ac79836480 (patch)
tree4a0c4b96e775cd2b08d9aad4a239184e6e0020d9 /server/mkrepo
parent6d5f1b3ccd7faff3b18f5e7a8b41d33a0c5592ab (diff)
Cleanup mkrepo, mrrepo scripts
Diffstat (limited to 'server/mkrepo')
-rwxr-xr-xserver/mkrepo60
1 files changed, 29 insertions, 31 deletions
diff --git a/server/mkrepo b/server/mkrepo
index f372d2e..82eaa4a 100755
--- a/server/mkrepo
+++ b/server/mkrepo
@@ -2,34 +2,33 @@
# Create remote git repository (on the server). You must run this script from
# the "repositories root" (e.g., /var/scm) where you want the repository to be
-# created. If the repository is public, also add it to the manifest file (used
-# for mirroring).
-#
-# Usage: mkrepo [<options>] <name>
+# created (including any subdirectories). If the repository is public, also
+# add it to the manifest file (used for mirroring).
#
# --private
# make the repository private
#
# Note: <name> is without the .git suffix.
#
-trap 'exit 1' ERR
+usage="usage: $0 [--private] <name>"
+
+owd="$(pwd)"
+trap "{ cd '$owd'; exit 1; }" ERR
+set -o errtrace # Trap in functions.
-function error ()
-{
- echo "$*" 1>&2
-}
+function info () { echo "$*" 1>&2; }
+function error () { info "$*"; exit 1; }
-public=y
+public="y"
-while [ $# -gt 0 ]; do
- case $1 in
+while [ "$#" -gt "0" ]; do
+ case "$1" in
--private)
- public=n
+ public="n"
shift
;;
-*)
error "unknown option: $1"
- exit 1
;;
*)
break
@@ -37,36 +36,35 @@ while [ $# -gt 0 ]; do
esac
done
-if [ "$1" = "" ]; then
+if [ -z "$1" ]; then
error "repository name expected"
- exit 1
fi
-r=$1
-if [ `basename $1` = `basename --suffix=.git $1` ]; then
+r="$1"
+if [ "$(basename "$1")" = "$(basename --suffix=.git "$1")" ]; then
r="$r.git"
fi
-mkdir -p $r
-chgrp scm $r
-git --bare init --shared=all $r
-error "Enter project description (one line; or edit $r/descrition later)"
-error "Hit Ctrl-D when done"
-cat >$r/description
-chgrp -R scm $r
+mkdir -p "$r"
+chgrp scm "$r"
+git --bare init --shared=all "$r"
+info "Enter project description (one line; or edit $r/descrition later)"
+info "Hit Ctrl-D when done"
+cat >"$r/description"
+chgrp -R scm "$r"
if [ "$public" = "y" ]; then
- f=$r/git-daemon-export-ok
- touch $f
- chgrp scm $f
- chmod g+w $f
+ f="$r/git-daemon-export-ok"
+ touch "$f"
+ chgrp scm "$f"
+ chmod g+w "$f"
else
# Disable raw HTTP access to this directory.
#
- echo "deny from all" >$r/.htaccess
+ echo "deny from all" >"$r/.htaccess"
fi
-mv $r/hooks/post-update.sample $r/hooks/post-update
+mv "$r/hooks/post-update.sample" "$r/hooks/post-update"
if [ "$public" = "y" ]; then
echo "$r" >>manifest