我在我的服務器上安裝了許多不同的存儲庫。我需要在每個回購協議中都有一個完全相同的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:可以爲自定義指標創建警報嗎?