Advertisement
Guest User

SNORBY INSTALL SCRIPT

a guest
Feb 19th, 2020
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.67 KB | None | 0 0
  1. #  snorby-install.sh
  2. #
  3. #  Copyright 2012 Silvio Knizek <sknizek@cyberport.de>
  4. #
  5. #  This program is free software; you can redistribute it and/or modify
  6. #  it under the terms of the GNU General Public License as published by
  7. #  the Free Software Foundation; either version 2 of the License, or
  8. #  (at your option) any later version.
  9. #
  10. #  This program is distributed in the hope that it will be useful,
  11. #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. #  GNU General Public License for more details.
  14. #
  15. #  You should have received a copy of the GNU General Public License
  16. #  along with this program; if not, write to the Free Software
  17. #  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  18. #  MA 02110-1301, USA.
  19. #
  20. #
  21.  
  22. ######## requirements ########
  23. # - a running mysql somewhere
  24. # - a user with access to a db
  25. # - more than 16MB in /tmp (256MB works)
  26. # probably you want in mysql
  27. # <<create database snorby;>>
  28. # <<grant all privileges on snorby.* to "snorby"@"%" identified by "secret_password";>>
  29. # You should know what you do if you you need snorby. For everything else is irc://irc.freenode.net/#snorby
  30. # Hint: this script was written and tested on a vServer, because vServer are cool 8-)
  31.  
  32. echo -n -e "Mail to:\t" ; read MAILTO
  33. echo -n -e "Server name:\t" ; read SRVNAME
  34. echo -n -e "MySQL server:\t" ; read MYSERVER
  35. echo -n -e "MySQL database:\t" ; read MYDB
  36. echo -n -e "MySQL user:\t" ; read MYUSER
  37. echo -n -e "MySQL password:\t" ; read MYPASS
  38.  
  39. RULES_DIR=/etc/snort/rules
  40. WWW_DIR=/var/www/       # where snorby should be installed
  41.  
  42. ######## install snorby ########
  43. # install run deps
  44. echo "Installing requirements for running snorby. This could take a while..."
  45. aptitude install -y ruby1.9.1 imagemagick wkhtmltopdf openjdk-6-jdk > /dev/null
  46. if [[ $? != 0 ]]; then exit 1; fi
  47. echo "Installing done."
  48. RUBYGEM_BIN=$(gem1.9.1 environment gemdir)/bin
  49. WKHTMLTOPDF=$(which wkhtmltopdf)
  50. # install make deps
  51. echo "Installing requirements for building snorby. This could take a while..."
  52. aptitude install -y ruby1.9.1-dev make unzip git libxml2-dev libxslt1-dev libmysqlclient-dev g++ libmagickcore-dev libmagickwand-dev libcurl4-openssl-dev libssl-dev apache2-prefork-dev libapr1-dev libaprutil1-dev > /dev/null
  53. if [[ $? != 0 ]]; then exit 1; fi
  54. ln -s /usr/bin/ruby1.9.1 /usr/local/bin/ruby    # or another way to help /usr/bin/env to find ruby
  55. echo "Install rails framework..."
  56. gem1.9.1 install rails > /dev/null              # after all, it's a rail application
  57. if [[ $? != 0 ]]; then exit 1; fi
  58. gem1.9.1 install pdfkit > /dev/null             # which can produce pdfs
  59. if [[ $? != 0 ]]; then exit 1; fi
  60. echo "Installing done."
  61. echo "Building snorby in ${WWW_DIR}/snorby..."
  62. mkdir -p ${WWW_DIR}/snorby                      # the installdir
  63. cd ${WWW_DIR}
  64. echo "Get source..."
  65. wget https://github.com/Snorby/snorby/zipball/v2.5.1 -O snorby.zip > /dev/null  # get the snorby source
  66. if [[ $? != 0 ]]; then exit 1; fi
  67. echo "Got source."
  68. unzip snorby.zip > /dev/null
  69. mv Snorby-snorby-83bdd7a/* snorby/ > /dev/null
  70. mv Snorby-snorby-83bdd7a/.gitignore snorby/ > /dev/null
  71. rm -f Snorby-snorby-83bdd7a
  72. rm snorby.zip
  73. chown -R www-data:www-data ${WWW_DIR}           # make the snorby source available to apache
  74. cd snorby/config
  75. cp database.example.yml database.yml
  76. cp snorby_config.example.yml snorby_config.yml
  77. echo "Configure snorby..."
  78. # configure snorby database.yml
  79. sed -i "s|username:.*|username: ${MYUSER}|g" database.yml
  80. sed -i "s|password:.*|password: ${MYPASS}|g" database.yml
  81. sed -i "s|host:.*|host: ${MYSERVER}|g" database.yml
  82. sed -i "s|database:.*|database: ${MYDB}|g" database.yml
  83.  
  84. #configure snorby config.yml
  85. sed -i "s|domain:.*|domain: localhost:3000|g" snorby_config.yml
  86. sed -i "s|wkhtmltopdf:.*|wkhtmltopdf: ${WKHTMLTOPDF}|g" snorby_config.yml
  87. sed -i "s|mailer_sender:.*|mailer_sender: '${MAILTO}'|g" snorby_config.yml
  88. sed -i 's|  - ""|  - "/etc/snort/rules"|g' snorby_config.yml
  89. echo "Configuring done."
  90. # final install
  91. echo "Installing snorby..."
  92. ${RUBYGEM_BIN}/bundle install > /dev/null
  93. ${RUBYGEM_BIN}/bundle exec rake snorby:setup > /dev/null
  94. if [[ $? != 0 ]]; then exit 1; fi
  95. echo "Installing snorby done."
  96. echo -n -e "\n\n\n"
  97.  
  98. ######## install apache2 ########
  99. echo "Installing and setting up Apache..."
  100. aptitude install -y apache2 > /dev/null
  101. gem1.9.1 install passenger > /dev/null
  102. /var/lib/gems/1.9.1/gems/passenger-3.0.14/bin/passenger-install-apache2-module -a > /dev/null
  103. if [[ $? != 0 ]]; then exit 1; fi
  104. echo "LoadModule passenger_module /var/lib/gems/1.9.1/gems/passenger-3.0.14/ext/apache2/mod_passenger.so" > /etc/apache2/mods-available/passenger.load
  105. echo -e "PassengerRoot /var/lib/gems/1.9.1/gems/passenger-3.0.14\nPassengerRuby /usr/bin/ruby1.9.1" > /etc/apache2/mods-available/passenger.conf
  106. a2enmod passenger > /dev/null
  107. echo -e "<VirtualHost *:80>\n  ServerAdmin ${MAILTO}\n  ServerName ${SRVNAME}\n  DocumentRoot ${WWW_DIR}/snorby/public\n\n  <Directory \"${WWW_DIR}/snorby/public\">\n    AllowOverride all\n    Options -MultiViews\n  </Directory>\n\n</VirtualHost>\n\nPassengerPreStart http://${SRVNAME}" > /etc/apache2/sites-available/snorby
  108. a2dissite default > /dev/null
  109. a2ensite snorby > /dev/null
  110. /etc/init.d/apache2 restart > /dev/null
  111. echo "Apache done."
  112.  
  113. echo "Clean environment..."
  114. unset MAILTO SRVNAME MYSERVER MYDB MYUSER MYPASS RULES_DIR WWW_DIR WKHTMLTOPDF
  115. echo "Mark all build dependencies as automatically installed..."
  116. aptitude markauto ruby1.9.1-dev make unzip git libxml2-dev libxslt1-dev libmysqlclient-dev g++ libmagickcore-dev libmagickwand-dev libcurl4-openssl-dev libssl-dev apache2-prefork-dev libapr1-dev libaprutil1-dev
  117. echo "Quit. Have a nice day."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement