3 % Execute remotly after the files has been copied.
4 % Reload all modules et update the database.
5 % TODO: build the node name from the host name.
10 % le premier argument est le nom du noeud est peut valoir :
11 % - yaws : noeud de production
12 % - yaws_dev : noeud de pre-production
13 main([Node_name
]) when Node_name
=:= "yaws"; Node_name
=:= "yaws_dev" ->
14 Node
= list_to_atom(Node_name
++ atom_to_list(hote())),
15 net_kernel:start([flynux
, shortnames
]),
16 io:format("reloading modules...~n"),
17 rpc:call(Node
, euphorik_daemon
, reload_euphorik
, []),
18 if Node_name
=:= "yaws_dev" -> copy_database(Node
);
21 io:format("updating database...~n"),
22 rpc:call(Node
, euphorik_bd_admin
, update
, []);
24 io:format("Usage: update_server.erl <node-name>"),
27 create_database_directory() ->
28 % Create the directory "var/database" if it doesn't exist.
29 {ok
, Files_in_root
} = file:list_dir("."),
30 Var_exists
= lists:any(fun(Name
) -> Name
=:= "var" end, Files_in_root
),
35 {ok
, Files_in_var
} = file:list_dir("var"),
36 Database_exists
= lists:any(fun(Name
) -> Name
=:= "database" end, Files_in_var
),
37 if not Database_exists
->
38 file:make_dir("var/database");
42 % Copy the datbase from the production to pre production.
43 copy_database(Node
) ->
44 io:format("Copying production database to pre-production node~n"),
45 File
= "/tmp/backup_ek_tmp",
46 File2
= "/tmp/backup_ek_tmp2",
47 rpc:call(yaws@overnux
, mnesia
, backup
, [File
]),
48 rpc:call(Node
, euphorik_bd_admin
, change_node_name
, [yaws@overnux
, yaws_dev@overnux
, File
, File2
]),
49 rpc:call(Node
, mnesia
, restore
, [File2
, [{default_op
, recreate_tables
}]]),
50 rpc:call(yaws@overnux
, file
, delete
, [File
]),
51 rpc:call(Node
, file
, delete
, [File2
]).