|
@@ -25,6 +25,8 @@ Commands:
|
|
|
Delete existing repository.
|
|
|
fixmod <repository1> [repository2] ...
|
|
|
Fix access rights for repository.
|
|
|
+ rename <old_name> <new_name>
|
|
|
+ Rename repository.
|
|
|
useradd <repository> <r/w/rw> <user1> [user2] ...
|
|
|
Set access rights for user(s) to repository.
|
|
|
userdel <repository> <r/w/rw> <user1> [user2] ...
|
|
@@ -44,6 +46,17 @@ group_del()
|
|
|
groupdel "${group_w_prefix}$1" || return 1
|
|
|
}
|
|
|
|
|
|
+group_rename()
|
|
|
+{
|
|
|
+ local old_name="$1"
|
|
|
+ local new_name="$2"
|
|
|
+
|
|
|
+ groupmod -n "${group_r_prefix}$new_name" "${group_r_prefix}$old_name" || return 1
|
|
|
+ groupmod -n "${group_w_prefix}$new_name" "${group_w_prefix}$old_name" || return 1
|
|
|
+
|
|
|
+ return 0
|
|
|
+}
|
|
|
+
|
|
|
create_repo_svn()
|
|
|
{
|
|
|
svnadmin --fs-type=fsfs create "$1" || return 1
|
|
@@ -169,6 +182,34 @@ repository_fixmod()
|
|
|
done
|
|
|
}
|
|
|
|
|
|
+repository_rename()
|
|
|
+{
|
|
|
+ local old_name="$1"
|
|
|
+ local new_name="$2"
|
|
|
+ local repo_root
|
|
|
+ local repo_link
|
|
|
+
|
|
|
+ # Check if target name is already exists
|
|
|
+ repo_root=`find_repo_root "$new_name"`
|
|
|
+ test "x$repo_root" = "x" || { echo "Error: The repository \"$new_name\" is already exist" 1>&2; return 1; }
|
|
|
+
|
|
|
+ repo_root=`find_repo_root "$old_name"`
|
|
|
+ repo_link=`find_repo_link "$old_name"`
|
|
|
+ test "x$repo_root" != "x" -a -d "$repo_root/$old_name" || { echo "Error: Can't find repository \"$old_name\"" 1>&2; return 1; }
|
|
|
+ test "x$repo_root" != "x" -a -L "$repo_link/$old_name" || { echo "Error: Can't find link of repository \"$old_name\"" 1>&2; return 1; }
|
|
|
+
|
|
|
+ # Real move repository and link
|
|
|
+ mv -f "$repo_root/$old_name" "$repo_root/$new_name" || { echo "Error: Can't move repository \"$old_name\"" 1>&2; return 1; }
|
|
|
+ link_del "$old_name" "$repo_link" || { echo "Error: Can't remove link for repository \"$old_name\"" 1>&2; }
|
|
|
+ link_add "$new_name" "$repo_root" "$repo_link" || { echo "Error: Can't create link for repository \"$new_name\"" 1>&2; }
|
|
|
+
|
|
|
+ # Rename a groups
|
|
|
+ group_rename "$old_name" "$new_name" || { echo "Error: Can't rename access groups for repository \"$new_name\"" 1>&2; }
|
|
|
+
|
|
|
+ echo "Info: The repository \"$old_name\" was succesfully renamed to \"$new_name\""
|
|
|
+ return 0
|
|
|
+}
|
|
|
+
|
|
|
user_add()
|
|
|
{
|
|
|
local w=0
|
|
@@ -231,25 +272,50 @@ user_del()
|
|
|
done
|
|
|
}
|
|
|
|
|
|
-find_repo()
|
|
|
+# Find repository root path by repository name
|
|
|
+find_repo_root()
|
|
|
+{
|
|
|
+ local r=""
|
|
|
+ local r_root=""
|
|
|
+
|
|
|
+ for r in $possible_vcs; do
|
|
|
+ eval r_root="\$repository_${r}_root"
|
|
|
+ test "x$r_root" = "x" && continue
|
|
|
+ test -d "$r_root/$1" || continue
|
|
|
+ echo "$r_root"
|
|
|
+ break
|
|
|
+ done
|
|
|
+
|
|
|
+ return 0
|
|
|
+}
|
|
|
+
|
|
|
+find_repo_link()
|
|
|
{
|
|
|
local r=""
|
|
|
local r_root=""
|
|
|
+ local r_link=""
|
|
|
|
|
|
- repo_root=""
|
|
|
- repo_link=""
|
|
|
for r in $possible_vcs; do
|
|
|
eval r_root="\$repository_${r}_root"
|
|
|
test "x$r_root" = "x" && continue
|
|
|
test -d "$r_root/$1" || continue
|
|
|
- repo_root="$r_root"
|
|
|
- eval repo_link="\$repository_${r}_link"
|
|
|
+ eval r_link="\$repository_${r}_link"
|
|
|
+ echo "$r_link"
|
|
|
break
|
|
|
done
|
|
|
|
|
|
return 0
|
|
|
}
|
|
|
|
|
|
+# Legacy function to be compatible.
|
|
|
+# Use find_repo_root and find_repo_link functions
|
|
|
+find_repo()
|
|
|
+{
|
|
|
+ repo_root=`find_repo_root "$1"`
|
|
|
+ repo_link=`find_repo_link "$1"`
|
|
|
+ return 0
|
|
|
+}
|
|
|
+
|
|
|
#------------------ MAIN -----------------------------------------
|
|
|
|
|
|
possible_vcs="svn git"
|
|
@@ -332,13 +398,17 @@ case "$action" in
|
|
|
test $# -lt 1 && { echo "Error: Repository name is expected" 1>&2; exit 1; }
|
|
|
repository_add "$@"
|
|
|
;;
|
|
|
+"del")
|
|
|
+ test $# -lt 1 && { echo "Error: Repository name is expected" 1>&2; exit 1; }
|
|
|
+ repository_del "$@"
|
|
|
+ ;;
|
|
|
"fixmod")
|
|
|
test $# -lt 1 && { echo "Error: Repository name is expected" 1>&2; exit 1; }
|
|
|
repository_fixmod "$@"
|
|
|
;;
|
|
|
-"del")
|
|
|
- test $# -lt 1 && { echo "Error: Repository name is expected" 1>&2; exit 1; }
|
|
|
- repository_del "$@"
|
|
|
+"rename")
|
|
|
+ test $# -lt 2 && { echo "Error: The old and new repository names are expected" 1>&2; exit 1; }
|
|
|
+ repository_rename "$@" || exit 1
|
|
|
;;
|
|
|
"adduser"|"useradd")
|
|
|
test $# -lt 3 && { echo "Error: Not enough parameters" 1>&2; exit 1; }
|