Commit 719445b9 authored by HQ's avatar HQ
Browse files

Various improvements

parent 2a91eb6f
......@@ -20,7 +20,7 @@ PRICE=-420
VCPU=2
MEMORY=4096
LOGO=https://www.stabile.io/images/apps/logo-discourse.png
THUMBNAIL=https://www.stabile.io/images/apps/thumb-discourse.png
THUMBNAIL=https://www.stabile.io/images/apps/discourse_icon.png
SUMMARY=Discourse is a civilized discussion platform. Use it as a mailing list, forum, long-form chat room, and more!
DESCRIPTION=<div class="app-description">\
Discourse is a from-scratch reboot, an attempt to reimagine what a modern Internet discussion platform should be today, in a world of ubiquitous smartphones, tablets, Facebook, and Twitter. \
......
......@@ -76,4 +76,4 @@ cp -a /tmp/files/stabile/tabs/discourse /usr/share/webmin/stabile/tabs/
cp /tmp/files/stabile-discourse.pl /usr/local/bin/
# Change logo
perl -pi -e 's/images\/ubuntu-logo.png/tabs\/discourse\/logo-discourse.png/' /usr/share/webmin/stabile/index.cgi
perl -pi -e 's/images\/ubuntu-logo.png/tabs\/discourse\/discourse_icon.png/' /usr/share/webmin/stabile/index.cgi
......@@ -26,7 +26,7 @@ unless (-e '/etc/discourse.seeded') {
print `perl -pi -e 's/.*ProxyPass.*\\n//g' /etc/apache2/sites-available/default-ssl.conf`;
}
print `echo "<h1 align=center><img width=48 height=48 src=https://www.origo.io/images/apps/thumb-discourse.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 DATABASE discourse;"`;
print `sudo -u postgres psql -c "CREATE USER discourse;"`;
print `sudo -u postgres psql -c "ALTER USER discourse WITH ENCRYPTED PASSWORD 'password';"`;
......@@ -39,7 +39,7 @@ unless (-e '/etc/discourse.seeded') {
print `cd /var/discourse ; RAILS_ENV=production bundle exec rake assets:precompile`;
my $me_json = `curl -k --silent https://$gw/stabile/users/me`;
my $me_ref = from_json($me_json);
my $email = $me_ref->{'email'};
my $email = $me_ref->[0]->{'email'};
$email = $me_ref->{'usename'} if (!$email || !($email =~ /\@/) || $email eq '--');
print "Adding user $email\n";
my $randpass = `openssl rand -base64 24`;
......@@ -65,3 +65,61 @@ unless (-e '/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 sidekiq -C config/sidekiq.yml &`;
sub get_internalip {
my $internalip;
if (!(-e "/tmp/internalip") && !(-e "/etc/stabile/internalip")) {
$internalip = $1 if (`curl -sk https://$gw/stabile/networks/this` =~ /"internalip" : "(.+)",/);
chomp $internalip;
`echo "$internalip" > /tmp/internalip` if ($internalip);
`mkdir /etc/stabile` unless (-e '/etc/stabile');
`echo "$internalip" > /etc/stabile/internalip` if ($internalip);
} else {
$internalip = `cat /tmp/internalip` if (-e "/tmp/internalip");
$internalip = `cat /etc/stabile/internalip` if (-e "/etc/stabile/internalip");
chomp $internalip;
}
return $internalip;
}
sub get_externalip {
my $externalip;
if (!(-e "/tmp/externalip")) {
$externalip = $1 if (`curl -sk https://$gw/stabile/networks/this` =~ /"externalip" : "(.+)",/);
chomp $externalip;
if ($externalip eq '--') {
# Assume we have ens4 up with an external IP address
$externalip = `ifconfig ens4 | grep -o 'inet addr:\\\S*' | sed -n -e 's/^inet addr://p'`;
chomp $externalip;
}
`echo "$externalip" > /tmp/externalip` if ($externalip);
} else {
$externalip = `cat /tmp/externalip` if (-e "/tmp/externalip");
chomp $externalip;
}
return $externalip;
}
sub get_appid {
my $appid;
if (!(-e "/tmp/appid")) {
$appid = $1 if (`curl -sk https://$gw/stabile/servers?action=getappid` =~ /appid: (.+)/);
chomp $appid;
`echo "$appid" > /tmp/appid` if ($appid);
} else {
$appid = `cat /tmp/appid` if (-e "/tmp/appid");
chomp $appid;
}
return $appid;
}
sub get_appinfo {
my $appinfo;
$appinfo = `curl -sk https://$gw/stabile/servers?action=getappinfo`;
if ($appinfo =~ /^\{/) {
my $json_hash_ref = from_json($appinfo);
return $json_hash_ref;
} else {
return '';
}
}
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