简体   繁体   English

在Centos上创建Subversion Shell脚本

[英]Creating subversion shell script on Centos

I have subversion installed on CentOs 6.4 and want to write a script (from my understanding a shell script) to run a couple of commands. 我在CentOs 6.4上安装了Subversion,并且想要编写一个脚本(据我了解的Shell脚本)来运行几个命令。 My issue here is not writing the shell script but more providing a parameter to the shell script (so a function in a way) to be able to complete the request. 我的问题不是写shell脚本,而是为shell脚本提供一个参数(某种程度上是一个函数)以能够完成请求。

In essence I want to do the following: 本质上,我想执行以下操作:

  1. Run script with parameter from SSH ("somscript reponame") 使用来自SSH的参数运行脚本(“ somscript reponame”)
  2. Create repo: svnadmin create /var/www/svn/reponame 创建仓库:svnadmin create / var / www / svn / reponame
  3. Change repo owner: chown -R apache.apache /var/www/svn/reponame -R 更改回购所有者:chown -R apache.apache / var / www / svn / reponame -R
  4. Do security changes: chcon -R -t httpd_sys_content_t /var/www/svn/reponame/ 进行安全更改:chcon -R -t httpd_sys_content_t / var / www / svn / reponame /
  5. And chcon -R -t httpd_sys_rw_content_r /var/www/svn/reponame 和chcon -R -t httpd_sys_rw_content_r / var / www / svn / reponame
  6. Create default directories: svn import -m 'Initial import' /tmp/svn-structure-template/ http://domain.com/svn/reponame/ (localhost is not accepted by stackoverflow) 创建默认目录:svn import -m'初始导入'/ tmp / svn-structure-template / http://domain.com/svn/reponame/(stackoverflow不接受localhost)

Can anyone offer some guidance or perhaps provide an alternative I can use? 谁能提供一些指导,或者提供我可以使用的替代方法? Would a PHP script work (so to run it from a browser and use a query string of some sort and would this not cause some security issues as apache is the default owner and some of these may require root / sudo access). PHP脚本是否可以工作(因此要从浏览器运行它并使用某种查询字符串,并且不会因为apache是​​默认所有者而引起一些安全问题,其中一些可能需要root / sudo访问权限)。

Thank you in advance! 先感谢您!

As Fausto said in the comment, standard Bash parameters should work fine. 正如Fausto在评论中所说,标准Bash参数应该可以正常工作。 At ProjectLocker , we use scripts similar to what you're describing to provision new Subversion repositories, and you should just be able to reference "$1", "$2", and so on in the script. ProjectLocker中 ,我们使用与您所描述的脚本类似的脚本来配置新的Subversion存储库,并且您应该只能够在脚本中引用“ $ 1”,“ $ 2”等等。

Incidentally, you don't have to import to the http:// location if you're running on the machine with the instance, if that makes things harder. 顺便说一句,如果您使用实例在计算机上运行,​​则不必导入到http://位置,这会使事情变得更难。 You can do: 你可以做:

 svn import -m 'Initial import' /tmp/svn-structure-template/ file:///var/www/svn/reponame

although I'd recommend testing that first to make sure that doesn't cause an undesired permissions change. 尽管我建议先进行测试,以确保不会导致不希望的权限更改。 If it does, you can simply run it before the apache permission flip and the lockdown. 如果是这样,您可以在apache权限翻转和锁定之前简单地运行它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM