summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJannis M. Hoffmann <jannis@fehcom.de>2023-09-29 19:03:40 +0200
committerJannis M. Hoffmann <jannis@fehcom.de>2023-09-29 19:03:40 +0200
commit80f8160370b297f7c81f9d77d9f6f8046634c259 (patch)
tree77c125769d2c5fe92b89f29df99ba132d2ec3aaf
parent3298617b8724f1827ae4fae2232795c66ed07161 (diff)
add global paths
-rwxr-xr-xconfigure16
-rw-r--r--confninja.sh12
-rw-r--r--install/jwebmail.service.in (renamed from install/jwebmail.service)2
-rw-r--r--lib/JWebmail.pm5
-rw-r--r--lib/JWebmail/Config.pm.in3
5 files changed, 25 insertions, 13 deletions
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.in
index a49e07f..afd0f17 100644
--- a/install/jwebmail.service
+++ b/install/jwebmail.service.in
@@ -7,7 +7,7 @@ Type=exec
ExecStart=hypnotoad -f jwebmail
ExecReload=hypnotoad -f jwebmail
PIDFile=/run/jwebmail/hypnotoad.pid
-Environment=MOJO_LOG_SHORT=1
+Environment=MOJO_LOG_SHORT=1 MOJO_CONFIG=@DESTDIR@@PREFIX@/@CONFDIR@/jwebmail.toml
User=jwebmail
[Install]
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