Skip to content

Commit

Permalink
Support ETURNAL_ETC_DIR, not ETURNAL_ETC_PREFIX
Browse files Browse the repository at this point in the history
Allow for specifying the full path to the directory containing the
eturnal.yml file, rather than hard-coding the last component to be named
"etc".  The ETURNAL_ETC_DIR default can be specified at build time and
overridden at run time.
  • Loading branch information
weiss committed Jul 28, 2023
1 parent e2866c1 commit ebe78c5
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 18 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ project adheres to [Semantic Versioning][SemVer].
for macOS.

### Changed
- The environment variable `ETURNAL_ETC_PREFIX` has been deprecated in favor of
`ETURNAL_ETC_DIR`. If the former was used with previous releases,
`ETURNAL_ETC_DIR` should now be set to `$ETURNAL_ETC_PREFIX/etc`.
- `mod_stats_prometheus`: Fine tune bucket sizes for TURN sessions, e.g., drop
the 1 KiB bucket, as the 4 KiB bucket size should be sufficient to identify
"inactive" sessions. Also, slightly alter the other bucket sizes.
Expand Down
2 changes: 1 addition & 1 deletion Formula/eturnal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def install
end
## change default default config dir
inreplace "config/sys.config" do |s|
s.gsub! "$ETURNAL_ETC_PREFIX/etc/#{name}.yml", "#{etc}/#{name}.yml"
s.gsub! "$ETURNAL_ETC_DIR/#{name}.yml", "#{etc}/#{name}.yml"
end
## !!! patch eturnalctl script, !!!
## !!! remove before updating to newer version than 1.10.1 !!!
Expand Down
1 change: 1 addition & 0 deletions build.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

{eturnal_user, "eturnal"}. % The user running eturnal.
{eturnal_prefix, "/opt/eturnal"}. % The installation directory.
{eturnal_etc_dir, "/etc"}. % The directory containing the eturnal.yml.
{erl_epmd_address, "127.0.0.1"}. % See <https://erlang.org/doc/man/epmd.html>.
{erl_dist_port, ""}. % Specify a port number to avoid spawning EPMD.
{code_loading, "static"}. % Specify "dynamic" to avoid hard-coded dep versions.
2 changes: 1 addition & 1 deletion config/sys.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
#{single_line => false,
template => ["[", level, "] ", msg, "\n"]}}}}]}]},
{conf,
[{file, "$ETURNAL_ETC_PREFIX/etc/eturnal.yml"},
[{file, "$ETURNAL_ETC_DIR/eturnal.yml"},
{on_fail, halt}]}].
15 changes: 7 additions & 8 deletions doc/overview.edoc
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ The eturnal server is configured by editing the `eturnal.yml' file (and
optionally setting one or more {@section Environment Variables}). If
`/etc/eturnal.yml' doesn't exist, eturnal will (by default) search for
`etc/eturnal.yml' within the installation directory. In order to use a different
path, the environment variable {@section ETURNAL_ETC_PREFIX} can be specified.
As an alternative, the arguments ``-conf file '"/path/to/eturnal.yml"''' (note
the double quoting) can be appended to the `eturnalctl' command line used for <a
path, the environment variable {@section ETURNAL_ETC_DIR} can be specified. As
an alternative, the arguments ``-conf file '"/path/to/eturnal.yml"''' (note the
double quoting) can be appended to the `eturnalctl' command line used for <a
href="#daemon">starting up</a> eturnal.

The `eturnal.yml' file uses the <a
Expand Down Expand Up @@ -626,12 +626,11 @@ Setting this environment variable tells EPMD to listen on the specified port. By
default, EPMD listens on port 4369. `ERL_EPMD_PORT' must be set to the same port
number during eturnal startup and when calling `eturnalctl'.

=== ETURNAL_ETC_PREFIX ===
=== ETURNAL_ETC_DIR ===

This environment variable specifies the path to the `etc' directory containing
the `eturnal.yml' configuration file. If, for example, `ETURNAL_ETC_PREFIX' is
set to `/usr/local/opt/eturnal', the file
`/usr/local/opt/eturnal/etc/eturnal.yml' will be used.
This environment variable specifies the directory containing the `eturnal.yml'
configuration file. If, for example, `ETURNAL_ETC_DIR' is set to
`/usr/local/etc', the file `/usr/local/etc/eturnal.yml' will be used.

=== ETURNAL_RELAY_IPV4_ADDR ===

Expand Down
2 changes: 1 addition & 1 deletion docker-k8s/examples/docker-compose/eturnal.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ERL_DIST_PORT=
#ERL_EPMD_ADDRESS=127.0.0.1
#ERL_EPMD_PORT=
#ETURNAL_ETC_PREFIX=
#ETURNAL_ETC_DIR=
#ETURNAL_RELAY_IPV4_ADDR=
#ETURNAL_RELAY_IPV6_ADDR=
#ETURNAL_RELAY_MAX_PORT=65535
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#ERL_DIST_PORT=
#ERL_EPMD_ADDRESS=127.0.0.1
#ERL_EPMD_PORT=
#ETURNAL_ETC_PREFIX=
#ETURNAL_ETC_DIR=
#ETURNAL_RELAY_IPV4_ADDR=
#ETURNAL_RELAY_IPV6_ADDR=
#ETURNAL_RELAY_MAX_PORT=65535
#ETURNAL_RELAY_MIN_PORT=49152
#LOGS_DIRECTORY=
#RUNTIME_DIRECTORY=
#STUN_SERVICE=false
#STUN_SERVICE=false
5 changes: 3 additions & 2 deletions scripts/eturnalctl
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ set -u

user="${ETURNAL_USER:-{{eturnal_user}}}"
prefix="${ETURNAL_PREFIX:-{{eturnal_prefix}}}"
etc_dir="${ETURNAL_ETC_DIR:-{{eturnal_etc_dir}}}"
epmd_address="${ERL_EPMD_ADDRESS:-{{erl_epmd_address}}}"
dist_port="${ERL_DIST_PORT:-{{erl_dist_port}}}"
code_loading="${CODE_LOADING_MODE:-{{code_loading}}}"
config_file="${ETURNAL_ETC_PREFIX-}/etc/eturnalctl.cfg"
config_file="${etc_dir:-/etc}/eturnalctl.cfg"

# END OF CONFIGURATION SECTION.

Expand Down Expand Up @@ -65,7 +66,7 @@ find_eturnal_yml()
{
set -- \
"$(printf '%s' "$*" | sed -n 's/.*-conf file "\([^"][^"]*\)".*/\1/p')" \
"${ETURNAL_ETC_PREFIX-}/etc/eturnal.yml" \
"${etc_dir:-/etc}/eturnal.yml" \
"$release_dir/etc/eturnal.yml" \
'/dev/null'

Expand Down
18 changes: 16 additions & 2 deletions scripts/hooks/pre_start
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
if ! [ -e "$ETURNAL_ETC_PREFIX/etc/eturnal.yml" ]
if [ -n "${ETURNAL_ETC_PREFIX+x}" ]
then
export ETURNAL_ETC_PREFIX="$RELEASE_ROOT_DIR"
echo "Warning: ETURNAL_ETC_PREFIX is deprecated." >&2
echo "Warning: Set ETURNAL_ETC_DIR=$ETURNAL_ETC_PREFIX/etc instead." >&2
export ETURNAL_ETC_DIR="$ETURNAL_ETC_PREFIX/etc"
fi

if ! [ -e "$ETURNAL_ETC_DIR/eturnal.yml" ]
then
for dir in '/etc' "$RELEASE_ROOT_DIR/etc"
do
if [ -e "$dir/eturnal.yml" ]
then
export ETURNAL_ETC_DIR="$dir"
break
fi
done
fi

# Until https://github.com/erlware/relx/issues/905 is fixed:
Expand Down
2 changes: 1 addition & 1 deletion windows/make-installer
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ grep -q 'mkdir, "log"' 'rebar.config' ||
sed -i -e '/TLS certificate/,+3d' \
-e 's|#log_dir.*|log_dir: "@INSTALL_DIR@/log"\
run_dir: "@INSTALL_DIR@/run"|' 'config/eturnal.yml'
sed -i 's/$ETURNAL_ETC_PREFIX/@INSTALL_DIR@/' 'config/sys.config'
sed -i 's|$ETURNAL_ETC_DIR|@INSTALL_DIR@/etc|' 'config/sys.config'

echo "$myself: Cleaning $rel_name repository ..."
rm -rf '_build'
Expand Down

0 comments on commit ebe78c5

Please sign in to comment.