Add a few things
This commit is contained in:
parent
3b238d7622
commit
8a360fb927
14
README.unix
14
README.unix
@ -1,20 +1,14 @@
|
|||||||
Unix installation information for ZX
|
Unix installation information for ZX
|
||||||
|
|
||||||
|
|
||||||
This file contains information about how to install and run ZX on a Unix-type system.
|
This file contains information about how to install and run ZX on a Unix-type system.
|
||||||
Consult README.md for general information about ZX as a program and as a project.
|
Consult README.md for general information about ZX as a program and as a project.
|
||||||
|
|
||||||
Current versions of ZX and this file can be found at https://zxq9.com/zx/
|
Current versions of ZX and this file can be found at https://zxq9.com/projects/zomp/
|
||||||
|
|
||||||
|
The unix startup script, "install_unix", must be set as executable to be used.
|
||||||
The unix startup script, "install_unix", is a BASH script and must be set as executable
|
To set the script as executable:
|
||||||
to be used. To set the script as executable:
|
|
||||||
|
|
||||||
|
|
||||||
From the command line:
|
|
||||||
|
|
||||||
To set the file permission correctly you will need to run the following command:
|
|
||||||
chmod +x install_unix
|
chmod +x install_unix
|
||||||
|
|
||||||
Then to execute the installer you will need to run the following command:
|
Then to execute the installer you will need to run the following command:
|
||||||
./install_unix
|
./install_unix
|
||||||
|
|
||||||
|
|||||||
@ -1,2 +1,11 @@
|
|||||||
|
Windows installation information for Windows
|
||||||
|
|
||||||
This file contains information about how to install and run ZX on a Windows system.
|
This file contains information about how to install and run ZX on a Windows system.
|
||||||
Consult README.md for general information about ZX as a program and as a project.
|
Consult README.md for general information about ZX as a program and as a project.
|
||||||
|
|
||||||
|
A quickstart guide for getting your system ready to run ZX (or any Erlang program)
|
||||||
|
is here: https://zxq9.com/projects/zomp/
|
||||||
|
|
||||||
|
Once you have an Erlang runtime installed (via the installer provided by Erlang
|
||||||
|
Solutions https://www.erlang-solutions.com/resources/download.html) you can click
|
||||||
|
to run the "install_windows" file in this directory.
|
||||||
|
|||||||
@ -103,6 +103,14 @@ do(["list", "deps", PackageString]) ->
|
|||||||
do(["install", PackageFile]) ->
|
do(["install", PackageFile]) ->
|
||||||
ok = start(),
|
ok = start(),
|
||||||
done(zx_daemon:install(PackageFile));
|
done(zx_daemon:install(PackageFile));
|
||||||
|
do(["set", "timeout", String]) ->
|
||||||
|
done(zx_local:set_timeout(String));
|
||||||
|
do(["add", "mirror"]) ->
|
||||||
|
done(zx_local:add_mirror());
|
||||||
|
do(["drop", "mirror"]) ->
|
||||||
|
done(zx_local:drop_mirror());
|
||||||
|
do(["status"]) ->
|
||||||
|
done(zx_local:status());
|
||||||
do(["set", "dep", PackageString]) ->
|
do(["set", "dep", PackageString]) ->
|
||||||
done(zx_local:set_dep(PackageString));
|
done(zx_local:set_dep(PackageString));
|
||||||
do(["set", "version", VersionString]) ->
|
do(["set", "version", VersionString]) ->
|
||||||
@ -588,7 +596,8 @@ usage() ->
|
|||||||
" zx logpath [Package [1-10]]~n"
|
" zx logpath [Package [1-10]]~n"
|
||||||
" zx status~n"
|
" zx status~n"
|
||||||
" zx set timeout Value~n"
|
" zx set timeout Value~n"
|
||||||
" zx set mirror Realm Host:Port~n"
|
" zx add mirror Realm Host:Port~n"
|
||||||
|
" zx drop mirror Realm Host:Port~n"
|
||||||
"~n"
|
"~n"
|
||||||
"Developer/Packager/Maintainer Actions:~n"
|
"Developer/Packager/Maintainer Actions:~n"
|
||||||
" zx create project [app | lib] PackageID~n"
|
" zx create project [app | lib] PackageID~n"
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
list_realms/0, list_packages/1, list_versions/1,
|
list_realms/0, list_packages/1, list_versions/1,
|
||||||
set_dep/1, list_deps/0, list_deps/1, drop_dep/1, verup/1, package/1,
|
set_dep/1, list_deps/0, list_deps/1, drop_dep/1, verup/1, package/1,
|
||||||
import_realm/1, drop_realm/1,
|
import_realm/1, drop_realm/1,
|
||||||
takeover/1, abdicate/1,
|
takeover/1, abdicate/1, set_timeout/1, add_mirror/0, drop_mirror/0,
|
||||||
create_plt/0, dialyze/0,
|
create_plt/0, dialyze/0,
|
||||||
grow_a_pair/0, drop_key/1,
|
grow_a_pair/0, drop_key/1,
|
||||||
create_user/0, create_realm/0, create_realmfile/2]).
|
create_user/0, create_realm/0, create_realmfile/2]).
|
||||||
@ -872,7 +872,7 @@ create_realm(R = #realm_init{realm = Realm, addr = Addr, port = Port, url = URL}
|
|||||||
"[3] Port Number : ~w~n"
|
"[3] Port Number : ~w~n"
|
||||||
"[4] URL : ~ts~n"
|
"[4] URL : ~ts~n"
|
||||||
"Press a number to select something to change, or [ENTER] to continue.~n",
|
"Press a number to select something to change, or [ENTER] to continue.~n",
|
||||||
ok = io:format(Instructions, [Realm, Addr, Port, URL]),
|
ok = io:format(Instructions, [Realm, stringify_address(Addr), Port, URL]),
|
||||||
case zx_tty:get_input() of
|
case zx_tty:get_input() of
|
||||||
"1" -> create_realm(R#realm_init{realm = none});
|
"1" -> create_realm(R#realm_init{realm = none});
|
||||||
"2" -> create_realm(R#realm_init{addr = none});
|
"2" -> create_realm(R#realm_init{addr = none});
|
||||||
@ -892,10 +892,9 @@ store_realm(#realm_init{realm = Realm,
|
|||||||
sysop = Sysop = #user_data{username = UserName,
|
sysop = Sysop = #user_data{username = UserName,
|
||||||
keys = [KeyName]}}) ->
|
keys = [KeyName]}}) ->
|
||||||
ok = make_realm_dirs(Realm),
|
ok = make_realm_dirs(Realm),
|
||||||
Address = parse_maybe_address(Addr),
|
|
||||||
RealmConf =
|
RealmConf =
|
||||||
[{realm, Realm},
|
[{realm, Realm},
|
||||||
{prime, {Address, Port}},
|
{prime, {Addr, Port}},
|
||||||
{sysop, UserName},
|
{sysop, UserName},
|
||||||
{key, KeyName},
|
{key, KeyName},
|
||||||
{url, URL}],
|
{url, URL}],
|
||||||
@ -966,7 +965,7 @@ ask_addr() ->
|
|||||||
ok = io:format("You need to enter an address.~n"),
|
ok = io:format("You need to enter an address.~n"),
|
||||||
ask_addr();
|
ask_addr();
|
||||||
String ->
|
String ->
|
||||||
String
|
parse_maybe_address(String)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
@ -979,6 +978,15 @@ parse_maybe_address(String) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
-spec stringify_address(inet:hostname() | inet:ip_address()) -> string().
|
||||||
|
|
||||||
|
stringify_address(Address) ->
|
||||||
|
case inet:ntoa(Address) of
|
||||||
|
{error, einval} -> Address;
|
||||||
|
String -> String
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
-spec ask_port() -> inet:port_number().
|
-spec ask_port() -> inet:port_number().
|
||||||
|
|
||||||
ask_port() ->
|
ask_port() ->
|
||||||
@ -1341,3 +1349,65 @@ abdicate(Realm) ->
|
|||||||
{ok, NewConf} -> zx_sys_conf:save(NewConf);
|
{ok, NewConf} -> zx_sys_conf:save(NewConf);
|
||||||
{error, unmanaged} -> log(error, "Cannot abdicate an unmanaged realm.")
|
{error, unmanaged} -> log(error, "Cannot abdicate an unmanaged realm.")
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
-spec set_timeout(string()) -> zx:outcome().
|
||||||
|
|
||||||
|
set_timeout(String) ->
|
||||||
|
case string:to_integer(String) of
|
||||||
|
{Value, ""} when Value > 0 ->
|
||||||
|
zx_sys_conf:save(zx_sys_conf:timeout(Value, zx_sys_conf:load()));
|
||||||
|
_ ->
|
||||||
|
{error, "Enter a positive integer. Common values are 3, 5 and 10.", 22}
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
-spec add_mirror() -> ok.
|
||||||
|
|
||||||
|
add_mirror() ->
|
||||||
|
ok = log(info, "Adding a mirror to the local configuration..."),
|
||||||
|
SysConf = zx_sys_conf:load(),
|
||||||
|
ok =
|
||||||
|
case zx_sys_conf:mirrors(SysConf) of
|
||||||
|
[] ->
|
||||||
|
ok;
|
||||||
|
Current ->
|
||||||
|
ok = io:format("Current mirrors:~n"),
|
||||||
|
Print =
|
||||||
|
fun({A, P}) ->
|
||||||
|
S = stringify_address(A),
|
||||||
|
io:format("* ~s:~w~n", [S, P])
|
||||||
|
end,
|
||||||
|
lists:foreach(Print, Current)
|
||||||
|
end,
|
||||||
|
Host = ask_addr(),
|
||||||
|
Port = ask_port(),
|
||||||
|
zx_sys_conf:save(zx_sys_conf:add_mirror({Host, Port}, SysConf)).
|
||||||
|
|
||||||
|
|
||||||
|
-spec drop_mirror() -> ok.
|
||||||
|
|
||||||
|
drop_mirror() ->
|
||||||
|
ok = log(info, "Removing mirrors from the local configuration..."),
|
||||||
|
SysConf = zx_sys_conf:load(),
|
||||||
|
zx_sys_conf:save(drop_mirror(SysConf)).
|
||||||
|
|
||||||
|
|
||||||
|
-spec drop_mirror(zx_sys_conf:data()) -> zx_sys_conf:data().
|
||||||
|
|
||||||
|
drop_mirror(SysConf) ->
|
||||||
|
case zx_sys_conf:mirrors(SysConf) of
|
||||||
|
[] ->
|
||||||
|
ok = log(info, "No mirrors to drop!"),
|
||||||
|
SysConf;
|
||||||
|
Current ->
|
||||||
|
ok = io:format("Pick a host to drop:~n"),
|
||||||
|
Optionize =
|
||||||
|
fun(Host = {A, P}) ->
|
||||||
|
Label = io_lib:format("~s:~w", [stringify_address(A), P]),
|
||||||
|
{Label, Host}
|
||||||
|
end,
|
||||||
|
Options = lists:map(Optionize, Current),
|
||||||
|
Selection = zx_tty:select(Options),
|
||||||
|
zx_sys_conf:rem_mirror(Selection, SysConf)
|
||||||
|
end.
|
||||||
|
|||||||
@ -41,7 +41,7 @@
|
|||||||
retries = 3 :: non_neg_integer(),
|
retries = 3 :: non_neg_integer(),
|
||||||
maxconn = 5 :: pos_integer(),
|
maxconn = 5 :: pos_integer(),
|
||||||
managed = sets:new() :: sets:set(zx:realm()),
|
managed = sets:new() :: sets:set(zx:realm()),
|
||||||
mirrors = [] :: [zx:host()]}).
|
mirrors = sets:new() :: sets:set(zx:host())}).
|
||||||
|
|
||||||
-opaque data() :: #d{}.
|
-opaque data() :: #d{}.
|
||||||
|
|
||||||
@ -92,8 +92,8 @@ populate_data(List) ->
|
|||||||
end,
|
end,
|
||||||
Mirrors =
|
Mirrors =
|
||||||
case proplists:get_value(mirrors, List, []) of
|
case proplists:get_value(mirrors, List, []) of
|
||||||
MR when is_list(MR) -> MR;
|
MR when is_list(MR) -> sets:from_list(MR);
|
||||||
_ -> []
|
_ -> sets:new()
|
||||||
end,
|
end,
|
||||||
#d{timeout = Timeout,
|
#d{timeout = Timeout,
|
||||||
retries = Retries,
|
retries = Retries,
|
||||||
@ -116,7 +116,7 @@ save(#d{timeout = Timeout,
|
|||||||
{retries, Retries},
|
{retries, Retries},
|
||||||
{maxconn, MaxConn},
|
{maxconn, MaxConn},
|
||||||
{managed, sets:to_list(Managed)},
|
{managed, sets:to_list(Managed)},
|
||||||
{mirrors, Mirrors}],
|
{mirrors, sets:to_list(Mirrors)}],
|
||||||
ok = zx_lib:write_terms(path(), Terms),
|
ok = zx_lib:write_terms(path(), Terms),
|
||||||
log(info, "Wrote etc/sys.conf").
|
log(info, "Wrote etc/sys.conf").
|
||||||
|
|
||||||
@ -275,7 +275,7 @@ rem_managed(Realm, Data = #d{managed = Managed}) ->
|
|||||||
%% Return the list of private mirrors.
|
%% Return the list of private mirrors.
|
||||||
|
|
||||||
mirrors(#d{mirrors = Mirrors}) ->
|
mirrors(#d{mirrors = Mirrors}) ->
|
||||||
Mirrors.
|
sets:to_list(Mirrors).
|
||||||
|
|
||||||
|
|
||||||
-spec mirrors(Hosts, Data) -> NewData
|
-spec mirrors(Hosts, Data) -> NewData
|
||||||
@ -286,7 +286,7 @@ mirrors(#d{mirrors = Mirrors}) ->
|
|||||||
%% Reset the mirror configuration.
|
%% Reset the mirror configuration.
|
||||||
|
|
||||||
mirrors(Hosts, Data) ->
|
mirrors(Hosts, Data) ->
|
||||||
Data#d{mirrors = Hosts}.
|
Data#d{mirrors = sets:from_list(Hosts)}.
|
||||||
|
|
||||||
|
|
||||||
-spec add_mirror(Host, Data) -> NewData
|
-spec add_mirror(Host, Data) -> NewData
|
||||||
@ -296,11 +296,8 @@ mirrors(Hosts, Data) ->
|
|||||||
%% @doc
|
%% @doc
|
||||||
%% Add a mirror to the permanent configuration.
|
%% Add a mirror to the permanent configuration.
|
||||||
|
|
||||||
add_mirror(Data = #d{mirrors = Mirrors}, Host) ->
|
add_mirror(Host, Data = #d{mirrors = Mirrors}) ->
|
||||||
case lists:member(Host, Mirrors) of
|
Data#d{mirrors = sets:add_element(Host, Mirrors)}.
|
||||||
false -> Data#d{mirrors = [Host | Mirrors]};
|
|
||||||
true -> Data
|
|
||||||
end.
|
|
||||||
|
|
||||||
|
|
||||||
-spec rem_mirror(Host, Data) -> NewData
|
-spec rem_mirror(Host, Data) -> NewData
|
||||||
@ -311,7 +308,7 @@ add_mirror(Data = #d{mirrors = Mirrors}, Host) ->
|
|||||||
%% Remove a host from the list of permanent mirrors.
|
%% Remove a host from the list of permanent mirrors.
|
||||||
|
|
||||||
rem_mirror(Host, Data = #d{mirrors = Mirrors}) ->
|
rem_mirror(Host, Data = #d{mirrors = Mirrors}) ->
|
||||||
Data#d{mirrors = lists:delete(Host, Mirrors)}.
|
Data#d{mirrors = sets:del_element(Host, Mirrors)}.
|
||||||
|
|
||||||
|
|
||||||
-spec reset() -> data().
|
-spec reset() -> data().
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user