-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-fidonet.js
771 lines (717 loc) · 23.2 KB
/
init-fidonet.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
// $Id: init-fidonet.js,v 1.28 2020/04/19 19:43:48 rswindell Exp $
// Initial FidoNet setup script - interactive, run via JSexec or ;exec
// usage: init-fidonet.js [zone | othernet-name] [http://path/to/echolist.na]
/* Prompt for FidoNet node address (support points and othernets)
* Prompt for hub address
* Prompt for areafix password
* Prompt for BinkP session password
* Prompt for Origin Line
* Create FidoNet msg group
* Prompt for backbone.na file location (to download from)
* Download backbone.na (using http-get) to ctrl dir
* Import backbone.na in SCFG
* Ask for default route to be created (e.g. 1:ALL)
* Update sbbsecho.ini (add uplink, enabled BinkpPoll)
* Run binkit.js install
* Send an AreaFix %+ALL netmail to the hub
* Generate a report with all details, mention log/lst/ini files
*/
"use strict";
const REVISION = "$Revision: 1.28 $".split(' ')[1];
var netname;
var netdns;
var netzone = parseInt(argv[0], 10);
if(!netzone)
netname = argv[0];
var echolist_url = argv[1];
// If you want your Othernet listed here, please provide information
// and an http[s] URL to your official EchoList
var network;
var fidoaddr = load({}, 'fidoaddr.js');
print("******************************************************************************");
print("* " + js.exec_file + " v" + format("%-30s", REVISION) + " *");
print("* " + format("%-58s", "Initializing " + (netname || "FidoNet") + " support in Synchronet") +" *");
print("* Use Ctrl-C to abort the process if desired *");
print("******************************************************************************");
var network_list = {};
var file = new File(js.exec_dir + "init-fidonet.ini");
if (file.open("r")) {
var list = file.iniGetSections("zone:", "zone");
for(var i in list)
network_list[list[i].substr(5)] = file.iniGetObject(list[i]);
file.close();
}
function aborted()
{
if(js.terminated || (js.global.console && console.aborted))
exit(1);
return false;
}
function exclude_strings(list, patterns, flags)
{
patterns = [].concat(patterns);
if (flags === undefined)
flags = 'i';
return list.reduce(function (a, c) {
var matched = patterns.some(function (e) {
if (typeof e == 'string')
e = new RegExp(e, flags);
return c.match(e);
});
if (!matched)
a.push(c);
return a;
}, []);
}
function file_contents(filename, dflt, maxlinelen)
{
var file = new File(filename);
if(!file.open("r"))
return dflt;
var lines = file.readAll(maxlinelen || 1000);
file.close();
return lines || dflt;
}
function remove_lines_from_file(filename, patterns, maxlinelen)
{
var file = new File(filename);
if(!file.open("r"))
return "Error " + file.error + " opening " + file.name;
var lines = file.readAll(maxlinelen || 1000);
file.close();
var file = new File(filename);
if(!file.open("w"))
return "Error " + file.error + " opening " + file.name;
var result = file.writeAll(exclude_strings(lines, patterns));
file.close();
return result;
}
function remove_prefix_from_title(filename, prefix)
{
var file = new File(filename);
if(!file.open("r"))
return "Error " + file.error + " opening " + file.name;
var lines = file.readAll(1000);
file.close();
var longest = 0;
var list = [];
for(var i = 0; i < lines.length; i++) {
var a = lines[i].split(/\s+/);
var tag = a.shift();
if(tag.length > longest)
longest = tag.length;
var title = a.join(' ');
if(title.toLowerCase().indexOf(prefix.toLowerCase()) == 0)
title = title.substr(prefix.length);
list.push({ tag: tag, title: title});
}
var file = new File(filename);
if(!file.open("w"))
return "Error " + file.error + " opening " + file.name;
for(var i in list)
file.writeln(format("%-*s %s", longest, list[i].tag, list[i].title));
file.close();
return true;
}
function find_sys_addr(addr)
{
for(var i = 0; i < system.fido_addr_list.length; i++) {
if(system.fido_addr_list[i] == addr)
return true;
}
return false;
}
function send_app_netmail(destaddr)
{
var hdr = {
to: link.Name,
to_net_addr: destaddr,
from: sysop,
from_ext: 1,
subject: netname + " node number request"
}
print("Message text:");
var body_text = "Hello, this is " + sysop + " from " + system.location + "\r\n";
body_text += "and I am requesting a node number for zone " + netzone + " in " + netname + ".\r\n";
body_text += "\r\n";
body_text += "My system is " + system.name + " at " + system.inet_addr + ".\r\n";
body_text += "\r\n";
body_text += "I am using Synchronet-" + system.platform + " v" + system.full_version
+ " with SBBSecho and BinkIT.\r\n";
body_text += "\r\n";
body_text += "My requested AreaFix password is: '" + link.AreaFixPwd + "'\r\n";
body_text += "My requested BinkP Session password is: '" + link.SessionPwd + "'\r\n";
body_text += "\r\n";
body_text += "I will be using 'Type-2+' (FSC-39) packets with no password.\r\n";
body_text += "Uncompressed or PKZIP-archived EchoMail bundles will work fine.\r\n";
print(body_text);
while(confirm("Add more text") && !aborted()) {
body_text += "\r\n";
var str;
while((str=prompt("[done]")) && !aborted()) body_text += str + "\r\n";
}
if(aborted() || !confirm("Send now"))
return false;
var msgbase = new MsgBase("mail");
if(msgbase.open() == false)
return "Error opening mail base: " + msgbase.last_error;
if(!msgbase.save_msg(hdr, body_text)) {
msgbase.close();
return "Error saving message: " + msgbase.last_error;
}
msgbase.close();
print("Application NetMail message created successfully for " + destaddr);
return true;
}
function lookup_network(info)
{
print("Looking up network/zone: " + info);
var result;
if(typeof info == "number") {
result = network_list[info];
if(result)
return result;
}
var file = new File("sbbsecho.ini");
if (!file.open("r")) {
alert("Error " + file.error + " opening " + file.name);
return false;
}
if(typeof info == "number") { // zone
var dns;
var domain_list = file.iniGetSections("domain:");
if(domain_list) {
var zonemap = {};
for(var i = 0; i < domain_list.length && !result; i++) {
var section = domain_list[i];
var netname = section.substr(7)
var zones = file.iniGetValue(section, "Zones");
if(!zones)
continue;
var dns = file.iniGetValue(section, "DNSSuffix");
if(typeof zones == 'number') {
if(info == zones) {
result = { name: netname, dns: dns};
break;
}
continue;
}
zones = zones.split(',');
for(var j = 0; j < zones.length; j++) {
if(info == zones[j]) {
result = { name: netname, dns: dns};
break;
}
}
}
}
file.close();
return result;
}
result = file.iniGetValue("domain:" + info, "Zones", 1);
file.close();
return result;
}
function get_linked_node(addr)
{
var file = new File("sbbsecho.ini");
if (!file.open("r"))
return false;
var result = file.iniGetObject("node:" + addr);
file.close();
return result;
}
function get_binkp_sysop()
{
var file = new File("sbbsecho.ini");
if (!file.open("r"))
return false;
var result = file.iniGetValue("Binkp", "Sysop");
file.close();
return result;
}
function update_sbbsecho_ini(hub, link, echolist_fname, areamgr)
{
function makepath(path)
{
if(mkpath(path))
return true;
alert("Error " + errno + " (" + errno_str + ") creating " + path);
return false;
}
var file = new File("sbbsecho.ini");
if(!file.open("r+")) {
return "Error " + file.error + " opening " + file.name;
}
var path = file.iniGetValue(null, "Inbound");
if(!path)
path = "../fido/nonsecure";
while((!path
|| !confirm("Non-secure inbound directory is '" + path + "'")
|| !makepath(path)) && !aborted())
path = prompt("Non-secure inbound directory");
file.iniSetValue(null, "Inbound", path);
path = file.iniGetValue(null, "SecureInbound");
if(!path)
path = "../fido/inbound";
while((!path
|| !confirm("Secure inbound directory is '" + path + "'")
|| !makepath(path)) && !aborted())
path = prompt("Secure inbound directory");
file.iniSetValue(null, "SecureInbound", path);
path = file.iniGetValue(null, "Outbound");
if(!path)
path = "../fido/outbound";
while((!path
|| !confirm("Outbound directory is '" + path + "'")
|| !makepath(path)) && !aborted())
path = prompt("Outbound directory");
file.iniSetValue(null, "Outbound", path);
var binkp = file.iniGetObject("BinkP");
if(!binkp) binkp = {};
binkp.sysop = sysop;
if(!file.iniSetObject("binkp", binkp)) {
return "Error" + file.error + " writign to " + file.name;
}
var section = "node:" + fidoaddr.to_str(hub);
if(!file.iniGetObject(section)
|| confirm("Overwrite hub [" + section + "] configuration in " + file.name)) {
if(!file.iniSetObject(section, link)) {
return "Error " + file.error + " writing to " + file.name;
}
}
var section = "node:" + hub.zone + ":ALL";
if(confirm("Route all zone " + hub.zone + " netmail through your hub")) {
if(!file.iniSetObject(section,
{
Comment: "Everyone in zone " + hub.zone,
Route: fidoaddr.to_str(hub)
})) {
return "Error " + file.error + " writing to " + file.name;
}
}
if(echolist_fname) {
var section = "echolist:" + echolist_fname;
if(!file.iniGetObject(section)
|| confirm("Overwrite [" + section + "] configuration in " + file.name)) {
if(!file.iniSetObject(section,
{
Hub: fidoaddr.to_str(hub),
Pwd: link.AreaFixPwd,
AreaMgr: areamgr || "AreaFix",
Fwd: false
})) {
return "Error " + file.error + " writing to " + file.name;
}
}
}
file.close();
print(file.name + " updated successfully.");
return true;
}
/****************************/
/* DETERMINE NETWORK (ZONE) */
/****************************/
if(netzone)
network = lookup_network(netzone);
else if(netname) {
netzone = lookup_network(netname);
network = network_list[netzone];
}
if(!netzone) {
for(var zone in network_list) {
var desc = "";
if(network_list[zone].desc)
desc = " (" + network_list[zone].desc + ")";
print(format("%6s %s%s", format("<%u>", zone), network_list[zone].name, desc));
if(network_list[zone].info)
print(" " + network_list[zone].info);
if(network_list[zone].coord || network_list[zone].email || network_list[zone].fido) {
var email = "";
if(network_list[zone].email)
email = " <" + network_list[zone].email + ">";
if(network_list[zone].fido)
email += " " + network_list[zone].fido;
print(" coordinator: " + (network_list[zone].coord || "") + email);
}
}
var which;
while((!which || which < 1) && !aborted()) {
var str = prompt("Which or [Q]uit");
if(str && str.toUpperCase() == 'Q')
exit(0);
which = parseInt(str, 10);
}
netzone = which;
network = network_list[which];
}
if(network)
netname = network.name;
else
network = {};
if(netzone <= 6)
netname = "FidoNet";
else {
while((!netname || netname.indexOf(' ') >= 0 || netname.length > 8
|| !confirm("Network name is '" + netname + "'")) && !aborted()) {
var str = prompt("Network name (no spaces or illegal filename chars) [" + netname + "]");
if(str)
netname = str;
}
}
if(netname) {
print("Network name: " + netname);
print("Network zone: " + netzone);
print("Network info: " + network.info);
print("Network coordinator: " + network.coord
+ (network.email ? (" <" + network.email + ">") : "")
+ (network.fido ? (" " + network.fido) : ""));
if(network.also)
print(" also: " + network.also);
print("EchoList: " + file_getname(network.echolist));
} else
alert("Unrecognized network zone: " + netzone);
print("Reading Message Area configuration file: msgs.cnf");
var cnflib = load({}, "cnflib.js");
var msgs_cnf = cnflib.read("msgs.cnf");
if (!msgs_cnf) {
alert("Failed to read msgs.cnf");
exit(1);
}
var your = {zone: NaN, net: NaN, node: 9999, point: 0};
for(var i = 0; i < system.fido_addr_list.length; i++) {
var addr = fidoaddr.parse(system.fido_addr_list[i]);
if(!addr || addr.zone != netzone)
continue;
if(deny("You already have a " + netname + " Address (" + system.fido_addr_list[i] + "), continue"))
exit(0);
your = addr;
break;
}
/*********************************/
/* DETERMINE YOUR HUB'S ADDRESSS */
/*********************************/
var hub = {zone: netzone ? netzone : NaN, net: NaN, node: NaN};
if(network.addr)
hub = fidoaddr.parse(network.addr);
while(((isNaN(hub.zone) || hub.zone < 1)
|| (isNaN(hub.net) || hub.net < 1)
|| (isNaN(hub.node) || hub.node < 0)
|| !confirm("Your hub's address is " + fidoaddr.to_str(hub))) && !aborted()) {
hub = fidoaddr.parse(prompt("Your hub's address (zone:net/node)"));
}
var link = get_linked_node(fidoaddr.to_str(hub));
if(!link)
link = {};
if(!link.Name && fidoaddr.to_str(hub) == network.addr)
link.Name = network.coord;
while((!link.Name || !confirm("Your hub's sysop's name is '" + link.Name + "'")) && !aborted()) {
link.Name = prompt("Your hub's sysop's name");
}
if(!link.BinkpHost)
link.BinkpHost = network.host;
while(!network.dns && (!link.BinkpHost
|| !confirm("Your hub's hostname or IP address is " + link.BinkpHost)) && !aborted()) {
link.BinkpHost = prompt("Your hub's hostname or IP address");
}
if(!link.BinkpPort)
link.BinkpPort = network.port || 24554;
while(!link.BinkpPort || !confirm("Your hub's BinkP/TCP port number is " + link.BinkpPort) && !aborted()) {
link.BinkpPort = parseInt(prompt("Your hub's BinkP/TCP port number"));
}
if(!link.Comment)
link.Comment = network.email;
if(!link.GroupHub)
link.GroupHub = netname;
if(link.BinkpPoll === undefined)
link.BinkpPoll = true;
/***************************/
/* DETERMINE YOUR ADDRESSS */
/***************************/
if(!your.zone)
your.zone = hub.zone;
if(!your.net)
your.net = hub.net;
while(!confirm("Your node address is " + fidoaddr.to_str(your)) && !aborted()) {
your.zone = NaN;
your.net = NaN;
your.node = NaN;
while((isNaN(your.zone) || your.zone < 1) && !aborted())
your.zone = parseInt(prompt("Your zone number (e.g. 1 for FidoNet North America)"));
while((isNaN(your.net) || your.net < 1) && !aborted())
your.net = parseInt(prompt("Your network number (i.e. normally the same as your hub)"));
while((isNaN(your.node) || your.node < 1) && !aborted())
your.node = parseInt(prompt("Your node number (e.g. 9999 for temporary node)"));
while((isNaN(your.point)) && !aborted())
your.point = parseInt(prompt("Your point number (i.e. 0 for a normal node)"));
}
/* Get/Confirm Sysop Name */
var sysop = system.operator;
if(system.stats.total_users) {
var u = new User(1);
if(u && u.name)
sysop = u.name;
}
sysop = get_binkp_sysop() || sysop;
while((!sysop || !confirm("Your name is '" + sysop + "'")) && !aborted())
sysop = prompt("Your name");
/* Get/Confirm passwords */
while((!link.AreaFixPwd || !confirm("Your AreaFix Password is '" + link.AreaFixPwd + "'")) && !aborted())
link.AreaFixPwd = prompt("Your AreaFix (a.k.a. Area Manager) Password (case in-sensitive)");
while((!link.SessionPwd || !confirm("Your BinkP Session Passowrd is '" + link.SessionPwd + "'")) && !aborted())
link.SessionPwd = prompt("Your BinkP Session Password (case sensitive)");
/***********************************************/
/* SEND NODE NUMBER REQUEST NETMAIL (Internet) */
/***********************************************/
if(your.node === 9999 && network.email && network.email.indexOf('@') > 0
&& confirm("Send a node number application to " + network.email)) {
var result = send_app_netmail(network.email);
if(typeof result !== 'boolean') {
alert(result);
exit(1);
}
if(aborted())
exit(0);
if(confirm("Come back when you have your permanently-assigned node address")) {
if(confirm("Save changes to FidoNet configuration file: sbbsecho.ini")) {
var result = update_sbbsecho_ini(hub, link);
if (result != true) {
alert(result);
exit(1);
}
}
exit(0);
}
}
if(!find_sys_addr(fidoaddr.to_str(your))
&& confirm("Add node address " + fidoaddr.to_str(your) + " to your configuration"))
msgs_cnf.fido_addr_list.push(your);
if(!msgs_cnf.fido_default_origin)
msgs_cnf.fido_default_origin = system.name + " - " + system.inet_addr;
while((!msgs_cnf.fido_default_origin
|| !confirm("Your origin line is '" + msgs_cnf.fido_default_origin + "'")) && !aborted()) {
msgs_cnf.fido_default_origin = prompt("Your origin line");
}
/*******************/
/* UPDATE MSGS.CNF */
/*******************/
if(!msg_area.grp[netname]
&& confirm("Create " + netname + " message group in SCFG->Message Areas")) {
print("Adding Message Group: " + netname);
msgs_cnf.grp.push( {
"name": netname,
"description": netname,
"ars": "",
"code_prefix": network.areatag_prefix === undefined
? (netname.toUpperCase() + "_") : network.areatag_prefix
});
}
if(confirm("Save Changes to Message Area configuration file: msgs.cnf")) {
if(!cnflib.write("msgs.cnf", undefined, msgs_cnf)) {
alert("Failed to write msgs.cnf");
exit(1);
}
print("msgs.cnf updated successfully.");
}
/*********************/
/* DOWNLOAD ECHOLIST */
/*********************/
var echolist_fname = file_getname(network.echolist);
if(network.echolist
&& (network.echolist.indexOf("http://") == 0 || network.echolist.indexOf("https://") == 0)
&& confirm("Download " + netname + " EchoList: " + file_getname(network.echolist))) {
var echolist_url = network.echolist;
load("http.js");
while(!aborted()) {
while((!echolist_url || !confirm("Download from: " + echolist_url)) && !aborted()) {
echolist_url = prompt("Echolist URL");
}
var file = new File(echolist_fname);
if(!file.open("w")) {
alert("Error " + file.error + " opening " + file.name);
exit(1);
}
var http_request = new HTTPRequest();
try {
var contents = http_request.Get(echolist_url);
} catch(e) {
alert(e);
file.close();
file_remove(file.name);
if(!confirm("Try again"))
break;
continue;
}
if(http_request.response_code == 200) {
print("Downloaded " + echolist_url + " to " + file.name);
file.write(contents);
file.close();
break;
}
file.close();
file_remove(file.name);
alert("Error " + http_request.response_code + " downloading " + echolist_url);
if(!confirm("Try again"))
break;
}
}
while(echolist_fname && !file_getcase(echolist_fname) && !aborted()) {
alert(system.ctrl_dir + echolist_fname + " does not exist");
if(!confirm("Install " + netname + " EchoList: " + echolist_fname))
break;
prompt("Download and extract " + echolist_fname + " now... Press enter to continue");
}
echolist_fname = file_getcase(echolist_fname)
if(echolist_fname && file_size(echolist_fname) > 0) {
if(network.areatag_exclude) {
print("Removing " + network.areatag_exclude + " from " + echolist_fname);
var result = remove_lines_from_file(echolist_fname, network.areatag_exclude.split(','));
if(result !== true)
alert(result);
}
if(network.areatitle_prefix) {
print("Removing " + network.areatitle_prefix + " Title Prefixes from " + echolist_fname);
var result = remove_prefix_from_titles(echolist_fname, network.areatitle_prefix);
if(result !== true)
alert(result);
}
if(confirm("Import EchoList (" + echolist_fname + ") into Message Group: " + netname)) {
print("Importing " + echolist_fname);
var misc = 0;
if(!network.handles)
misc |= SUB_NAME;
system.exec(system.exec_dir + "scfg"
+ " -import=" + echolist_fname
+ " -g" + netname
+ " -faddr=" + fidoaddr.to_str(your)
+ " -misc=" + misc
);
}
}
/***********************/
/* UPDATE SBBSECHO.INI */
/***********************/
if(confirm("Save changes to FidoNet configuration file: sbbsecho.ini")) {
var result = update_sbbsecho_ini(hub, link, echolist_fname, network.areamgr);
if (result != true) {
alert(result);
exit(1);
}
}
/******************/
/* INSTALL BINKIT */
/******************/
if(confirm("Install BinkIT")) {
var result = load({}, "install-binkit.js");
if (result != true) {
alert(result);
exit(1);
}
}
print("Requesting Synchronet recycle (configuration-reload)");
if(!file_touch(system.ctrl_dir + "recycle"))
alert("Recycle semaphore file update failure");
/******************************************/
/* SEND NODE NUMBER REQUEST NETMAIL (FTN) */
/******************************************/
if(your.node === 9999) {
if(confirm("Send a node number application to " + fidoaddr.to_str(hub))) {
var result = send_app_netmail(fidoaddr.to_str(hub));
if(typeof result !== 'boolean') {
alert(result);
exit(1);
}
if(aborted() || confirm("Come back when you have a permanently-assigned node address"))
exit(0);
} else if(network.fido && confirm("Send a node number application to " + network.fido)) {
var result = send_app_netmail(network.fido);
if(typeof result !== 'boolean') {
alert(result);
exit(1);
}
if(aborted() || confirm("Come back when you have a permanently-assigned node address"))
exit(0);
}
}
/************************/
/* SEND AREAFIX NETMAIL */
/************************/
if(your.node !== 9999
&& confirm("Send an AreaFix request to link EchoMail areas with "
+ fidoaddr.to_str(hub))) {
var msgbase = new MsgBase("mail");
if(msgbase.open() == false) {
alert("Error opening mail base: " + msgbase.last_error);
exit(1);
}
var lines = file_contents(echolist_fname, ["%+ALL"]);
for(var i in lines) {
lines[i] = lines[i].split(/\s+/)[0];
}
if(!msgbase.save_msg({
to: network.areamgr || "AreaFix",
to_net_addr: fidoaddr.to_str(hub),
from: sysop,
from_ext: 1,
subject: link.AreaFixPwd
}, /* body text: */ lines.join('\r\n'))) {
alert("Error saving message: " + msgbase.last_error);
exit(1);
}
msgbase.close();
print("AreaFix NetMail message created successfully.");
}
/**************************************************************/
/* Add links to logs/stats files to "Operator" G-file section */
/**************************************************************/
function add_gfile(fname, desc, tail)
{
function file_append(fname, text)
{
var file = new File(fname);
if(!file.open("at")) {
alert("Error " + file.error + " opening " + file.name);
return false;
}
file.writeAll(text);
file.close();
return true;
}
var file = new File(system.data_dir + "text/operator.ini");
if(!file.open(file.exists ? 'r+':'w+')) {
alert("Error " + file.error + " opening " + file.name);
return false;
}
var section = "%j" + fname;
if(file.iniGetObject(section) == null && confirm("Add " + desc)) {
if(file.iniSetObject(section, { desc: "Fido: " + desc, tail: tail }))
print("Added " + fname + " to " + file.name);
}
file.close();
}
print("Updating the 'Operator' Text File Section:");
add_gfile("sbbsecho.log", "NetMail and EchoMail import/export activity log", 500);
add_gfile("badareas.lst", "Unrecognized received EchoMail area list");
add_gfile("echostats.ini", "Detailed EchoMail statistics");
add_gfile("binkstats.ini", "Detailed BinkP (mail/file transfer) statistics");
/***********************/
/* DISPLAY FINAL NOTES */
/***********************/
print(netname + " initial setup completely successfully.");
print();
if(your.node == 9999) {
print("You used a temporary node address (" + fidoaddr.to_str(your) +
"). You will need to update your");
print("SCFG->Networks->FidoNet->Address once your permanent node address has been");
print("assigned to you.");
print();
}
print("See your 'Events' log output for outbound BinkP connections.");
print("See your 'Services' log output for inbound BinkP connections.");
print("Use exec/echocfg for follow-up FidoNet-related configuration.");
if(!this.jsexec_revision) {
print();
print("It appears you have run this script from the BBS. You must log-off now for the");
print("server to recycle and configuration changes to take effect.");
}
exit(0);