Commit 96fba6ca authored by HQ's avatar HQ
Browse files

Various improvements

parent 45c19f72
......@@ -32,4 +32,4 @@ DESCRIPTION=<div>This Stack is a lean install of Centos Server 8.2 with light-we
<li>No lock-in: At any time you can download your images in qcow2-format</li>\
<li>Size the server (after installation) as you like, and only pay for the minutes your servers are running.</li>\
</ul>\
<div><a href="https://gitlab.origo.io/origosys/stabile-stacks/-/tree/mastercentos-8">Stack source code</a></div>
<div><a href="https://gitlab.origo.io/origosys/stabile-stacks/-/tree/master/centos-8">Stack source code</a></div>
......@@ -59,4 +59,4 @@ DESCRIPTION=<section>\
<p>Codiad is installed and works out the box with Develop.</p>\
<p>For more information about Codiad, please <strong><a href="https://github.com/Codiad/Codiad/wiki/Installation">read the installation instructions</a></strong> on the Wiki.</p>\
</section>\
<div><a href="https://gitlab.origo.io/origosys/stabile-stacks/-/tree/masterdevelop">Stack source code</a></div>
\ No newline at end of file
<div><a href="https://gitlab.origo.io/origosys/stabile-stacks/-/tree/master/develop">Stack source code</a></div>
\ No newline at end of file
......@@ -12,7 +12,7 @@ TARTARGET=
GIT=https://github.com/discourse/discourse.git
GITTARGET=/var/discourse
PREEXEC=/tmp/files/preexec.sh
DEBS=postgresql-10 libgdbm-dev libncurses5-dev automake libtool bison libffi-dev gawk g++ libssl-dev make zlib1g-dev libyaml-dev libsqlite3-dev sqlite3 libgmp-dev pkg-config libgmp-dev libreadline6-dev libpq-dev redis-server ruby-rmagick imagemagick optipng jhead jpegoptim gifsicle postfix software-properties-common ruby-sidekiq-cron ruby ruby-dev
DEBS=postgresql-10 libgdbm-dev libncurses5-dev automake libtool bison libffi-dev gawk g++ libssl-dev make zlib1g-dev libyaml-dev libsqlite3-dev sqlite3 libgmp-dev pkg-config libgmp-dev libreadline6-dev libpq-dev redis-server ruby-rmagick imagemagick optipng jhead jpegoptim gifsicle postfix software-properties-common ruby-sidekiq-cron ruby ruby-dev brotli
POSTEXEC=/tmp/files/postexec.sh
SERVICE=/usr/local/bin/stabile-discourse.pl
TERMINALLINK=/stabile/pipe/http://{uuid}:4200
......
......@@ -20,7 +20,8 @@ perl -pi -e 's/(.*config.serve_static_files.+)/\#$1/g' /var/discourse/config/env
apt-get install -y npm
npm install -g svgo@0.7.2
npm install pngquant
#npm install pngquant
gem install image_optim
perl -pi -e 's/inet_protocols =.*/inet_protocols = ipv4/;' /etc/postfix/main.cf
......@@ -50,6 +51,7 @@ development:
- [default, 2]
- [low]" > /var/discourse/config/sidekiq.yml
cp
mkdir -p /var/discourse/tmp/sockets
mkdir -p /var/discourse/tmp/pids
......@@ -64,6 +66,7 @@ echo "export RAILS_ENV=production" >> /etc/bash.bashrc
# https://github.com/discourse/discourse/commit/b2cfad5f47e6335ba514297517fa20e84dd004a8
wget https://github.com/mikefarah/yq/releases/download/v4.9.6/yq_linux_amd64
mv yq_linux_amd64 /usr/bin/yq
chmod 755 /usr/bin/yq
/usr/bin/yq e '.users.min_password_length.min = 6' -i /var/discourse/config/site_settings.yml
/usr/bin/yq e '.users.min_password_length.default = 6' -i /var/discourse/config/site_settings.yml
/usr/bin/yq e '.users.min_admin_password_length.min = 6' -i /var/discourse/config/site_settings.yml
......
......@@ -21,16 +21,24 @@ my $dnssubdomain = $appinfo{'dnssubdomain'};
my $dom = ($dnsdomain && $dnssubdomain)?"$externalip.$dnssubdomain.$dnsdomain":"$externalip";
unless (-e '/etc/discourse.seeded') {
if (`grep ProxyPass /etc/apache2/sites-available/000-default.conf`) {
print `perl -pi -e 's/.*ProxyPass.*\\n//g' /etc/apache2/sites-available/000-default.conf`;
print `perl -pi -e 's/.*ProxyPass.*\\n//g' /etc/apache2/sites-available/default-ssl.conf`;
# if (`grep ProxyPass /etc/apache2/sites-available/000-default.conf`) {
# print `perl -pi -e 's/.*ProxyPass.*\\n//g' /etc/apache2/sites-available/000-default.conf`;
# print `perl -pi -e 's/.*ProxyPass.*\\n//g' /etc/apache2/sites-available/default-ssl.conf`;
# } else {
# 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/000-default.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 `sudo -u postgres psql -c "CREATE DATABASE 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 DATABASE discourse OWNER TO discourse;"`;
print `sudo -u postgres psql -c "CREATE DATABASE discourse WITH OWNER discourse ENCODING 'UTF8' LC_CTYPE='en_US.UTF-8' LC_COLLATE='en_US.UTF-8' TEMPLATE=template0;"`;
# print `sudo -u postgres psql -c "ALTER DATABASE discourse OWNER TO discourse;"`;
print `sudo -u postgres psql -c "CREATE ROLE root WITH CREATEDB LOGIN CREATEROLE SUPERUSER;"`;
print `sudo -u postgres psql discourse -c "CREATE EXTENSION hstore;"`;
print `sudo -u postgres psql discourse -c "CREATE EXTENSION pg_trgm;"`;
......@@ -46,24 +54,17 @@ unless (-e '/etc/discourse.seeded') {
chomp $randpass;
print `cd /var/discourse ; export RAILS_ENV=production; echo "$email\n$randpass\n$randpass\nY " | rake admin:create`;
unless (`grep ProxyPass /etc/apache2/sites-available/000-default.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/000-default.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`;
}
`systemctl restart apache2`;
my $appinfo = `curl -sk https://$gw/stabile/servers?action=getappinfo`;
my $info_ref = from_json($appinfo);
my $externalip = `cat /tmp/externalip`;
chomp $externalip;
my $hostname = $externalip . '.' . $dom;
`perl -pi -e 's/hostname =.*/hostname = $hostname/g' /var/discourse/config/discourse.conf`;
`perl -pi -e 's/smtp_domain =.*/smtp_domain = $hostname/g' /var/discourse/config/discourse.conf`;
`perl -pi -e 's/myhostname =.*/myhostname = $hostname/g' /var/discourse/config/discourse.conf`;
print `sudo -u postgres psql discourse -c "UPDATE site_settings SET value = 'noreply\@$hostname' WHERE name = 'notification_email';"`;
`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/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';"`;
`systemctl restart postfix`;
`chowm -R www-data:www-data /var/discourse`;
`systemctl restart apache2`;
`touch /etc/discourse.seeded`;
}
print `cd /var/discourse ; RAILS_ENV=production bundle exec puma -C config/puma.rb &`;
# print `cd /var/discourse ; RAILS_ENV=production bundle exec puma -C config/puma.rb &`;
print `cd /var/discourse ; RAILS_ENV=production bundle exec sidekiq -C config/sidekiq.yml &`;
sub get_internalip {
......
......@@ -25,7 +25,7 @@ sub discourse {
Here you can manage basic security for Discourse.
</div>
<small>Set password for Discourse user "$email":</small>
<form class="passwordform" action="index.cgi?action=discoursepassword&tab=discourse" method="post" onsubmit="discourseSpinner(); \$('#discoursepassword').val(''); return false;" accept-charset="utf-8" id="discoursepassword_form" autocomplete="off">
<form class="passwordform" action="index.cgi?action=discoursepassword&tab=discourse" method="post" onsubmit="discourseSpinner(); return false;" accept-charset="utf-8" id="discoursepassword_form" autocomplete="off">
<div class="row">
<div class="col-sm-10">
<input type="password" name="discoursepassword" id="discoursepassword" autocomplete="off" value="" class="password">
......@@ -54,13 +54,16 @@ END
if (!target) target = "discoursepassword";
\$("#" + target + "_button").prop("disabled", true ).html('Set! <i class="fa fa-cog fa-spin"></i>');
var ser = \$('#' + target + '_form').serialize();
\$("#" + target).prop("disabled", true );
\$.post('index.cgi?action=' + target + '&tab=discourse', ser, function(data) {}
,'json'
).done(function( data ) {
salert(data.message);
\$("#" + target).val('').prop("disabled", false );
\$("#" + target + "_button").prop("disabled", false ).html('Set!');
}).fail(function() {
salert( "An error occurred :(" );
\$("#" + target).prop("disabled", false );
\$("#" + target + "_button").prop("disabled", false ).html('Set!');
});
}
......
......@@ -69,4 +69,4 @@ DESCRIPTION=<div class="app-description">\
<li>Size the server (after installation) as you like.</li>\
</ul>\
</div>\
<div><a href="https://gitlab.origo.io/origosys/stabile-stacks/-/tree/masterubuntu-bionic">Stack source code</a></div>
\ No newline at end of file
<div><a href="https://gitlab.origo.io/origosys/stabile-stacks/-/tree/master/ubuntu-bionic">Stack source code</a></div>
\ No newline at end of file
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