forked from DoctorWkt/4bsd-uucp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildimg
executable file
·133 lines (117 loc) · 3.91 KB
/
buildimg
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
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
#
# Create a 4.2BSD SimH image of a system which is set up to make uucp
# connections and pass mail to other 4.2BSD SimH systems.
#
# Usage: buildimg hostname:ourport remote1:server:port remote2:server:port ...
#
# Example: buildimg seismo:6345 mcvax:11.23.45.66:9000 ucbvax:www.fred.com:1800
#
# We will run our image of seismo on our machine on TCP port 6345.
# There is another uucp node called mcvax on machine 11.23.45.66 port 9000
# There is another uucp node called ucbvax on machine www.fred.com port 1800
#
# The script will build a tarball with changes to the generic SimH image,
# boot the SimH image. The SimH image will import the tarball and run a
# script to apply any final changes, e.g. file ownerships and permissions.
if (@ARGV < 1) {
die("Usage: $0 hostname:ourport remote1:server:port remote2:server:port ...\n");
}
# Get our uucp hostname and the set of remote uucp machines
my @remotename;
my @remoteserver;
my ($hostname,$hostport)=split(/:/, shift(@ARGV));
my $remotecount= scalar(@ARGV);
foreach my $i (@ARGV) {
my ($j, $k)= split(/:/, $i, 2);
push(@remotename, $j);
push(@remoteserver, $k);
}
# Remove any previous filesystem
system("rm -rf etc usr mkdirs");
# Make the additional filesystem areas for the customised tarball
system("mkdir -p etc usr/lib/uucp bin usr/include/sys");
# Personalise the hostname and overwrite the rc.local
system("echo $hostname > etc/hostname");
system("cp template/etc/rc.local etc/rc.local");
system("cp template/etc/group etc/group");
system("cp template/etc/passwd etc/passwd");
# Fix up some broken files
system("cp template/usr/include/sys/types.h usr/include/sys/types.h");
system("cp template/bin/date bin/date");
# Create the ttys file
open(my $OUT, ">", "etc/ttys") || die("etc/ttys: $!");
print($OUT "console \"/etc/getty std.9600\" unknown on secure\n");
foreach my $i (0 .. 7) {
if ($i < $remotecount) {
print($OUT "tty0$i \"/etc/getty std.9600\" unknown off insecure\n");
} else {
print($OUT "tty0$i \"/etc/getty std.9600\" unknown on insecure\n");
}
}
close($OUT);
# Generate the L.sys file
open($OUT, ">", "usr/lib/uucp/L.sys") || die("usr/lib/uucp/L.sys: $!");
my $i=0;
foreach my $r (@remotename) {
print($OUT "$r Any;9 DIR 9600 tty0$i \"\" \"\" " .
"ogin:--ogin:--ogin: uucp ssword: uucp\n"); $i++;
}
close($OUT);
# Generate the uucp sendmail.cf
open($OUT, ">", "usr/lib/sendmail.cf") || die("usr/lib/sendmail.cf: $!");
print($OUT "# UUCP hostname\n");
print($OUT "Cw$hostname\n");
print($OUT "DU$hostname\n");
print($OUT "CU$hostname\n\n");
print($OUT "# UUCP hosts that we talk to\n");
foreach my $r (@remotename) {
print($OUT "CW$r\n");
}
print($OUT "\n");
close($OUT);
# Create the sendmail.cf file, and customise the mkdirs script
system("cat template/usr/lib/sendmail.cf >> usr/lib/sendmail.cf");
my $r= "remote=\\'" . join(' ', @remotename) . "\\'";
system("echo $r > mkdirs; chmod 755 mkdirs");
system("cat template/mkdirs >> mkdirs");
# Build the tap image
system("bsdtar -c --uid 0 --uname root --gid 0 --gname root -f - mkdirs bin etc usr | ./mktape /dev/stdin > $hostname.tap");
system("rm -rf etc usr mkdirs bin");
# Generate the system's SimH config file
open($OUT, ">", "$hostname.ini") || die("$hostname.ini: $!");
print($OUT "# Set up eight DZ serial ports in 8-bit mode.\n");
print($OUT "# Connect some lines to remote servers\n");
print($OUT "# Connect the remaining lines to listen on port $hostport\n");
print($OUT "set dz lines=8\n");
print($OUT "set dz 8b\n");
$i=0;
foreach my $server (@remoteserver) {
print($OUT "attach dz -m -a line=$i,Connect=$server\n"); $i++;
}
print($OUT "att dz -m -a $hostport\n");
print $OUT <<"HERE";
set rq0 ra81
att rq0 $hostname.dsk
att ts $hostname.tap
set rq1 dis
set rq2 dis
set rq3 dis
set rp dis
set lpt dis
set rl dis
set tq dis
set tu dis
set tti 7b
set tto 7b
load -o boot42 0
d r10 9
d r11 0
set cpu idle=QUASIJARUS
run 2
HERE
close($OUT);
exit(0);