From 80f8160370b297f7c81f9d77d9f6f8046634c259 Mon Sep 17 00:00:00 2001 From: "Jannis M. Hoffmann" Date: Fri, 29 Sep 2023 19:03:40 +0200 Subject: add global paths --- configure | 16 ++++++++++++---- confninja.sh | 12 ++++++------ install/jwebmail.service | 14 -------------- install/jwebmail.service.in | 14 ++++++++++++++ lib/JWebmail.pm | 5 ++++- lib/JWebmail/Config.pm.in | 3 ++- 6 files changed, 38 insertions(+), 26 deletions(-) delete mode 100644 install/jwebmail.service create mode 100644 install/jwebmail.service.in diff --git a/configure b/configure index 193e999..428f89a 100755 --- a/configure +++ b/configure @@ -45,7 +45,8 @@ if readlink /sbin/init | grep -q systemd then JWM_INIT=systemd fi -eval PERL_PATH="$(perl -V::installsitelib)" +eval PERL_LIB_PATH="$(perl -V::installsitelib)" +eval PERL_BIN_PATH="$(perl -V::installsitebin)" allargs="$*" while getopts 'c:d:e:i:hm:p:P:' opt @@ -55,7 +56,7 @@ do case $opt in (c) JWM_LOGIN_SCHEME="$OPTARG";; (d) DESTDIR="$OPTARG";; (p) PREFIX="$OPTARG";; - (P) PERL_PATH="$OPTARG";; + (P) PERL_LIB_PATH="$OPTARG";; (i) JWM_INIT="$OPTARG";; (h) t="$(printf '\t')" @@ -69,7 +70,7 @@ usage: $0 configure [options...] -c LOGIN_SCHEME plain {plain,cram_md5} The login scheme (don't use plain unless over TLS) -d DESTDIR / Install root -p PREFIX usr/local {usr,usr/local} Install prefix - -P PATH $PERL_PATH$t$t Perl install path + -P PATH $PERL_LIB_PATH$t$t Perl install path -i INIT $JWM_INIT $t{,systemd} Init system to install service files for END exit @@ -138,7 +139,14 @@ export JWM_MODE export JWM_INIT export DESTDIR export PREFIX -export PERL_PATH +export PERL_LIB_PATH +export PERL_BIN_PATH +export DATADIR="share/jwebmail" +if [ "$PREFIX" = usr ] +then export CONFDIR="../etc" +else export CONFDIR="etc" +fi perl -pe 's/@(\w+)@/$ENV{$1}/ga' lib/JWebmail/Config.pm.in >|lib/JWebmail/Config.pm +perl -pe 's/@(\w+)@/$ENV{$1}/ga' install/jwebmail.service.in >|install/jwebmail.service sh confninja.sh >|build.ninja diff --git a/confninja.sh b/confninja.sh index 5d01d3d..a8f69be 100644 --- a/confninja.sh +++ b/confninja.sh @@ -44,7 +44,7 @@ END # CONFIGURE echo "confargs = $CONFARGS" -echo "build build.ninja lib/JWebmail/Config.pm: configure configure confninja.sh lib/JWebmail/Config.pm.in" +echo "build build.ninja lib/JWebmail/Config.pm install/jwebmail.service: configure configure confninja.sh lib/JWebmail/Config.pm.in install/jwebmail.service.in" case "$JWM_MODE" in (development) @@ -121,8 +121,8 @@ echo "destdir = $DESTDIR" echo "prefix = $PREFIX" echo "bindir = \$prefix/bin" -echo "scriptdir = \$prefix/bin" -echo "perldir = $PERL_PATH" +echo "scriptdir = $PERL_BIN_PATH" +echo "perldir = $PERL_LIB_PATH" if [ "$PREFIX" = usr ] then echo "confdir = \$prefix/../etc" else echo "confdir = \$prefix/etc" @@ -135,7 +135,7 @@ ALL_INST= case "$MAILDIR_EXTRACTOR_NAME" in (extractrs) install_file instexec \$bindir bin jwebmail-extract;; - (extractpy) install_file instexec \$scriptdir script extract.py;; + (extractpy) install_file instexec \$bindir script extract.py;; (extractpl) install_file instexec \$scriptdir script extract.pl;; esac @@ -223,8 +223,8 @@ templates/exception_.html.ep templates/not_found.html.ep END -install_file instdata \$confdir . jwebmail.development.toml -install_file instdata \$confdir . jwebmail.production.toml +echo "build \$destdir/\$confdir/jwebmail.toml: instdata jwebmail.production.toml" +ALL_INST="$ALL_INST \$destdir/\$confdir/jwebmail.toml" for f in CHANGES.md LICENSE README.md do install_file instdata \$docdir . "$f" diff --git a/install/jwebmail.service b/install/jwebmail.service deleted file mode 100644 index a49e07f..0000000 --- a/install/jwebmail.service +++ /dev/null @@ -1,14 +0,0 @@ -[Unit] -Description=JWebmail managed by hypnotoad -After=network.target - -[Service] -Type=exec -ExecStart=hypnotoad -f jwebmail -ExecReload=hypnotoad -f jwebmail -PIDFile=/run/jwebmail/hypnotoad.pid -Environment=MOJO_LOG_SHORT=1 -User=jwebmail - -[Install] -WantedBy=multi-user.target diff --git a/install/jwebmail.service.in b/install/jwebmail.service.in new file mode 100644 index 0000000..afd0f17 --- /dev/null +++ b/install/jwebmail.service.in @@ -0,0 +1,14 @@ +[Unit] +Description=JWebmail managed by hypnotoad +After=network.target + +[Service] +Type=exec +ExecStart=hypnotoad -f jwebmail +ExecReload=hypnotoad -f jwebmail +PIDFile=/run/jwebmail/hypnotoad.pid +Environment=MOJO_LOG_SHORT=1 MOJO_CONFIG=@DESTDIR@@PREFIX@/@CONFDIR@/jwebmail.toml +User=jwebmail + +[Install] +WantedBy=multi-user.target diff --git a/lib/JWebmail.pm b/lib/JWebmail.pm index 92c5b44..c95e481 100644 --- a/lib/JWebmail.pm +++ b/lib/JWebmail.pm @@ -4,7 +4,7 @@ use Mojo::Base Mojolicious; use Module::Load 'load'; -use JWebmail::Config 'LOGIN_SCHEME'; +use JWebmail::Config qw'LOGIN_SCHEME DATADIR'; use JWebmail::Controller::Webmail; use JWebmail::Model::ReadMails::QMailAuthuser; use JWebmail::Model::WriteMails; @@ -60,6 +60,9 @@ sub startup { my $write = JWebmail::Model::WriteMails->new($self->config->{model}{write}); $self->helper(send_mail => sub { $write->sendmail($_[1]) }); + push $self->renderer->paths->@*, DATADIR . '/templates'; + push $self->static->paths->@*, DATADIR . '/public'; + $self->validator->add_check(mail_line => \&_mail_line); $self->validator->add_filter(non_empty_ul => \&_filter_empty_upload); diff --git a/lib/JWebmail/Config.pm.in b/lib/JWebmail/Config.pm.in index a899024..91c40c6 100644 --- a/lib/JWebmail/Config.pm.in +++ b/lib/JWebmail/Config.pm.in @@ -5,11 +5,12 @@ use warnings; use utf8; use Exporter 'import'; -our @EXPORT_OK = qw(MAILDIR_EXTRACTOR LOGIN_SCHEME); +our @EXPORT_OK = qw(MAILDIR_EXTRACTOR LOGIN_SCHEME DATADIR); use constant { MAILDIR_EXTRACTOR => '@MAILDIR_EXTRACTOR_BIN@', LOGIN_SCHEME => fc '@LOGIN_SCHEME@', + DATADIR => '@DESTDIR@@PREFIX@/@DATADIR@', }; 1 -- cgit v1.2.3