Commit 0c754948 authored by HQ's avatar HQ
Browse files

Various improvements

parent bf1fc026
...@@ -29,11 +29,6 @@ unless (-e '/etc/discourse.seeded') { ...@@ -29,11 +29,6 @@ unless (-e '/etc/discourse.seeded') {
# print `perl -pi -e 's/(DocumentRoot .*)/\$1\\nProxyPass \\/ http:\\/\\/127.0.0.1:9292\\/\\nProxyPassReverse \\/ http:\\/\\/127.0.0.1:9292\\//g' /etc/apache2/sites-available/default-ssl.conf`; # print `perl -pi -e 's/(DocumentRoot .*)/\$1\\nProxyPass \\/ http:\\/\\/127.0.0.1:9292\\/\\nProxyPassReverse \\/ http:\\/\\/127.0.0.1:9292\\//g' /etc/apache2/sites-available/default-ssl.conf`;
# } # }
unless (`grep PassengerBase /etc/apache2/sites-available/default-ssl.conf`) {
print `perl -pi -e 's/(DocumentRoot .*)/DocumentRoot \\/var\\/discourse\\/public\\nRailsBaseURI \\/\\nPassengerBaseURI \\/\\nPassengerResolveSymlinksInDocumentRoot on\\nPassengerAppRoot \\/var\\/discourse\\n/g' /etc/apache2/sites-available/default-ssl.conf`;
print `perl -pi -e 's/(DocumentRoot .*)/DocumentRoot \\/var\\/discourse\\/public\\nRailsBaseURI \\/\\nPassengerBaseURI \\/\\nPassengerResolveSymlinksInDocumentRoot on\\nPassengerAppRoot \\/var\\/discourse\\n/g' /etc/apache2/sites-available/000-default.conf`;
}
print `echo "<h1 align=center><img width=48 height=48 src=https://www.stabile.io/images/apps/discourse_icon.png> Preparing Discourse...</h1><p align=center><img src=https://www.origo.io/images/39.svg></p><script>setTimeout(function(){location.reload() ; }, 8000);</script>" > /var/www/html/index.html`; print `echo "<h1 align=center><img width=48 height=48 src=https://www.stabile.io/images/apps/discourse_icon.png> Preparing Discourse...</h1><p align=center><img src=https://www.origo.io/images/39.svg></p><script>setTimeout(function(){location.reload() ; }, 8000);</script>" > /var/www/html/index.html`;
print `sudo -u postgres psql -c "CREATE USER discourse;"`; print `sudo -u postgres psql -c "CREATE USER discourse;"`;
print `sudo -u postgres psql -c "ALTER USER discourse WITH ENCRYPTED PASSWORD 'password';"`; print `sudo -u postgres psql -c "ALTER USER discourse WITH ENCRYPTED PASSWORD 'password';"`;
...@@ -46,7 +41,12 @@ unless (-e '/etc/discourse.seeded') { ...@@ -46,7 +41,12 @@ unless (-e '/etc/discourse.seeded') {
`perl -pi -e 's/hostname =.*/hostname = $dom/g' /var/discourse/config/discourse.conf`; `perl -pi -e 's/hostname =.*/hostname = $dom/g' /var/discourse/config/discourse.conf`;
`perl -pi -e 's/smtp_domain =.*/smtp_domain = $dom/g' /var/discourse/config/discourse.conf`; `perl -pi -e 's/smtp_domain =.*/smtp_domain = $dom/g' /var/discourse/config/discourse.conf`;
`perl -pi -e 's/myhostname =.*/myhostname = $dom/g' /var/discourse/config/discourse.conf`; `perl -pi -e 's/myhostname =.*/myhostname = $dom/g' /var/discourse/config/discourse.conf`;
print `sudo -u postgres psql discourse -c "UPDATE site_settings SET value = 'noreply\@$dom' WHERE name = 'notification_email';"`; # print `sudo -u postgres psql discourse -c "UPDATE site_settings SET value = 'noreply\@$dom' WHERE name = 'notification_email';"`;
# https://github.com/lautis/uglifier/issues/127
`perl -pi -e 's/config\.assets\.js_compressor = :uglifier/config.assets.js_compressor = Uglifier.new(:harmony => true)/' /var/discourse/config/environments/production.rb`;
`perl -pi -e 's/Uglifier.new\(comments: :none,.*/Uglifier.new(comments: :none, harmony: true,/' /var/discourse/lib/tasks/assets.rake`;
`echo "require 'uglifier'" >> /var/discourse/Gemfile`;
print `cd /var/discourse ; RAILS_ENV=production bundle exec rake db:migrate`; print `cd /var/discourse ; RAILS_ENV=production bundle exec rake db:migrate`;
print `cd /var/discourse ; RAILS_ENV=production bundle exec rake assets:precompile`; print `cd /var/discourse ; RAILS_ENV=production bundle exec rake assets:precompile`;
...@@ -60,9 +60,14 @@ unless (-e '/etc/discourse.seeded') { ...@@ -60,9 +60,14 @@ unless (-e '/etc/discourse.seeded') {
chomp $randpass; chomp $randpass;
print `cd /var/discourse ; export RAILS_ENV=production; echo "$email\n$randpass\n$randpass\nY " | rake admin:create`; print `cd /var/discourse ; export RAILS_ENV=production; echo "$email\n$randpass\n$randpass\nY " | rake admin:create`;
unless (`grep PassengerBase /etc/apache2/sites-available/default-ssl.conf`) {
print `perl -pi -e 's/(DocumentRoot .*)/DocumentRoot \\/var\\/discourse\\/public\\nRailsBaseURI \\/\\nPassengerBaseURI \\/\\nPassengerResolveSymlinksInDocumentRoot on\\nPassengerAppRoot \\/var\\/discourse\\n/g' /etc/apache2/sites-available/default-ssl.conf`;
print `perl -pi -e 's/(DocumentRoot .*)/DocumentRoot \\/var\\/discourse\\/public\\nRailsBaseURI \\/\\nPassengerBaseURI \\/\\nPassengerResolveSymlinksInDocumentRoot on\\nPassengerAppRoot \\/var\\/discourse\\n/g' /etc/apache2/sites-available/000-default.conf`;
}
`chown -R www-data:www-data /var/www`; `chown -R www-data:www-data /var/www`;
`chown -R www-data:www-data /var/discourse`; `chown -R www-data:www-data /var/discourse`;
`perl -pi -e 's/PrivateTmp=true/PrivateTemp=false/' /lib/systemd/system/apache2.service`;
`systemctl restart postfix`; `systemctl restart postfix`;
`systemctl restart apache2`; `systemctl restart apache2`;
`touch /etc/discourse.seeded`; `touch /etc/discourse.seeded`;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment