mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
New "make relive" similar to "ejabberdctl live" without installing
Prepare with: ./autogen.sh && ./configure --with-rebar=./rebar3 && make Or use this if you installed Elixir: ./autogen.sh && ./configure --with-rebar=mix && make Start without installing (it recompiles when necessary): make relive It stores config, database and logs in _build/relive/ There's available the well-known script: _build/relive/ejabberdctl Please note this fails immediately: r3:do(compile). This crashes a few seconds later: rebar3:run(["compile"]). Workaround that works correctly: ejabberd_admin:update().
This commit is contained in:
parent
67b5de05c7
commit
adbccbe852
41
Makefile.in
41
Makefile.in
@ -113,6 +113,7 @@ ifeq "$(REBAR_VER)" "6"
|
|||||||
EBINDIR=$(DEPSDIR)/ejabberd/ebin
|
EBINDIR=$(DEPSDIR)/ejabberd/ebin
|
||||||
REBARREL=MIX_ENV=prod $(REBAR) release --overwrite
|
REBARREL=MIX_ENV=prod $(REBAR) release --overwrite
|
||||||
REBARDEV=MIX_ENV=dev $(REBAR) release --overwrite
|
REBARDEV=MIX_ENV=dev $(REBAR) release --overwrite
|
||||||
|
RELIVECMD=escript rel/relive.escript && MIX_ENV=dev RELIVE=true iex --name ejabberd@localhost -S mix run
|
||||||
else
|
else
|
||||||
ifeq "$(REBAR_VER)" "3"
|
ifeq "$(REBAR_VER)" "3"
|
||||||
SKIPDEPS=
|
SKIPDEPS=
|
||||||
@ -130,6 +131,7 @@ endif
|
|||||||
EBINDIR=$(DEPSDIR)/ejabberd/ebin
|
EBINDIR=$(DEPSDIR)/ejabberd/ebin
|
||||||
REBARREL=$(REBAR) as prod tar
|
REBARREL=$(REBAR) as prod tar
|
||||||
REBARDEV=REBAR_PROFILE=dev $(REBAR) release
|
REBARDEV=REBAR_PROFILE=dev $(REBAR) release
|
||||||
|
RELIVECMD=$(REBAR) relive
|
||||||
else
|
else
|
||||||
SKIPDEPS=skip_deps=true
|
SKIPDEPS=skip_deps=true
|
||||||
LISTDEPS=-q list-deps
|
LISTDEPS=-q list-deps
|
||||||
@ -142,6 +144,8 @@ else
|
|||||||
EBINDIR=ebin
|
EBINDIR=ebin
|
||||||
REBARREL=$(REBAR) generate
|
REBARREL=$(REBAR) generate
|
||||||
REBARDEV=
|
REBARDEV=
|
||||||
|
RELIVECMD=@echo "Rebar2 detected... relive not supported.\
|
||||||
|
\nTry: ./configure --with-rebar=./rebar3 ; make relive"
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -268,13 +272,27 @@ copy-files:
|
|||||||
|
|
||||||
copy-files-sub: copy-files-sub2
|
copy-files-sub: copy-files-sub2
|
||||||
|
|
||||||
install: copy-files
|
relive:
|
||||||
#
|
$(RELIVECMD)
|
||||||
# Configuration files
|
|
||||||
$(INSTALL) -d -m 750 $(G_USER) $(ETCDIR)
|
relivedir=$(shell pwd)/_build/relive
|
||||||
[ -f $(ETCDIR)/ejabberd.yml ] \
|
iexpath=$(shell which iex)
|
||||||
&& $(INSTALL) -b -m 640 $(G_USER) ejabberd.yml.example $(ETCDIR)/ejabberd.yml-new \
|
|
||||||
|| $(INSTALL) -b -m 640 $(G_USER) ejabberd.yml.example $(ETCDIR)/ejabberd.yml
|
ejabberdctl.relive:
|
||||||
|
$(SED) -e "s*{{rootdir}}*@prefix@*g" \
|
||||||
|
-e "s*{{installuser}}*@INSTALLUSER@*g" \
|
||||||
|
-e "s*{{bindir}}/iex*$(iexpath)*g" \
|
||||||
|
-e "s*{{bindir}}*@bindir@*g" \
|
||||||
|
-e "s*{{libdir}}*@libdir@*g" \
|
||||||
|
-e "s*{{sysconfdir}}/ejabberd*$(relivedir)/conf*g" \
|
||||||
|
-e "s*{{localstatedir}}/log/ejabberd*$(relivedir)/logs*g" \
|
||||||
|
-e "s*{{localstatedir}}/lib/ejabberd*$(relivedir)/database*g" \
|
||||||
|
-e "s*{{docdir}}*@docdir@*g" \
|
||||||
|
-e "s*{{erl}}*@ERL@*g" \
|
||||||
|
-e "s*{{epmd}}*@EPMD@*g" ejabberdctl.template \
|
||||||
|
> ejabberdctl.relive
|
||||||
|
|
||||||
|
ejabberdctl.example:
|
||||||
$(SED) -e "s*{{rootdir}}*@prefix@*g" \
|
$(SED) -e "s*{{rootdir}}*@prefix@*g" \
|
||||||
-e "s*{{installuser}}*@INSTALLUSER@*g" \
|
-e "s*{{installuser}}*@INSTALLUSER@*g" \
|
||||||
-e "s*{{bindir}}*@bindir@*g" \
|
-e "s*{{bindir}}*@bindir@*g" \
|
||||||
@ -285,6 +303,14 @@ install: copy-files
|
|||||||
-e "s*{{erl}}*@ERL@*g" \
|
-e "s*{{erl}}*@ERL@*g" \
|
||||||
-e "s*{{epmd}}*@EPMD@*g" ejabberdctl.template \
|
-e "s*{{epmd}}*@EPMD@*g" ejabberdctl.template \
|
||||||
> ejabberdctl.example
|
> ejabberdctl.example
|
||||||
|
|
||||||
|
install: copy-files ejabberdctl.example
|
||||||
|
#
|
||||||
|
# Configuration files
|
||||||
|
$(INSTALL) -d -m 750 $(G_USER) $(ETCDIR)
|
||||||
|
[ -f $(ETCDIR)/ejabberd.yml ] \
|
||||||
|
&& $(INSTALL) -b -m 640 $(G_USER) ejabberd.yml.example $(ETCDIR)/ejabberd.yml-new \
|
||||||
|
|| $(INSTALL) -b -m 640 $(G_USER) ejabberd.yml.example $(ETCDIR)/ejabberd.yml
|
||||||
[ -f $(ETCDIR)/ejabberdctl.cfg ] \
|
[ -f $(ETCDIR)/ejabberdctl.cfg ] \
|
||||||
&& $(INSTALL) -b -m 640 $(G_USER) ejabberdctl.cfg.example $(ETCDIR)/ejabberdctl.cfg-new \
|
&& $(INSTALL) -b -m 640 $(G_USER) ejabberdctl.cfg.example $(ETCDIR)/ejabberdctl.cfg-new \
|
||||||
|| $(INSTALL) -b -m 640 $(G_USER) ejabberdctl.cfg.example $(ETCDIR)/ejabberdctl.cfg
|
|| $(INSTALL) -b -m 640 $(G_USER) ejabberdctl.cfg.example $(ETCDIR)/ejabberdctl.cfg
|
||||||
@ -470,6 +496,7 @@ help:
|
|||||||
@echo ""
|
@echo ""
|
||||||
@echo " rel Build a production release"
|
@echo " rel Build a production release"
|
||||||
@echo " dev Build a development release"
|
@echo " dev Build a development release"
|
||||||
|
@echo " relive Start a live ejabberd in _build/relive/"
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo " edoc Generate edoc documentation (unused)"
|
@echo " edoc Generate edoc documentation (unused)"
|
||||||
@echo " options Generate ejabberd_option.erl"
|
@echo " options Generate ejabberd_option.erl"
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
import Config
|
import Config
|
||||||
|
|
||||||
rootpath = System.get_env("RELEASE_ROOT", "")
|
case System.get_env("RELIVE", "false") do
|
||||||
|
"true" ->
|
||||||
# This is standard path in the context of ejabberd release
|
rootpath = System.get_env("RELEASE_ROOT", "_build/relive")
|
||||||
config :ejabberd,
|
config :ejabberd,
|
||||||
|
file: Path.join(rootpath, "conf/ejabberd.yml"),
|
||||||
|
log_path: Path.join(rootpath, 'logs/ejabberd.log')
|
||||||
|
config :mnesia,
|
||||||
|
dir: Path.join(rootpath, 'database/')
|
||||||
|
"false" ->
|
||||||
|
rootpath = System.get_env("RELEASE_ROOT", "")
|
||||||
|
config :ejabberd,
|
||||||
file: Path.join(rootpath, "etc/ejabberd/ejabberd.yml"),
|
file: Path.join(rootpath, "etc/ejabberd/ejabberd.yml"),
|
||||||
log_path: Path.join(rootpath, 'var/log/ejabberd/ejabberd.log')
|
log_path: Path.join(rootpath, 'var/log/ejabberd/ejabberd.log')
|
||||||
|
config :mnesia,
|
||||||
# Customize Mnesia directory:
|
|
||||||
config :mnesia,
|
|
||||||
dir: Path.join(rootpath, 'var/lib/ejabberd/')
|
dir: Path.join(rootpath, 'var/lib/ejabberd/')
|
||||||
|
end
|
||||||
|
@ -215,6 +215,12 @@
|
|||||||
{copy, "test/ejabberd_SUITE_data/cert.pem", "etc/ejabberd/"}]}]}]},
|
{copy, "test/ejabberd_SUITE_data/cert.pem", "etc/ejabberd/"}]}]}]},
|
||||||
{test, [{erl_opts, [nowarn_export_all]}]}]}.
|
{test, [{erl_opts, [nowarn_export_all]}]}]}.
|
||||||
|
|
||||||
|
{alias, [{relive, [{shell, "--apps ejabberd \
|
||||||
|
--config rel/relive.config \
|
||||||
|
--script rel/relive.escript \
|
||||||
|
--name ejabberd@localhost"}]}
|
||||||
|
]}.
|
||||||
|
|
||||||
%% Local Variables:
|
%% Local Variables:
|
||||||
%% mode: erlang
|
%% mode: erlang
|
||||||
%% End:
|
%% End:
|
||||||
|
3
rel/relive.config
Normal file
3
rel/relive.config
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[{mnesia, [{dir, "_build/relive/database"}]},
|
||||||
|
{ejabberd, [{config, "_build/relive/conf/ejabberd.yml"},
|
||||||
|
{log_path, "_build/relive/logs/ejabberd.log"}]}].
|
26
rel/relive.escript
Normal file
26
rel/relive.escript
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env escript
|
||||||
|
|
||||||
|
main(_) ->
|
||||||
|
Base = "_build/relive",
|
||||||
|
prepare(Base, "", none),
|
||||||
|
prepare(Base, "conf", {os, cmd, "rel/setup-relive.sh"}),
|
||||||
|
prepare(Base, "database", none),
|
||||||
|
prepare(Base, "logs", none),
|
||||||
|
c:erlangrc([os:cmd("echo -n $HOME")]),
|
||||||
|
ok.
|
||||||
|
|
||||||
|
prepare(BaseDir, SuffixDir, MFA) ->
|
||||||
|
Dir = filename:join(BaseDir, SuffixDir),
|
||||||
|
case file:make_dir(Dir) of
|
||||||
|
ok ->
|
||||||
|
io:format("Preparing relive dir ~s...~n", [Dir]),
|
||||||
|
case MFA of
|
||||||
|
none -> ok;
|
||||||
|
{M, F, A} -> M:F(A)
|
||||||
|
end;
|
||||||
|
{error, eexist} ->
|
||||||
|
ok;
|
||||||
|
{error, LogsError} ->
|
||||||
|
io:format("Error creating dir ~s: ~p~n", [Dir, LogsError]),
|
||||||
|
halt(1)
|
||||||
|
end.
|
30
rel/setup-relive.sh
Executable file
30
rel/setup-relive.sh
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
PWD_DIR=`pwd`
|
||||||
|
REL_DIR=$PWD_DIR/_build/relive/
|
||||||
|
CON_DIR=$REL_DIR/conf/
|
||||||
|
|
||||||
|
[ -z "$REL_DIR_TEMP" ] && REL_DIR_TEMP=$REL_DIR
|
||||||
|
CON_DIR_TEMP=$REL_DIR_TEMP/conf/
|
||||||
|
|
||||||
|
make ejabberdctl.relive
|
||||||
|
chmod +x ejabberdctl.relive
|
||||||
|
mv ejabberdctl.relive $REL_DIR/ejabberdctl
|
||||||
|
|
||||||
|
cp inetrc $CON_DIR/
|
||||||
|
cp ejabberdctl.cfg.example $CON_DIR/ejabberdctl.cfg.example
|
||||||
|
cp ejabberd.yml.example $CON_DIR/ejabberd.yml.example
|
||||||
|
cp test/ejabberd_SUITE_data/ca.pem $CON_DIR
|
||||||
|
cp test/ejabberd_SUITE_data/cert.pem $CON_DIR
|
||||||
|
|
||||||
|
cd $CON_DIR_TEMP
|
||||||
|
|
||||||
|
sed -i "s|# certfiles:|certfiles:\n - $CON_DIR/cert.pem|g" ejabberd.yml.example
|
||||||
|
sed -i "s|certfiles:|ca_file: $CON_DIR/ca.pem\ncertfiles:|g" ejabberd.yml.example
|
||||||
|
sed -i 's|^acl:$|acl:\n admin: [user: admin]|g' ejabberd.yml.example
|
||||||
|
[ ! -f "$CON_DIR/ejabberd.yml" ] \
|
||||||
|
&& echo -n "ejabberd.yml " \
|
||||||
|
&& mv ejabberd.yml.example ejabberd.yml
|
||||||
|
|
||||||
|
sed -i "s|#' POLL|EJABBERD_BYPASS_WARNINGS=true\n\n#' POLL|g" ejabberdctl.cfg.example
|
||||||
|
[ ! -f "$CON_DIR/ejabberdctl.cfg" ] \
|
||||||
|
&& echo -n "ejabberdctl.cfg " \
|
||||||
|
&& mv ejabberdctl.cfg.example ejabberdctl.cfg
|
@ -40,7 +40,7 @@
|
|||||||
%% Cluster
|
%% Cluster
|
||||||
join_cluster/1, leave_cluster/1, list_cluster/0,
|
join_cluster/1, leave_cluster/1, list_cluster/0,
|
||||||
%% Erlang
|
%% Erlang
|
||||||
update_list/0, update/1,
|
update_list/0, update/1, update/0,
|
||||||
%% Accounts
|
%% Accounts
|
||||||
register/3, unregister/2,
|
register/3, unregister/2,
|
||||||
registered_users/1,
|
registered_users/1,
|
||||||
@ -540,6 +540,15 @@ update_module(ModuleNameString) ->
|
|||||||
{error, Reason} -> {error, Reason}
|
{error, Reason} -> {error, Reason}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
update() ->
|
||||||
|
io:format("Compiling ejabberd...~n", []),
|
||||||
|
os:cmd("make"),
|
||||||
|
Mods = ejabberd_admin:update_list(),
|
||||||
|
io:format("Updating modules: ~p~n", [Mods]),
|
||||||
|
ejabberd_admin:update("all"),
|
||||||
|
io:format("Updated modules: ", []),
|
||||||
|
Mods -- ejabberd_admin:update_list().
|
||||||
|
|
||||||
%%%
|
%%%
|
||||||
%%% Account management
|
%%% Account management
|
||||||
%%%
|
%%%
|
||||||
|
Loading…
Reference in New Issue
Block a user