My linux world » Mercurial

Mercurial


Prerequiste

I assume that you have a Centos installation.

Installation

You can copy/paste this script and use it to configure automatically your server.

  1. #!/bin/bash
  2.  
  3. echo "install tools mercurial, mod_wsgi"
  4. dnf -y install mercurial mod_wsgi
  5.  
  6. echo "create trees in /opt/hg"
  7. mkdir -p /opt/hg/cgi-bin
  8. mkdir -p /opt/hg/repos
  9. mkdir -p /opt/hg/bin
  10.  
  11. echo "copy hgweb.cgi to /opt/hg/cgi-bin"
  12. cp /usr/share/doc/mercurial-2.6.2/hgweb.cgi /opt/hg/cgi-bin
  13. chmod a+x /opt/hg/cgi-bin/hgweb.cgi
  14.  
  15. echo "configure /opt/hg/cgi-bin/hgweb.cgi"
  16. sed -i "s/^\(config\s*=\).*/\1\"\/opt\/hg\/cgi-bin\/hgweb.config\"/" /opt/hg/cgi-bin/hgweb.cgi
  17.  
  18. echo "create file /opt/hg/cgi-bin/hgweb.config"
  19. cat > /opt/hg/cgi-bin/hgweb.config << "EOF"
  20. [paths]
  21. myrepos = /opt/hg/repos/**
  22.  
  23. [web]
  24. style = paper
  25. allow_push = *
  26. push_ssl = false
  27. encoding = UTF-8
  28. descend = True
  29. collapse = True
  30. EOF
  31.  
  32. echo "configure httpd (create /etc/httpd/conf.d/hg.conf)"
  33. cat > /etc/httpd/conf.d/hg.conf << "EOF"
  34. ScriptAliasMatch ^/hg(.*)$ /opt/hg/cgi-bin/hgweb.cgi/$1
  35.  
  36. <Directory "/opt/hg/cgi-bin/">
  37. SetHandler cgi-script
  38. AllowOverride All
  39. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  40. # apache 2.2 (disabled)
  41. #Order allow,deny
  42. #Allow from all
  43. # apache 2.4
  44. Require all granted
  45. </Directory>
  46. ErrorLog /var/log/httpd/hg-error.log
  47. CustomLog /var/log/httpd/hg-access.log common
  48. EOF
  49.  
  50. echo "set selinux permissions. can check permission by using 'ls -alZ /opt/hg/cgi-bin/hgweb.cgi"
  51. chcon --type=httpd_sys_rw_content_t /opt/hg/cgi-bin/hgweb.cgi
  52.  
  53. echo "create /opt/hg/bin/create.sh"
  54. cat > /opt/hg/bin/create.sh << "EOF"
  55. hg init /opt/hg/repos/$1
  56. chown -R apache:apache /opt/hg/repos/$1
  57. chmod -R 750 /opt/hg/repos/$1
  58. EOF
  59. chmod a+x /opt/hg/bin/create.sh
  60.  
  61. echo "create two samples repositories named 'myrepos' and 'myrepos2'"
  62. /opt/hg/bin/create.sh myrepos
  63. /opt/hg/bin/create.sh myrepos2
  64.  
  65. echo "Now restart httpd"
  66. systemctl restart httpd.service
  67.  
  68. myip=`hostname -I`
  69. echo "Now meet you there: http://$myip/hg"
  70.  

That’s all 🙂
Administration – hg

FAQ

Need some help? Have a look here: Mercurial Survival Guide


Copyright © 2023 My linux world - by Marc RABAHI
Design by Marc RABAHI and encelades.

Fork me on GitHub