Skip to content

Instantly share code, notes, and snippets.

@keynslug
Created December 17, 2021 12:09
Show Gist options
  • Save keynslug/e1f07744741fcffba8bf22d645338552 to your computer and use it in GitHub Desktop.
Save keynslug/e1f07744741fcffba8bf22d645338552 to your computer and use it in GitHub Desktop.
#!/usr/bin/env escript
%%! +sbtu +A0 -noshell -boot start_clean
main([Config]) ->
validate_config(Config);
main([]) ->
validate_config(find_sys_config()).
validate_config(Config) ->
Me = filename:basename(os:getenv("ESCRIPT_NAME")),
case file:consult(Config) of
{ok, _} ->
_ = io:format(standard_io, "[~s] ~s is ok~n", [Me, Config]),
erlang:halt(0);
{error, Terms} ->
_ = io:format(standard_io, "[~s] ~s is INVALID: ~0p~n", [Me, Config, Terms]),
erlang:halt(1)
end.
find_sys_config() ->
RootDir = os:getenv("RELEASE_ROOT_DIR"),
ReleaseVsn = os:getenv("RELEASE_VSN"),
filename:join([RootDir, "releases", ReleaseVsn, "sys.config"]).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment