我在我的服务器上安装了许多不同的存储库。我需要在每个回购协议中都有一个完全相同的post-commit hook文件。足够简单的现有,但有没有办法打电话给svnadmin创建自动将post-commit存根文件复制到新的挂钩目录?基本上我正在寻找一个post-svnadmin-create挂钩。谢谢!我可以自定义svnadmin创建过程吗?
0
A
回答
1
我认为你最好的选择是将呼叫包装到svnadmin create中,该脚本创建回购后的挂钩。
0
只要没有一些内置的方式,似乎没有。我希望颠覆者可以为新的Linux用户提供类似于可定制骨架目录的东西。太糟糕了。
这是我的包装与评论,如果任何人都可以找到它有用的 - 应该是相当可扩展的。如果有人注意到在它的任何明显的陷阱,不要犹豫 - 我既不是庆典也不是Linux的专家,但我觉得我得到了大部分覆盖,它的工作原理:)
# -----------------------------------------------------------------------
# A wrapper for svnadmin to allow post operations following repo creation - copying custom
# hook files into repo in this case. This should be run as root.
# capture input args; note that args[0] == [email protected][1] (this script name is not captured here)
args=("[email protected]");
# redirect args to svnadmin in all cases - this script should not modify the behavior of svnadmin.
# note: the original binary "/binary_path/svnadmin" has been renamed "/binary_path/svnadmin-wrapped" and
# this script was then named "/binary_path/svnadmin" and given identical user:group & permissions as
# the original.
sudo -u svnuser svnadmin-wrapped ${args[@]};
# capture return code so we can return on exit; svnadmin returns 0 for success
eCode=$?;
# find out if sub-command to svnadmin was "create" and, if so, note the index of the directory arg,
# which is not necessarily going to be in the same position each time (options may be specified
# before the sub-command).
path_idx=0;
found=0;
for i in ${args[@]}
do
# track index; pre-incerement
((path_idx++));
if [ $i == "create" ]
then
# found repo path
((found++));
break;
fi
done
# we now know if the subcommand was create and where the repo path is - finish up as needed.
# note that this block assumes that our hook file stubs are /stub_path/ (owned by root)
# and that there exists a custom log file at /stub_path/cust-log (also owned by root).
d=`date`;
if [ $found != 0 ]
then
# check that the command succeeded
if [ $eCode == 0 ]
then
# check that the directory exists
if [ -d "${args[$path_idx]}/hooks" ]
then
# copy our custom hooks into place
sudo -u svnuser cp "/stub_path/post-commit" "${args[$path_idx]}/hooks/post-commit";
sudo -u svnuser cp "/stub_path/post-revprop-change" "${args[$path_idx]}/hooks/post-revprop-change";
else
# unlikey failure; set custom error code here; log issue
echo "$d svnadmin wrapper error: svnadmin 'create' succeeded but the 'hooks' directory was not found! Params: ${args[@]}" >> "/stub_path/cust-log";
let "eCode=1325";
fi
else
# tried to create but svnadmin failed; log issue
echo "$d svnadmin wrapper error: svnadmin 'create' was called but failed! Params: ${args[@]}" >> "/stub_path/cust-log";
fi
fi
exit $eCode;
-Thanks所有谁主机和帖子!
相关问题
- 1. 我可以创建自定义plist结构定义吗?
- 2. 我们可以自己创建自定义sdk吗
- 3. 我可以为android创建自定义配置限定符吗?
- 4. 我可以在iPhone上创建自定义键盘字典吗?
- 5. 我可以在iPhone中创建自定义键盘吗?
- 6. MS CRM:我可以创建自定义活动partylist吗?
- 7. 我可以在Delphi中创建自定义HTTP协议吗?
- 8. 我们可以使用UIPickerView创建自定义单元吗?
- 9. 我可以创建一个自定义的java。*包吗?
- 10. 我可以在ASP.NET中创建自定义指令吗?
- 11. 我可以为函数创建自定义语法/前缀吗?
- 12. 我可以创建一个自定义WordPress注册表吗?
- 13. 我可以使用Querydsl创建自定义后端实现吗?
- 14. 我们可以在Fortran中创建自定义属性吗?
- 15. 我可以创建自定义[视频]搜索引擎吗?
- 16. 我可以创建自定义暗示类型演员吗?
- 17. 我们可以创建自定义HTTP描述吗?
- 18. 我可以创建Corda自定义数据表吗?
- 19. 我们可以在发布后创建自定义报告吗?
- 20. 您可以为STB创建自定义驱动程序吗?
- 21. 我们可以在C#中创建自己的过程吗?
- 22. 我可以通过WCF服务创建自定义角色提供者吗?
- 23. 我可以创建自定义事件以更改特定的select值吗?
- 24. 我可以从自定义应用程序创建或删除Android日历吗?
- 25. 我可以通过LinqPad创建DbContext吗?
- 26. 我可以自定义Google Map吗?
- 27. 我可以自定义标题吗?
- 28. 我可以自定义UIDatePicker吗?
- 29. 如果我需要自定义getter/setter,我可以省略字段创建吗?
- 30. New Relic:可以为自定义指标创建警报吗?