Realm creation
This commit is contained in:
parent
014909f79b
commit
28598cccf0
5
zomp/etc/otpr/zxq9.user
Normal file
5
zomp/etc/otpr/zxq9.user
Normal file
@ -0,0 +1,5 @@
|
||||
{realm,"otpr"}.
|
||||
{username,"zxq9"}.
|
||||
{realmname,"Craig Everett"}.
|
||||
{contact_info,{"email","zxq9@zxq9.com"}}.
|
||||
{keys,["zxq9-root"]}.
|
||||
@ -777,11 +777,12 @@ create_user(Realm, Username) ->
|
||||
%% realm file to the user.
|
||||
|
||||
create_realm() ->
|
||||
ok = log(info, "WOOHOO! Making a new realm!"),
|
||||
Instructions =
|
||||
"~n"
|
||||
" Enter a name for your new realm.~n"
|
||||
" Names can contain only lower-case letters, numbers and the underscore.~n"
|
||||
" Names must begin with a lower-case letter.~n",
|
||||
"~nNAMING~n"
|
||||
"Enter a name for your new realm.~n"
|
||||
"Names can contain only lower-case letters, numbers and the underscore.~n"
|
||||
"Names must begin with a lower-case letter.~n",
|
||||
ok = io:format(Instructions),
|
||||
Realm = zx_tty:get_input(),
|
||||
case zx_lib:valid_lower0_9(Realm) of
|
||||
@ -812,11 +813,11 @@ create_realm(Realm) ->
|
||||
|
||||
prompt_address() ->
|
||||
Message =
|
||||
"~n"
|
||||
" Enter a static, valid hostname or IPv4 or IPv6 address at which this host "
|
||||
"~nHOST ADDRESS~n"
|
||||
"Enter a static, valid hostname or IPv4 or IPv6 address at which this host "
|
||||
"can be reached from the public internet (or internal network if it will never "
|
||||
"need to be reached from the internet).~n"
|
||||
" DO NOT INCLUDE A PORT NUMBER IN THIS STEP~n",
|
||||
"DO NOT INCLUDE A PORT NUMBER IN THIS STEP~n",
|
||||
ok = io:format(Message),
|
||||
case zx_tty:get_input() of
|
||||
"" ->
|
||||
@ -842,8 +843,8 @@ parse_address(String) ->
|
||||
|
||||
create_realm(Realm, Address) ->
|
||||
Message =
|
||||
"~n"
|
||||
" Enter the public (external) port number at which this service should be "
|
||||
"~nPUBLIC PORT NUMBER~n"
|
||||
"Enter the public (external) port number at which this service should be "
|
||||
"available. (This might be different from the local port number if you are "
|
||||
"forwarding ports or have a complex network layout.)~n",
|
||||
ok = io:format(Message),
|
||||
@ -857,8 +858,8 @@ create_realm(Realm, Address) ->
|
||||
|
||||
prompt_port_number(Current) ->
|
||||
Instructions =
|
||||
" A valid port is any number from 1 to 65535."
|
||||
" [Press enter to accept the current setting: ~tw]~n",
|
||||
"A valid port is any number from 1 to 65535."
|
||||
"[Press enter to accept the current setting: ~tw]~n",
|
||||
ok = io:format(Instructions, [Current]),
|
||||
case zx_tty:get_input() of
|
||||
"" ->
|
||||
@ -888,10 +889,10 @@ prompt_port_number(Current) ->
|
||||
|
||||
create_realm(Realm, Address, Port) ->
|
||||
Instructions =
|
||||
"~n"
|
||||
" Enter a username for the realm sysop.~n"
|
||||
" Names can contain only lower-case letters, numbers and the underscore.~n"
|
||||
" Names must begin with a lower-case letter.~n",
|
||||
"~nSYSOP USERNAME~n"
|
||||
"Enter a username for the realm sysop.~n"
|
||||
"Names can contain only lower-case letters, numbers and the underscore.~n"
|
||||
"Names must begin with a lower-case letter.~n",
|
||||
ok = io:format(Instructions),
|
||||
UserName = zx_tty:get_input(),
|
||||
case zx_lib:valid_lower0_9(UserName) of
|
||||
@ -911,9 +912,9 @@ create_realm(Realm, Address, Port) ->
|
||||
|
||||
create_realm(Realm, Address, Port, UserName) ->
|
||||
Instructions =
|
||||
"~n"
|
||||
" Enter an email address for the realm sysop.~n"
|
||||
" Valid email address rules apply though the checking done here is quite "
|
||||
"~nSYSOP EMAIL~n"
|
||||
"Enter an email address for the realm sysop.~n"
|
||||
"Valid email address rules apply though the checking done here is quite "
|
||||
"minimal. Check the address you enter carefully. The only people who will "
|
||||
"suffer from an invalid address are your users.~n",
|
||||
ok = io:format(Instructions),
|
||||
@ -946,9 +947,9 @@ create_realm(Realm, Address, Port, UserName) ->
|
||||
|
||||
create_realm(Realm, Address, Port, UserName, Email) ->
|
||||
Instructions =
|
||||
"~n"
|
||||
" Enter the real name (or whatever name people recognize) for the sysop.~n"
|
||||
" There are no rules for this one. Any valid UTF-8 printables are legal.~n",
|
||||
"~nSYSOP REAL NAME~n"
|
||||
"Enter the real name (or whatever name people recognize) for the sysop.~n"
|
||||
"There are no rules for this one. Any valid UTF-8 printables are legal.~n",
|
||||
ok = io:format(Instructions),
|
||||
RealName = zx_tty:get_input(),
|
||||
create_realm(Realm, Address, Port, UserName, Email, RealName).
|
||||
@ -976,7 +977,7 @@ create_realm(Realm, Address, Port, UserName, Email, RealName) ->
|
||||
[{realm, Realm},
|
||||
{username, UserName},
|
||||
{realmname, RealName},
|
||||
{contact_info, {"email", Email}},
|
||||
{contact_info, [{"email", Email}]},
|
||||
{keys, [KeyName]}],
|
||||
RealmConfPath = filename:join(zx_lib:path(etc, Realm), "realm.conf"),
|
||||
ok = zx_lib:write_terms(RealmConfPath, RealmConf),
|
||||
@ -988,7 +989,7 @@ create_realm(Realm, Address, Port, UserName, Email, RealName) ->
|
||||
"===========================================================================~n"
|
||||
"DONE!~n"
|
||||
"~n"
|
||||
"The realm ~tp has been created and is accessible from the current system.~n"
|
||||
"The realm ~tp has been created and is accessible from this system.~n"
|
||||
"~n"
|
||||
"Other zomp nodes and zx users will need the new realm file, ~ts, to~n"
|
||||
"access the realm. It does not include any public keys.~n"
|
||||
@ -1046,10 +1047,10 @@ configure_zomp() ->
|
||||
Dir :: file:filename().
|
||||
|
||||
create_realmfile(Realm, Dir) ->
|
||||
RealmConf = zx_lib:load_realm_conf(Realm),
|
||||
{ok, RealmConf} = zx_lib:load_realm_conf(Realm),
|
||||
ok = log(info, "Realm found, creating realm file..."),
|
||||
KeyName = proplists:get_value(key, RealmConf),
|
||||
PubKeyPath = zx_key:name(pub, KeyName),
|
||||
KeyName = maps:get(key, RealmConf),
|
||||
PubKeyPath = zx_key:keypath(public, {Realm, KeyName}),
|
||||
{ok, PubDER} = file:read_file(PubKeyPath),
|
||||
Blob = term_to_binary({RealmConf, PubDER}),
|
||||
ZRF = filename:join(Dir, Realm ++ ".zrf"),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user