Skip to content

Commit

Permalink
New REX config, and updated README.md (#434)
Browse files Browse the repository at this point in the history
* New REX config, and updated README.md

* Updated Rex config

* Modified Rex config removing remote

* Removed random files
  • Loading branch information
droberts-ctrlo authored Jul 22, 2024
1 parent bceec81 commit 6044c47
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 46 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ To run JEST tests, run `yarn test`, to watch any tests and run them according to

### The easy way - (R)?ex

Probably the quickest and easiest way to set up GADS within your environment is using [(R)?ex](http://rexify.org). Set up Rex on your system, and then run `rex -b setup` within the gads root (obviously clone using `git clone https://github.com/ctrlo/GADS -b uiux` first and chdir into the GADS directory) to set up a basic GADS environment on your system.
Probably the quickest and easiest way to set up GADS within your environment is using [(R)?ex](http://rexify.org). Set up Rex on your system (the script `./rex/setup.sh` can be used to set this up for you), and then run `rex -f ./rex/Rexfile -b setup` within the gads root (obviously clone using `git clone https://github.com/ctrlo/GADS -b dev` first and chdir into the GADS directory) to set up a basic GADS environment on your system. If you wish to change any of the configuration before you run the Rexfile, update `./rex/config/gads-config.yml` with your desired configuration.

### The container way (Docker)

From the root folder, run the following command `docker compose up`
This will automatically run the seed script as well.
Access the application on http://localhost and login with `admin@localhost` and password `qwedsa`
Access the application on http://localhost:3000 and login with `admin@localhost` and password `qwedsa`

### Manual package installation

Expand Down
119 changes: 75 additions & 44 deletions rex/Rexfile
Original file line number Diff line number Diff line change
@@ -1,62 +1,93 @@

=pod
GADS - Globally Accessible Data Store
Copyright (C) 2015 Ctrl O Ltd
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
=head2 WARNING
THIS SCRIPT IS NOT SUITABLE FOR PRODUCTION OR REMOTE DEPLOYMENT - IT IS
INTENDED FOR EASE OF DEVELOPMENT AND TESTING ONLY.
=cut

use Rex -feature => [1.4];

use strict;
use warnings;

use feature 'say';

task 'libs', sub {
update_package_db;
pkg "git", ensure => "present";
pkg $_, ensure => "present"
foreach
qw/cpanminus liblua5.3-dev gcc g++ libdatetime-format-sqlite-perl libtest-most-perl libdatetime-set-perl libdbix-class-schema-loader-perl libmagic-dev postgresql-client libpng-dev libssl-dev libpq-dev libjson-perl libsession-token-perl libnet-oauth2-authorizationserver-perl libtext-csv-encoded-perl libcrypt-urandom-perl libhtml-scrubber-perl libtext-markdown-perl libwww-form-urlencoded-xs-perl libstring-camelcase-perl libmail-transport-perl liblog-log4perl-perl libplack-perl libdbd-pg-perl libmail-message-perl libmath-random-isaac-xs-perl libdbix-class-helpers-perl libtree-dagnode-perl libmath-round-perl libdatetime-format-dateparse-perl libwww-mechanize-perl libdatetime-format-iso8601-perl libmoox-types-mooselike-perl libmoox-singleton-perl libdancer2-perl liblist-compare-perl liburl-encode-perl libtie-cache-perl libhtml-fromtext-perl libdata-compare-perl libfile-bom-perl libalgorithm-dependency-perl libdancer-plugin-auth-extensible-perl libfile-libmagic-perl postfix perl/;
};
use YAML;

task 'cypress', sub {
pkg $_, ensure => "present"
foreach
qw/libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libnss3 libxss1 libasound2 libxtst6 xauth xvfb/;
task psql => sub {
pkg "postgresql", ensure => "present";
service postgresql => "ensure", "started";
service postgresql => "ensure", "enabled";
my $config = YAML::LoadFile('rex/config/gads-config.yml')->{config}
or die("No config found");
run 'su -c "psql -c \"CREATE USER '
. $config->{db_user}
. ' WITH PASSWORD \''
. $config->{db_pass}
. '\'\"" postgres';
run 'su -c "psql -c \"CREATE DATABASE '
. $config->{db_name}
. ' OWNER '
. $config->{db_user}
. '\"" postgres';
run 'su -c "psql linkspace -c \"CREATE EXTENSION IF NOT EXISTS citext WITH SCHEMA public;\"" postgres';
};

task 'clone', sub {
chdir '/srv';
run "git clone https://github.com/ctrlo/gads";
task libs => sub {
update_package_db;
pkg [
qw/cpanminus liblua5.3-dev gcc g++ libdatetime-format-sqlite-perl libtest-most-perl libdatetime-set-perl libdbix-class-schema-loader-perl libmagic-dev postgresql-client libpng-dev libssl-dev libpq-dev libjson-perl libsession-token-perl libnet-oauth2-authorizationserver-perl libtext-csv-encoded-perl libcrypt-urandom-perl libhtml-scrubber-perl libtext-markdown-perl libwww-form-urlencoded-xs-perl libstring-camelcase-perl libmail-transport-perl liblog-log4perl-perl libplack-perl libdbd-pg-perl libmail-message-perl libmath-random-isaac-xs-perl libdbix-class-helpers-perl libtree-dagnode-perl libmath-round-perl libdatetime-format-dateparse-perl libwww-mechanize-perl libdatetime-format-iso8601-perl libmoox-types-mooselike-perl libmoox-singleton-perl liblist-compare-perl liburl-encode-perl libtie-cache-perl libhtml-fromtext-perl libdata-compare-perl libfile-bom-perl libalgorithm-dependency-perl libdancer-plugin-auth-extensible-perl libfile-libmagic-perl postfix perl libconvert-asn1-perl libmodule-runtime-perl libcrypt-openssl-random-perl libdancer2-perl libinline-perl libdatetime-perl libdatetime-format-strptime-perl liblist-moreutils-perl liblog-report-perl libpdf-table-perl libtest-mocktime-perl libtext-autoformat-perl libyaml-perl libnamespace-clean-perl make nano libaws-signature4-perl libdata-validate-ip-perl libdevel-caller-perl libhash-merge-perl libio-string-perl libsort-naturally-perl libterm-readkey-perl libtext-glob-perl liburi-perl libxml-simple-perl libversion-perl libfile-sharedir-install-perl libio-pty-perl libdigest-hmac-perl libnet-sftp-foreign-perl libnet-openssh-perl libjson-maybexs-perl libcpanel-json-xs-perl/
], ensure => present;
};

task 'cpan', sub {
chdir '/srv/gads';
run "perl ./bin/output_cpanfile > cpanfile";
run "cpanm --installdeps . --notest --cpanfile ./cpanfile";
task cpan => sub {
update_package_db;
pkg [ "gcc", "g++", "make", "cpanminus" ], ensure => "present";
run "perl ./bin/output_cpanfile.pl > cpanfile";
run "cpanm --installdeps . --cpanfile cpanfile --notest";
};

task 'nvm', sub {
pkg "curl", ensure => 'present';
run "curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash";
run "source ~/.bashrc";
run "nvm install --lts";
run 'npm install -g npm@latest yarn';
task dbconfig => sub {
say "Loading config from config/gads-config.yml";
my $config = YAML::LoadFile('rex/config/gads-config.yml')->{config}
or die("No config found");
run "psql "
. $config->{db_name} . " -h "
. $config->{db_host} . " -U "
. $config->{db_user}
. " -c \"CREATE EXTENSION IF NOT EXISTS citext WITH SCHEMA public;\"";
run "./bin/seed-database.pl --initial_username="
. $config->{gads_user}
. " --instance_name="
. $config->{gads_instance}
. " --site="
. $config->{gads_site};
};

task 'config', sub {
my $db_host = $ENV{DB_HOST} || 'db';
file "/etc/timezone",
content => "Europe/London",
owner => "root",
group => "root",
mode => 644;
append_or_amend_line "/srv/gads/webdriver/config.yml",
line => "dbi:Pg:database=$db_host;host=localhost;port=5432",
regexp => qr/dbi:Pg:database=linkspace;host=localhost;port=5432/,
on_change => sub {
say "Changed db connection string";
};
append_or_amend_line "/srv/gads/bin/setup_database",
line => ': ${PSQL_HOSTNAME:=' . $db_host . '}',
regexp => qr/PSQL_HOSTNAME:=localhost/,
on_change => sub {
say "Changed db hostname";
};
task config => sub {
say "Loading config from config/gads-config.yml";
my $config = YAML::LoadFile('rex/config/gads-config.yml')
or die("No config found");
file "./config.yml", content => template( "files/config.yml.tpl", $config );
};

batch 'setup', 'libs', 'cypress', 'nvm', 'clone', 'cpan', 'config';
batch setup => 'libs', 'psql', 'cpan', 'config', 'dbconfig';
11 changes: 11 additions & 0 deletions rex/config/gads-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
config:
email: '[email protected]'
url: 'http://example.com'
db_name: 'linkspace'
db_user: 'linkspace'
db_pass: 'linkspace'
db_host: 'localhost'
gads_user: '[email protected]'
gads_instance: 'test'
gads_site: 'localhost'

95 changes: 95 additions & 0 deletions rex/files/config.yml.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Linkspace configuration. Also see the files in the "environments"
# directory that extend this configuration.
#
# Your application's name
appname: "Linkspace"

# The default layout to use for your application (located in
# views/layouts/main.tt)
layout: "main"

# when the charset is set to UTF-8 Dancer2 will handle for you
# all the magic of encoding and decoding. You should not care
# about unicode within your app when this setting is set (recommended).
charset: "UTF-8"

# template engine
# simple: default and very basic template engine
# template_toolkit: TT

template: "template_toolkit"

logger: LogReport

session: "YAML"

engines:
session:
YAML:
session_dir: "/tmp/dancer-sessions"
cookie_duration: 3600
cookie_name: linkspace.session
is_secure: 1 # Comment out or remove if using HTTP

gads:
header: "HEADER"
hostlocal: 1 # Whether to fetch files such as jquery.js locally
dateformat: "yyyy-MM-dd" # In CLDR format. Not all options available for datetime picker
email_from: '"Linkspace" <<%= $config->{"email"} %>>' # Emails are sent from this
aup: 0 # Whether to show an acceptable use policy
login_instance: 1 # The config values used for login page
default_instance: 1 # The default instance on login, if more than one
url: <%= $config->{"url"} %> # Used for URLs in overnight email alerts
# legacy_menu: 0
# aup_accept: I accept these terms # Use to change default accept button
message_prefix: |
This email has been generated and sent from Linkspace. Replies
will be directed to the sender of the message.
user_status: 0 # Whether to show user status on login
user_status_message: |
You must accept that you will treat this system with
respect. And be gentle please.

plugins:
LogReport:
session_messages: [ NOTICE, MISTAKE, WARNING, ERROR, FAULT, ALERT, FAILURE, PANIC ]
DBIC:
default:
dsn: dbi:Pg:database=<%= $config->{"db_name"} %>;host=<%= $config->{"db_host"} %>
schema_class: GADS::Schema
user: <%= $config->{"db_user"} %>
password: <%= $config->{"db_pass"} %>
options:
RaiseError: 1
PrintError: 1
quote_names: 1
Auth::Extensible:
no_default_pages: 1
no_login_handler: 1
record_lastlogin: 1
mailer:
module: Mail::Message
options:
via: sendmail
sendmail_options:
- "-f"
- <%= $config->{"email"} %>
mail_from: '"Linkspace Database" <<%= $config->{"email"} %>>'
password_reset_text: GADS::reset_text
welcome_text: GADS::welcome_text
realms:
dbic:
provider: DBIC
user_as_object: 1
users_resultset: User
roles_resultset: Permission
user_roles_resultset: UserPermission
roles_role_column: name
roles_key: permission
password_expiry_days: 60
users_pwchanged_column: pwchanged
users_pwresetcode_column: resetpw
encryption_algorithm: SHA-512
user_valid_conditions:
deleted: ~
account_request: 0
11 changes: 11 additions & 0 deletions rex/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

#THIS SCRIPT IS NOT SUITABLE FOR PRODUCTION OR REMOTE DEPLOYMENT - IT IS INTENDED FOR EASE OF DEVELOPMENT AND TESTING ONLY.

apt-get update
apt-get install -y cpanminus gcc g++ make nano libaws-signature4-perl libdata-validate-ip-perl libdevel-caller-perl libhash-merge-perl
apt-get install -y libio-string-perl libsort-naturally-perl libterm-readkey-perl libtext-glob-perl liburi-perl libxml-simple-perl libyaml-perl
apt-get install -y libversion-perl libfile-sharedir-install-perl libio-pty-perl libdigest-hmac-perl libnet-sftp-foreign-perl libnet-openssh-perl
apt-get install -y libjson-maybexs-perl libcpanel-json-xs-perl

cpanm --notest Rex

0 comments on commit 6044c47

Please sign in to comment.