From 586ce3455c330a0099b6af649d2aac26dff0b617 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 19 Oct 2020 21:47:42 +0200 Subject: [PATCH 1/3] eolisation --- db/lemur.sql | 1 + dicos/50_lemur.xml | 2 ++ posttemplate/{00-lemur => 03-lemur} | 6 ++++++ tmpl/lemur.conf.py | 2 +- tmpl/lemur.yml | 4 +++- 5 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 db/lemur.sql rename posttemplate/{00-lemur => 03-lemur} (65%) diff --git a/db/lemur.sql b/db/lemur.sql new file mode 100644 index 00000000..d4971215 --- /dev/null +++ b/db/lemur.sql @@ -0,0 +1 @@ +CREATE EXTENSION pg_trgm; diff --git a/dicos/50_lemur.xml b/dicos/50_lemur.xml index 86b41e61..23495543 100644 --- a/dicos/50_lemur.xml +++ b/dicos/50_lemur.xml @@ -17,11 +17,13 @@ lemur + + diff --git a/posttemplate/00-lemur b/posttemplate/03-lemur similarity index 65% rename from posttemplate/00-lemur rename to posttemplate/03-lemur index cef1ebd5..d1a07bf1 100755 --- a/posttemplate/00-lemur +++ b/posttemplate/03-lemur @@ -5,4 +5,10 @@ set -e # install unrelease python modules pip3 install alembic-autogenerate-enums==0.0.2 asyncpool==1.0 certsrv==2.1.1 cryptography==3.1.1 dnspython3==1.15.0 dyn==1.8.1 flask-replicated==1.4 javaobj-py3==0.4.0.1 jsonlines==1.2.0 logmatic-python==0.1.7 marshmallow==2.20.4 pycryptodomex==3.9.7 pyjks==20.0.0 raven[flask]==6.10.0 twofish==0.3.0 +cd /usr/share/lemur/ +systemctl start postgresql.service +lemur --config=/etc/lemur/lemur.conf.py init --password $(CreoleGet lemur_admin_password) +systemctl stop postgresql.service +rm -f *.log + exit 0 diff --git a/tmpl/lemur.conf.py b/tmpl/lemur.conf.py index fee1aa5c..f8ee4d9f 100644 --- a/tmpl/lemur.conf.py +++ b/tmpl/lemur.conf.py @@ -51,7 +51,7 @@ LOG_FILE = "lemur.log" # modify this if you are not using a local database SQLALCHEMY_DATABASE_PASSWORD = 'replaceme' -SQLALCHEMY_DATABASE_URI = f'postgresql://%%lemur_db_user:{SQLALCHEMY_DATABASE_PASSWORD}@localhost:5432/%%lemur_db_name' +SQLALCHEMY_DATABASE_URI = f'postgresql:///%%lemur_db_name?host=/var/run/postgresql&user=%%lemur_db_user&password={SQLALCHEMY_DATABASE_PASSWORD}' # AWS diff --git a/tmpl/lemur.yml b/tmpl/lemur.yml index fa09b2e3..5c31460a 100644 --- a/tmpl/lemur.yml +++ b/tmpl/lemur.yml @@ -12,5 +12,7 @@ dbport: 5432 dbtype: postgres dbname: %%dbname template: 'template0' +sqlscripts: + - /usr/share/eole/db/lemur/gen/lemur.sql pwd_files: - - {'file': '/etc/lemur/lemur.conf.py', 'pattern': 'SQLALCHEMY_DATABASE_PASSWORD = "'} + - {'file': '/etc/lemur/lemur.conf.py', 'pattern': "SQLALCHEMY_DATABASE_PASSWORD = '"} From f68a1759d649e79d8e54ba2a7a8030aaa59054f2 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 19 Oct 2020 22:38:33 +0200 Subject: [PATCH 2/3] FIX: Do not add urlContextPath to relative path --- gulp/build.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gulp/build.js b/gulp/build.js index eed59503..5aca8094 100644 --- a/gulp/build.js +++ b/gulp/build.js @@ -237,7 +237,7 @@ gulp.task('addUrlContextPath',['addUrlContextPath:revreplace'], function(){ .forEach(function(file){ return gulp.src(file) .pipe(gulpif(urlContextPathExists, replace('api/', argv.urlContextPath + '/api/'))) - .pipe(gulpif(urlContextPathExists, replace('angular/', argv.urlContextPath + '/angular/'))) + .pipe(gulpif(urlContextPathExists, replace('/angular/', '/' + argv.urlContextPath + '/angular/'))) .pipe(gulp.dest(function(file){ return file.base; })) @@ -256,10 +256,9 @@ gulp.task('addUrlContextPath:revreplace', ['addUrlContextPath:revision'], functi var manifest = gulp.src("lemur/static/dist/rev-manifest.json"); var urlContextPathExists = argv.urlContextPath ? true : false; return gulp.src( "lemur/static/dist/index.html") - .pipe(gulpif(urlContextPathExists, revReplace({prefix: argv.urlContextPath + '/', manifest: manifest}, revReplace({manifest: manifest})))) .pipe(gulp.dest('lemur/static/dist')); }) gulp.task('build', ['build:ngviews', 'build:inject', 'build:images', 'build:fonts', 'build:html', 'build:extras']); -gulp.task('package', ['addUrlContextPath', 'package:strip']); \ No newline at end of file +gulp.task('package', ['addUrlContextPath', 'package:strip']); From ebf864c585ca5c5a77afed1ea096b1d2ed6f13f4 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Tue, 20 Oct 2020 22:29:45 +0200 Subject: [PATCH 3/3] lemur.service --- lemur.service | 12 ++++++++++++ posttemplate/03-lemur | 3 +++ tmpl/lemur.conf.py | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 lemur.service diff --git a/lemur.service b/lemur.service new file mode 100644 index 00000000..b5c1dbb3 --- /dev/null +++ b/lemur.service @@ -0,0 +1,12 @@ +[Unit] +Description=Lemur +After=postgresql.service + +[Service] +ExecStart=/usr/bin/lemur start -b 127.0.0.1:8002 -c /etc/lemur/lemur.conf.py +User=lemur +Group=lemur + +[Install] +WantedBy=multi-user.target + diff --git a/posttemplate/03-lemur b/posttemplate/03-lemur index d1a07bf1..52418333 100755 --- a/posttemplate/03-lemur +++ b/posttemplate/03-lemur @@ -11,4 +11,7 @@ lemur --config=/etc/lemur/lemur.conf.py init --password $(CreoleGet lemur_admin_ systemctl stop postgresql.service rm -f *.log +mkdir -p /var/log/lemur/ +chown lemur: /var/log/lemur/ + exit 0 diff --git a/tmpl/lemur.conf.py b/tmpl/lemur.conf.py index f8ee4d9f..740ecc59 100644 --- a/tmpl/lemur.conf.py +++ b/tmpl/lemur.conf.py @@ -44,7 +44,7 @@ METRIC_PROVIDERS = [] # Logging LOG_LEVEL = "DEBUG" -LOG_FILE = "lemur.log" +LOG_FILE = "/var/log/lemur/lemur.log" # Database