My linux world » Sonar

Sonar


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 "import sonar repository"
  4. sudo wget -O /etc/yum.repos.d/sonar.repo http://downloads.sourceforge.net/project/sonar-pkg/rpm/sonar.repo
  5.  
  6. echo "create database sonar, user/password sonar/sonar":
  7. mysql --user=root --password=root -e "CREATE USER 'sonar'@'localhost' IDENTIFIED BY 'sonar';"
  8. mysql --user=root --password=root -e "CREATE DATABASE IF NOT EXISTS sonar;"
  9. mysql --user=root --password=root -e "use sonar; GRANT ALL PRIVILEGES ON sonar.* TO 'sonar'@'localhost' WITH GRANT OPTION;"
  10.  
  11. echo "install sonar"
  12. dnf -y install sonar
  13.  
  14. echo "start sonar on boot"
  15. systemctl enable sonar.service
  16.  
  17. echo "Configure sonar"
  18. # add # before each sonar.jdbc.url that are not commented:
  19. sed -i "s/^\(sonar.jdbc.url\)/#\1/" /opt/sonar/conf/sonar.properties
  20.  
  21. # remove comment for the sonar.jdbc.url in mysql part:
  22. sed -i "s/^#\(sonar.jdbc.url=.*jdbc:mysql\)/\1/" /opt/sonar/conf/sonar.properties
  23.  
  24. # user creditential:
  25. sed -i "s/^#\(sonar.jdbc.username=\).*/\1sonar/" /opt/sonar/conf/sonar.properties
  26. sed -i "s/^#\(sonar.jdbc.password=\).*/\1sonar/" /opt/sonar/conf/sonar.properties
  27.  
  28. # sonar web context
  29. sed -i "s/^#\(sonar.web.context=\).*/\1\/sonar/" /opt/sonar/conf/sonar.properties
  30. sed -i "s/^\(sonar.web.context=\).*/\1\/sonar/" /opt/sonar/conf/sonar.properties
  31.  
  32. echo "configure httpd (create /etc/httpd/conf.d/sonar.conf)"
  33. cat > /etc/httpd/conf.d/sonar.conf << "EOF"
  34. ProxyPreserveHost On
  35. Proxypass /sonar http://localhost:9000/sonar
  36. Proxypassreverse /sonar http://localhost:9000/sonar
  37. ProxyRequests Off
  38. EOF
  39.  
  40. echo "start service"
  41. systemctl restart httpd.service
  42. systemctl start sonar.service
  43.  
  44. myip=`hostname -I`
  45. echo "Now meet you here: http://$myip/sonar"
  46.  

That’s all 🙂


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