move config around
diff --git a/etc/couchdb/default.d/couchperuser.ini b/priv/default.d/couchperuser.ini
similarity index 100%
rename from etc/couchdb/default.d/couchperuser.ini
rename to priv/default.d/couchperuser.ini
diff --git a/rebar.config.script b/rebar.config.script
index 73d0543..1565588 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -1,18 +1,27 @@
%% -*- mode: erlang -*-
-try
- begin
- Cfg = os:cmd("couch-config --erl-libs-dir --couch-version"),
- [LibDir, Version] = string:tokens(Cfg, "\n"),
- true = filelib:is_dir(LibDir),
- code:add_path(filename:join([LibDir, "couch-" ++ Version, "ebin"])),
- CONFIG
- end
-catch
- _Err:_What ->
- io:format(
- "CONFIG ERROR:\n"
- "Failed to run couch-config --erl-libs-dir --couch-version\n"
- "Ensure that couch-config is on the PATH, or set ERL_LIBS "
- "appropriately\n\n"),
- CONFIG
-end.
+%%
+%% This doesn't change CONFIG. If couch isn't accessible to the code server,
+%% it adds paths from couch-config. This is equivalent to:
+%%
+%% ERL_LIBS=$(couch-config --erl-libs-dir):$ERL_LIBS rebar compile
+%%
+case code:which(couch) of
+ non_existing ->
+ try
+ Cfg = os:cmd("couch-config --erl-libs-dir"),
+ [LibDir] = string:tokens(Cfg, "\n"),
+ true = filelib:is_dir(LibDir),
+ code:add_pathsa(
+ filelib:wildcard(filename:join([LibDir, "*", "ebin"]))),
+ false = (code:which(couch) =:= non_existing)
+ catch _Err:_What ->
+ io:format(
+ "CONFIG ERROR:\n"
+ "Failed to run couch-config --erl-libs-dir\n"
+ "Ensure that couch-config is on the PATH, or set ERL_LIBS "
+ "appropriately\n\n")
+ end;
+ _ ->
+ ok
+end,
+CONFIG.