Advertisement
Guest User

Untitled

a guest
Mar 4th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. set -e
  4.  
  5. [ -z "${MYSQL_PASSWD}" ] && MYSQL_PASSWD=mysql
  6. [ -z "${REDMINE_PASSWD}" ] && REDMINE_PASSWD=redmine
  7.  
  8. redmine_install()
  9. {
  10. sudo pacman -Sy --noconfirm ruby ruby-bundler
  11. for f in ruby gem rake bundle; do
  12. sudo ln -s "$(which ${f}-2.3)" /usr/bin/"${f}"
  13. done
  14.  
  15. # Ruby on Rails.
  16. cd /usr/share/webapps/redmine/
  17. cat <<EOF | sudo tee config/database.yml
  18. production:
  19. adapter: mysql2
  20. database: redmine
  21. host: localhost
  22. username: redmine
  23. password: "${REDMINE_PASSWD}"
  24. encoding: utf8
  25. EOF
  26. sudo bundle install --without development test
  27. sudo RAILS_ENV=production bundle exec rake generate_secret_token
  28. sudo RAILS_ENV=production bundle exec rake db:migrate
  29. echo "en" | \
  30. sudo RAILS_ENV=production bundle exec rake redmine:load_default_data
  31. sudo chown -R http:http files log tmp public/plugin_assets
  32. }
  33.  
  34. apache_install()
  35. {
  36. sudo pacman -Sy --noconfirm apache
  37. sudo systemctl enable httpd
  38.  
  39. # ssl configuration.
  40. # Country Name (2 letter code) [AU]:
  41. # State or Province Name (full name) [Some-State]:
  42. # Locality Name (eg, city) []:
  43. # Organization Name (eg, company) [Internet Widgits Pty Ltd]:
  44. # Organizational Unit Name (eg, section) []:
  45. # Common Name (e.g. server FQDN or YOUR name) []:
  46. # Email Address []:
  47. cat <<EOF | sudo openssl req -new -x509 -nodes -newkey rsa:4096 -days 1095 \
  48. -keyout /etc/httpd/conf/server.key \
  49. -out /etc/httpd/conf/server.crt
  50. AU
  51. Some-State
  52. city
  53. company
  54. section
  55.  
  56.  
  57. EOF
  58. sudo sed -i /etc/httpd/conf/httpd.conf \
  59. -e 's/^#LoadModule ssl_module/LoadModule ssl_module/g' \
  60. -e 's/^#LoadModule socache_shmcb_module/LoadModule socache_shmcb_module/g'
  61. cat <<EOF | sudo tee -a /etc/httpd/conf/httpd.conf
  62. Include conf/extra/httpd-ssl.conf
  63. EOF
  64.  
  65. # rewrite configuration.
  66. sudo sed -i /etc/httpd/conf/httpd.conf \
  67. -e 's/^#LoadModule rewrite_module/LoadModule rewrite_module/g'
  68. cat << EOF | sudo tee /etc/httpd/conf/extra/redirect-to-https.conf
  69. RewriteEngine On
  70. RewriteCond %{HTTPS} off
  71. RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}
  72. EOF
  73. cat <<EOF | sudo tee -a /etc/httpd/conf/httpd.conf
  74. Include conf/extra/redirect-to-https.conf
  75. EOF
  76.  
  77. # passenger configuration.
  78. sudo gem install --no-user-install passenger
  79. cd /opt/ruby2.3/lib/ruby/gems/2.3.0/gems/passenger-5.1.11/bin
  80. echo "1" | sudo ./passenger-install-apache2-module
  81. cat << EOF | sudo tee /etc/httpd/conf/extra/passenger.conf
  82. PassengerRoot /opt/ruby2.3/lib/ruby/gems/2.3.0/gems/passenger-5.1.11
  83. PassengerDefaultRuby /opt/ruby2.3/bin/ruby-2.3
  84. PassengerDefaultUser http
  85. RailsBaseURI /redmine
  86. EOF
  87. cat <<EOF | sudo tee -a /etc/httpd/conf/httpd.conf
  88. LoadModule passenger_module \
  89. /opt/ruby2.3/lib/ruby/gems/2.3.0/gems/passenger-5.1.11/buildout/apache2/mod_passenger.so
  90. Include conf/extra/passenger.conf
  91. EOF
  92.  
  93. # redmine configuration.
  94. sudo ln -s /usr/share/webapps/redmine/public /srv/http/redmine
  95. cat << EOF | sudo tee /etc/httpd/conf/extra/redmine.conf
  96. <Directory /redmine>
  97. Options FollowSymLinks
  98. PassengerResolveSymlinksInDocumentRoot on
  99. AllowOverride None
  100. </Directory>
  101. EOF
  102. cat <<EOF | sudo tee -a /etc/httpd/conf/httpd.conf
  103. Include conf/extra/redmine.conf
  104. EOF
  105.  
  106. sudo systemctl restart httpd
  107. }
  108.  
  109. redmine_main()
  110. {
  111. redmine_install
  112. apache_install
  113. }
  114.  
  115. redmine_main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement