carini

Install Subversion with SASL auth on Ubuntu 14.04.1 LTS

Dec 29th, 2014
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.32 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. #
  4. # Install Subversion with SASL auth on Ubuntu 14.04.1 LTS
  5. #
  6. # 30/12/2014 V1.0 - Alessandro Carini
  7. #
  8.  
  9.  
  10.  
  11. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  12. # Installiamo Subversion e configuriamo il supporto SASL
  13. # ----------------------------------------------------------------------------
  14.  
  15. SVNROOT="/srv/subversion"
  16. SVNUSER="subversion"
  17.  
  18. DOMAIN="example.com"
  19. ACCOUNT="myuser"
  20. PASSWORD="mypassword"
  21. REPOSITORY="myrepo"
  22.  
  23.  
  24. # -= Installiamo subversion e sasl =-
  25.  
  26. apt-get -y install subversion xinetd sasl2-bin gsasl
  27.  
  28. adduser --system --group --home $SVNROOT $SVNUSER
  29.  
  30.  
  31. # -= Configuriamo svnserve per funzionare tramite xinetd =-
  32.  
  33. cat << __EOF__ > /etc/xinetd.d/svnserve
  34. # default: on
  35. # description:
  36. #   Subversion server for the svn protocol
  37. service svn
  38. {
  39.     disable     = no
  40.     id      = svn-stream
  41.     socket_type = stream
  42.     protocol    = tcp
  43.     instances   = 50
  44.     per_source  = 5
  45.     log_on_success  += PID HOST DURATION
  46.     log_on_failure  += HOST
  47.     wait        = no
  48.     user        = $SVNUSER
  49.     server      = /usr/bin/svnserve
  50.     server_args = -i -r $SVNROOT
  51. }
  52. __EOF__
  53.  
  54. reload xinetd
  55.  
  56.  
  57. # -= Configuriamo SASL =-
  58.  
  59. mkdir /etc/sasl2
  60. cat << __EOF__ > /etc/sasl2/svn.conf
  61. pwcheck_method: auxprop
  62. auxprop_plugin: sasldb
  63. sasldb_path: $SVNROOT/sasldb2
  64. # mech_list: DIGEST-MD5 GSSAPI
  65. __EOF__
  66.  
  67.  
  68. # -= Creiamo un account e un repository di test =-
  69.  
  70. # utente di test (e.g. saslpasswd2 -c -a svn -u example.com myuser)
  71. saslpasswd2 -c -a svn -u $DOMAIN $ACCOUNT << __EOF__
  72. $PASSWORD
  73. __EOF__
  74.  
  75. # repository di test
  76.  
  77. svnadmin create $SVNROOT/$REPOSITORY
  78.  
  79. creation=$(date "+%Y%m%d")
  80. mv $SVNROOT/$REPOSITORY/conf/authz $SVNROOT/$REPOSITORY/conf/authz.$creation
  81. mv $SVNROOT/$REPOSITORY/conf/svnserve.conf $SVNROOT/$REPOSITORY/conf/svnserve.conf.$creation
  82.  
  83. cat << __EOF__ > $SVNROOT/$REPOSITORY/conf/authz
  84. # domain = $DOMAIN, repository $REPOSITORY
  85. # created = $creation
  86.  
  87. [groups]
  88. rwgroup = $ACCOUNT
  89.  
  90. [$REPOSITORY:/]
  91. @rwgroup = rw
  92. __EOF__
  93.  
  94. cat << __EOF__ > $SVNROOT/$REPOSITORY/conf/svnserve.conf
  95. # domain = $DOMAIN, repository $REPOSITORY
  96. # created = $creation
  97.  
  98. [general]
  99. anon-access = none
  100. auth-access = write
  101. authz-db = authz
  102. realm = example.com
  103.  
  104. [sasl]
  105. use-sasl = true
  106. min-encryption = 128
  107. max-encryption = 2048
  108. __EOF__
  109.  
  110. # mettiamo a posto i permessi
  111.  
  112. chown -cR $SVNUSER:$SVNUSER $SVNROOT
  113.  
  114.  
  115. # end
Advertisement
Add Comment
Please, Sign In to add comment