Skip to content

Commit 9a7f69d

Browse files
committed
Initial version with most important hooks in place
0 parents  commit 9a7f69d

10 files changed

+146
-0
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.eunit
2+
*.o
3+
*.beam
4+
*.plt
5+
*.app

LICENSE

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Copyright (c) 2015, Grzegorz Junka
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
* Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
* Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

priv/local_setup.conf

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
%% -*- mode: erlang -*-
2+
{dummy_value1, abc}.
3+
{dummy_value2, def}.
4+
{dummy_port, 123}.

src/builderl_sample_setup.app.src

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
%% -*- erlang -*-
2+
{application, builderl_sample_setup,
3+
[{description, "Example of an installation and configuration application"},
4+
{vsn, "=VSN="},
5+
{modules,
6+
[
7+
=MODULES=
8+
]},
9+
{registered, []},
10+
{applications, [kernel, stdlib]}
11+
]}.

src/cmd_config.erl

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-module(cmd_config).
2+
3+
-export([
4+
subfolders/0,
5+
key_replace/4,
6+
process_config/4
7+
]).
8+
9+
subfolders() ->
10+
{ok,
11+
[<<"mnesia_backups">>,
12+
<<"other_folder">>]}.
13+
14+
key_replace(_Base, _Name, Offset, RunVars) ->
15+
{_, _Host} = proplists:get_value(hostname, RunVars),
16+
17+
{ok,
18+
[
19+
{<<"=EXAMPLE_IP=">>, <<"0.0.0.0">>},
20+
{<<"=EXAMPLE_PORT=">>, integer_to_list(8080 + Offset), [global]}
21+
]}.
22+
23+
process_config({resource_discovery, _Name, _PrivDir},
24+
_CfgDir, _CfgArgs, _Privs) ->
25+
%% Some custom configuration instructions for resource_discovery
26+
true;
27+
process_config(_App, _Dest, _CfgArgs, _Privs) ->
28+
false.

src/common_config.erl

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-module(common_config).
2+
3+
-export([load_config/1]).
4+
5+
-define(DEFAULT_CONFIG_FILENAME, "local_setup.conf").
6+
7+
load_config(SetupCfg) ->
8+
Name = proplists:get_value(default_config,
9+
SetupCfg, ?DEFAULT_CONFIG_FILENAME),
10+
File = filename:join(code:priv_dir(builderl_sample_setup), Name),
11+
12+
io:format("Using configuration file: ~p~n", [File]),
13+
{ok, Config} = file:consult(File),
14+
Replace = proplists:get_value(install_key_replace, SetupCfg, []),
15+
io:format("But replacing the following keys:~n~p~n", [Replace]),
16+
bld_init:merge_config(Config, Replace).

src/htif_config.erl

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
-module(htif_config).
2+
3+
-export([install/2]).
4+
5+
log(F0, A0) ->
6+
F1 = "~p:~p: " ++ F0 ++ "~n",
7+
A1 = [?MODULE, ?LINE] ++ A0,
8+
io:format(F1, A1).
9+
10+
install({_Id, _Node}, SetupCfg) ->
11+
Config = common_config:load_config(SetupCfg),
12+
log("Config file: ~p~n", [Config]),
13+
14+
ok.

src/sc_config.erl

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
-module(sc_config).
2+
3+
-export([install/2]).
4+
5+
log(F0, A0) ->
6+
F1 = "~p:~p: " ++ F0 ++ "~n",
7+
A1 = [?MODULE, ?LINE] ++ A0,
8+
io:format(F1, A1).
9+
10+
install(Cluster, SetupCfg) ->
11+
Config = common_config:load_config(SetupCfg),
12+
log("Config file: ~p~n", [Config]),
13+
14+
Nodes = [Remote || {_Id, Remote} <- Cluster],
15+
16+
ok = mnesia:create_schema(Nodes),
17+
verify(rpc:multicall(Nodes, mnesia, start, [])),
18+
19+
%% application:start(inets),
20+
ok.
21+
22+
verify({OKs, []} = Err) ->
23+
lists:usort(OKs) =:= [ok] orelse verify_error(Err);
24+
verify({[ok], []}) ->
25+
ok;
26+
verify(Err) ->
27+
verify_error(Err).
28+
29+
verify_error(Err) ->
30+
io:format(standard_error, "Returned error:'~p', aborting...~n", [Err]).

src/tcif_config.erl

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
-module(tcif_config).
2+
3+
-export([install/2]).
4+
5+
log(F0, A0) ->
6+
F1 = "~p:~p: " ++ F0 ++ "~n",
7+
A1 = [?MODULE, ?LINE] ++ A0,
8+
io:format(F1, A1).
9+
10+
install({_Id, _Node}, SetupCfg) ->
11+
Config = common_config:load_config(SetupCfg),
12+
log("Config file: ~p~n", [Config]),
13+
14+
ok.

src/vsn.mk

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VSN = 0.1

0 commit comments

Comments
 (0)