├── .gitattributes
├── .gitignore
├── LICENSE
├── README.md
├── Vagrantfile
├── scripts
├── functions.sh
├── insecure_disable
├── insecure_enable
├── install_targets
├── iphex
├── mount_media
├── proto_install
├── sunboot_init
├── target_add
├── target_rm
├── utils.sh
└── xdrtoc.py
├── shims
├── arch
├── dd
├── mount
└── mt
├── sunboot-settings
├── sunos
└── .gitkeep
├── targets-disabled
├── .gitkeep
└── ssx
└── targets
├── .gitkeep
└── hobbes
/.gitattributes:
--------------------------------------------------------------------------------
1 | * -crlf
2 |
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .vagrant
2 | .idea
3 | .DS_Store
4 | sunos/*.iso
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright 2018 Andrew Liles
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | sunboot
2 | -------
3 |
4 | sunboot makes it easy to get an operating system running on Sun hardware. This is the sister project to a similar utility for Silicon Graphics computers called [irixboot](https://github.com/halfmanhalftaco/irixboot).
5 |
6 | ## Contents
7 |
8 | - [How it works](#howitworks)
9 | - [Features](#features)
10 | - [Requirements](#requirements)
11 | - [Configuration](#configuration)
12 | - [Vagrantfile](#config_vagrant)
13 | - [sunboot-settings](#sunboot-settings)
14 | - [targets](#config_targets)
15 | - [Security](#security)
16 | - [Operating System-specific Examples](#examples)
17 | - [Diskless SunOS 4.1.4 on SPARCstation IPC](#sunos_ipc)
18 | - [Diskful Solaris 2.3 on SPARCclassic](#sol_classic)
19 | - [Maintenance](#maint)
20 | - [License](#license)
21 |
22 |
23 | ## How it works
24 |
25 | Sun hardware was designed with the network in mind and nearly every Sun machine I've come across has baked-in support for booting from Ethernet devices. The code in PROM knows enough to be able to initialize the ethernet adapter and send a broadcast request for its IP address via RARP. Once the machine has its IP address it sends a request via TFTP (UDP port 69) to the address that replied to RARP for a file whose name is the hexadecimal representation of the IP address. This file is the bootloader (often called 'boot' or 'inetboot') and is loaded into RAM and executed.
26 |
27 | The bootloader program knows how to use RPC to call BOOTPARAMS and retrieve information about which filesystems to mount via NFS. It contains enough code to download the kernel via NFS. Control is then passed over to the kernel which then brings the system up the rest of the way.
28 |
29 | Later hardware supports the more modern DHCP for booting but most machines can fall back to RARP/TFTP.
30 |
31 | ---
32 |
33 | ## Features
34 |
35 | - Simple configuration
36 | - Supports multiple simultaneous clients running different OS versions
37 | - Diskless-client install & autoconfiguration
38 | - Remote install for diskful-client systems
39 | - Emulates remote tape and CD-ROM devices as install sources
40 | - Supports netbooting the miniroot environment for formatting local disks and running the installer
41 | - Supports both SunOS and Solaris (diskless support for Solaris is in the works)
42 | - Boots (probably) any RARP/TFTP/BOOTPARAMS/NFS capable Sun workstation and operating system
43 |
44 | This project is in its early stages so right now it only supports the following:
45 |
46 | - Only SunOS 4.1.4 (Solaris 1.1.2) and Solaris 2.3 have been tested at this point.
47 | - CD-based operating systems (SunOS 4.1.x, Solaris)
48 | - Diskful (remote install) and Diskless support for SunOS 4.1.x
49 | - Diskful (remote install) support for Solaris
50 |
51 | ### Planned features
52 |
53 | - Diskless Solaris installs
54 | - Tape-based SunOS installs (including pre-SPARC systems)
55 | - Non-Sun OS support (netbsd, Linux)
56 | - Centralized user/group/host management (yp/NIS/NIS+)
57 | - Support for installing sunboot on other non-x86 systems (Raspberry Pi, etc.)
58 |
59 | ---
60 |
61 | ## Requirements
62 |
63 | - [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
64 | - [Vagrant](https://www.vagrantup.com/)
65 |
66 | Hardware-wise, any virtualization-capable Intel-based computer should work. VirtualBox and Vagrant support Linux, MacOS and Windows.
67 |
68 | ---
69 |
70 | ## Configuration
71 |
72 | sunboot has configuration distributed in a few locations. To fully configure sunboot, the following will need to be edited to suit your environment:
73 |
74 | - [Vagrantfile](#vagrantfile)
75 | - [sunboot-settings](#sunboot-settings)
76 | - [targets directory](#config_targets)
77 |
78 | ### Vagrantfile
79 |
80 | First, the `Vagrantfile` has one item that needs to be configured: the bridge interface. sunboot must be bridged to (not NAT-ed) to the network where the Sun machine(s) are connected. This is to support the broadcast traffic required to bring these machines up. Fill in your network interface name (can be determined with `VBoxManage list bridgedifs`, the `Name` is the field it looks for). In this example, `eth1` is the interface to be bridged. If this is not filled out, Vagrant will ask at startup which interface to use.
81 |
82 | ```ruby
83 | config.vm.network "public_network", auto_config: false, bridge: "eth1"
84 | ```
85 |
86 | ### sunboot-settings
87 |
88 | The next configuration step is the server configuration. This contains the hostname, IP address, netmask and gateway of the server. This should be chosen to not interfere with existing machines on the bridged network and be outside of any DHCP address ranges that may be present on the network.
89 |
90 | ```bash
91 | # General environment settings
92 |
93 | SERVERNAME=sunboot
94 | SERVERADDR=10.94.42.7
95 | NETMASK=255.255.255.0
96 | GATEWAY=10.94.42.1
97 | ```
98 |
99 | ### targets directory
100 |
101 | Files in this directory specify the settings for individual machines to enable netbooting for.
102 |
103 | Example:
104 |
105 | ```bash
106 | # SPARCstation IPC SunOS 4.1.4 Diskless Install Example
107 |
108 | TARGETARCH=sun4c
109 | TARGETNAME=hobbes
110 | TARGETETHER=8:0:20:a:7d:8f
111 | TARGETADDR=10.94.42.208
112 | TARGETSWAPSIZE=64
113 |
114 | # options: DISKLESS or DISKFUL
115 | INSTALLMETHOD=DISKLESS
116 |
117 | # options: CDROM or TAPE
118 | INSTALLMEDIA=CDROM
119 |
120 | # path (within 'sunos' directory) to the install CD-ROM or directory that contains 'tape1', 'tape2', etc. dirs
121 | INSTALLMEDIAPATH=solaris1.1.2.iso
122 | ```
123 |
124 | `TARGETARCH` should be set to the correct kernel architecture required for your machine.
125 |
126 | Examples:
127 |
128 | - Sun-2 machines are always `sun2`
129 | - Sun-3 machines are either `sun3` or later 68030-based machines are `sun3x`
130 | - Early SPARC machines are `sun4`, while SPARCstation 1-era machines are `sun4c`. Machines based on the multiprocessor-capable architecture (SPARCstation 10, 20 and relatives) are `sun4m`.
131 | - There are some fairly esoteric derivatives of these such as `sun4d`, `sun4e`, `sun4u1` and `sun4us`
132 | - UltraSPARC I, II, III and IV machines are `sun4u`
133 | - UltraSPARC T1 and later are `sun4v`
134 |
135 | `TARGETSWAPSIZE` is the size of the swapfile allocated to the machine, in megabytes. A general rule of thumb is RAM * 2.
136 |
137 | A `DISKFUL` install will configure the machine to boot into the installer for the operating system media provided. For SunOS 4.1.x this will boot the machine into `miniroot` and boot to a shell where one can run `format` to label local disks and then `suninstall` to perform an installation. For Solaris this will boot into the graphical installer if a keyboard is present.
138 |
139 | A `DISKLESS` install tries to emulate a full install of the operating system. Currently this is only supported for SunOS 4.1.x. All of the available software sets are extracted to disk and exported via NFS. The operating system is customized per the target configuration to set the IP address and hostname.
140 |
141 | Install media should be placed in the provided `sunos` directory. Paths specified in `INSTALLMEDIAPATH` are relative to this directory.
142 |
143 | ---
144 |
145 | ## Security
146 |
147 | sunboot configures the virtual machine in a way that is inherently insecure. The boot process was designed in an era where the network was considered fully trusted so security on the modern Linux-based operating system that sunboot uses must be bypassed in several cases to make things work.
148 |
149 | It is recommended to airgap or at minimum heavily firewall the network that sunboot is configured on.
150 |
151 | - `rsh` is enabled and allows passwordless root login to SunOS diskful installs. This is required to support remote media access.
152 | - read-write NFS exports are restricted by IP address only, there is no other authentication in place which means other machines on the network could potentially access NFS on these exports as root or any other user without restriction. Static ARP entries are entered on the sunboot VM to mitigate.
153 |
154 | The sunboot VM does require internet access during `vagrant up` in order to download the required Debian packages. After the initial configuration is complete it can be disconnected from the internet.
155 |
156 | ---
157 |
158 | ## Operating System-specific Examples
159 |
160 | ### Diskless SunOS 4.1.4 on a SPARCstation IPC
161 |
162 | Using the following target configuration, here are the steps to start up sunboot and boot the SPARCstation.
163 |
164 | `targets/hobbes`:
165 |
166 | ```bash
167 | # SPARCstation IPC SunOS 4.1.4 Diskless Install Example
168 |
169 | TARGETARCH=sun4c
170 | TARGETNAME=hobbes
171 | TARGETETHER=8:0:20:a:7d:8f
172 | TARGETADDR=10.94.42.208
173 | TARGETSWAPSIZE=64
174 |
175 | # options: DISKLESS or DISKFUL
176 | INSTALLMETHOD=DISKLESS
177 |
178 | # options: CDROM or TAPE
179 | INSTALLMEDIA=CDROM
180 |
181 | # path (within 'sunos' directory) to the install CD-ROM or directory that contains 'tape1', 'tape2', etc. dirs
182 | INSTALLMEDIAPATH=solaris1.1.2.iso
183 | ```
184 |
185 | On host machine:
186 | ```
187 | $ git clone https://github.com/halfmanhalftaco/sunboot.git
188 | $ cd sunboot
189 | $ vi Vagrantfile sunboot-settings targets/hobbes # edit the configurations
190 | $ vagrant up
191 | Bringing machine 'default' up with 'virtualbox' provider...
192 | ==> default: Importing base box 'debian/contrib-jessie64'...
193 | ==> default: Matching MAC address for NAT networking...
194 | ==> default: Checking if box 'debian/contrib-jessie64' is up to date...
195 | ==> default: Setting the name of the VM: sunboot_default_1531929476572_79046
196 | ==> default: Clearing any previously set network interfaces...
197 | ==> default: Preparing network interfaces based on configuration...
198 | default: Adapter 1: nat
199 | default: Adapter 2: bridged
200 | ==> default: Forwarding ports...
201 | default: 22 (guest) => 2222 (host) (adapter 1)
202 | ==> default: Running 'pre-boot' VM customizations...
203 | ==> default: Booting VM...
204 |
205 | ==> default: Mounting shared folders...
206 | default: /vagrant => F:/src/sunboot
207 | ==> default: Running provisioner: initialize (shell)...
208 | default: Running: C:/Users/sunboot/AppData/Local/Temp/vagrant-shell20180718-6128-1w9bupk
209 | default: Renaming machine to 'sunboot'...
210 | default: Installing packages...
211 | default: Adjusting kernel settings...
212 | default: Enable rdate service...
213 | default: Creating server directories...
214 | default: Configuring NFS daemons...
215 | default: Setting up rsh shims...
216 | default: Configuring bridge interface...
217 | default: sunboot initialization complete.
218 | ==> default: Running provisioner: provision (shell)...
219 | default: Running: C:/Users/sunboot/AppData/Local/Temp/vagrant-shell20180718-6128-3rk3gf
220 | default: --------------------------------------
221 | default: Installing target "hobbes"...
222 | default: --------------------------------------
223 | default: Mounting CD-ROM image...
224 | default: Found SunOS 4.1.4
225 | default: --------------------------------------
226 | default: SunOS 4.1.4 SUNBIN
227 | default: sun4c, sun4, sun4m
228 | default: CD-ROM (boot format) 1 of 1
229 | default: 258-4662
230 | default: Solaris(R) 1.1.2
231 | default: Sun-4(TM), Sun-4c, Sun-4m, SPARC(R)
232 | default: Part Number: 258-4662
233 | default: CD-ROM (1 of 1) ISO 9660 format
234 | default: --------------------------------------
235 | default: Available architectures on this media:
236 | default: sun4.sun4c.sunos.4.1.4
237 | default: sun4.sun4.sunos.4.1.4
238 | default: sun4.sun4m.sunos.4.1.4
239 | default: Detected version: 4.1.4
240 | default: Selected architecture: sun4.sun4c.sunos.4.1.4
241 | default: Creating diskless install...
242 | default: Extracting "debugging" set...
243 | default: Extracting "demo" set...
244 | default: Extracting "games" set...
245 | default: Extracting "graphics" set...
246 | default: Extracting "install" set...
247 | default: Extracting "networking" set...
248 | default: Extracting "openwindows_demo" set...
249 | default: Extracting "openwindows_fonts" set...
250 | default: Extracting "openwindows_programmers" set...
251 | default: Extracting "openwindows_users" set...
252 | default: Extracting "rfs" set...
253 | default: Extracting "security" set...
254 | default: Extracting "shlib_custom" set...
255 | default: Extracting "sunview_demo" set...
256 | default: Extracting "sunview_programmers" set...
257 | default: Extracting "sunview_users" set...
258 | default: Extracting "system_v" set...
259 | default: Extracting "text" set...
260 | default: Extracting "tli" set...
261 | default: Extracting "user_diag" set...
262 | default: Extracting "usr" set...
263 | default: Extracting "uucp" set...
264 | default: Extracting "versatec" set...
265 | default: Extracting "manual" set...
266 | default: --------------------------------------
267 | default: Install complete for "hobbes".
268 | default: --------------------------------------
269 |
270 | ==> default: Machine 'default' has a post `vagrant up` message. This is a message
271 | ==> default: from the creator of the Vagrantfile, and not from Vagrant itself:
272 | ==> default:
273 | ==> default: ["sunboot initialization complete."]
274 |
275 | ```
276 |
277 | At this stage the server is now ready to boot the target machine. From the target machine, all that should be required is a `boot net` command. The following is the output from the serial console:
278 |
279 | ```
280 | not nvramrc
281 | SPARCstation IPC, No keyboard.
282 | ROM Rev. 1.6, 32 MB memory installed, Serial #687503.
283 | Ethernet address 8:0:20:a:7d:8f, Host ID: 520a7d8f.
284 |
285 |
286 | Testing
287 | Type b (boot), c (continue), or n (new command mode)
288 | >n
289 | ok boot net
290 | Booting from: le(0,0,0)
291 | 1ee00 Using IP Address 10.94.42.208 = 0A5E2AD0
292 | hostname: hobbes
293 | domainname: (none)
294 | server name 'sunboot'
295 | root pathname '/export/root/hobbes'
296 | root on sunboot:/export/root/hobbes fstype nfs
297 | Boot: vmunix
298 | Size: 1343488+218832+131992 bytes
299 | SunOS Release 4.1.4 (GENERIC) #2: Fri Oct 14 11:08:06 PDT 1994
300 | Copyright (c) 1983-1993, Sun Microsystems, Inc.
301 | mem = 32768K (0x2000000)
302 | avail mem = 30531584
303 | Ethernet address = 8:0:20:a:7d:8f
304 | cpu = Sun 4/40
305 | zs0 at obio 0xf1000000 pri 12
306 | zs1 at obio 0xf0000000 pri 12
307 | fd0 at obio 0xf7200000 pri 11
308 | audio0 at obio 0xf7201000 pri 13
309 | sbus0 at SBus slot 0 0x0
310 | dma0 at SBus slot 0 0x400000
311 | esp0 at SBus slot 0 0x800000 pri 3
312 | esp0: Warning- no devices found for this SCSI bus
313 | le0 at SBus slot 0 0xc00000 pri 5
314 | dma1 at SBus slot 1 0x81000
315 | esp1 at SBus slot 1 0x80000 pri 3
316 | esp1: Warning- no devices found for this SCSI bus
317 | lebuffer0 at SBus slot 1 0x40000
318 | le1 at SBus slot 1 0x60000 pri 5
319 | cgsix0 at SBus slot 2 0x0 pri 7
320 | cgsix0: screen 1152x900, single buffered, 1M mappable, rev 6
321 | bwtwo0 at SBus slot 3 0x0 pri 7
322 | hostname: hobbes
323 | domainname: (none)
324 | root on sunboot:/export/root/hobbes fstype nfs
325 | swap on sunboot:/export/swap/hobbes fstype nfs size 65536K
326 | dump on sunboot:/export/swap/hobbes fstype nfs size 65524K
327 |
328 |
329 |
330 | hobbes login: root
331 | Jul 18 16:23:52 hobbes login: ROOT LOGIN console
332 | Last login: Wed Jul 18 16:17:19 from 10.94.42.30
333 | SunOS Release 4.1.4 (GENERIC) #2: Fri Oct 14 11:08:06 PDT 1994
334 | hobbes#
335 |
336 | ```
337 |
338 |
339 | ### Diskful install of Solaris 2.3 on a SPARCclassic
340 |
341 | `targets/ssx`:
342 |
343 | ```bash
344 | # SPARCclassic Solaris 2.3 Diskful Install Example
345 |
346 | TARGETARCH=sun4m
347 | TARGETNAME=ssx
348 | TARGETETHER=8:0:20:5:61:c2
349 | TARGETADDR=10.94.42.209
350 | TARGETSWAPSIZE=64
351 |
352 | # options: DISKLESS or DISKFUL
353 | INSTALLMETHOD=DISKFUL
354 |
355 | # options: CDROM or TAPE
356 | INSTALLMEDIA=CDROM
357 |
358 | # path (within 'sunos' directory) to the install CD-ROM or directory that contains 'tape1', 'tape2', etc. dirs
359 | INSTALLMEDIAPATH=solaris_2.3_sparc.iso
360 | ```
361 |
362 | ```
363 | $ git clone https://github.com/halfmanhalftaco/sunboot.git
364 | $ cd sunboot
365 | $ vi Vagrantfile sunboot-settings targets/ssx # edit the configurations
366 | $ vagrant up
367 | Bringing machine 'default' up with 'virtualbox' provider...
368 | ==> default: Importing base box 'debian/contrib-jessie64'...
369 | ==> default: Matching MAC address for NAT networking...
370 | ==> default: Checking if box 'debian/contrib-jessie64' is up to date...
371 | ==> default: Setting the name of the VM: sunboot_default_1531931457995_66060
372 | ==> default: Clearing any previously set network interfaces...
373 | ==> default: Preparing network interfaces based on configuration...
374 | default: Adapter 1: nat
375 | default: Adapter 2: bridged
376 | ==> default: Forwarding ports...
377 | default: 22 (guest) => 2222 (host) (adapter 1)
378 | ==> default: Running 'pre-boot' VM customizations...
379 | ==> default: Booting VM...
380 |
381 | ==> default: Mounting shared folders...
382 | default: /vagrant => F:/src/sunboot
383 | ==> default: Running provisioner: initialize (shell)...
384 | default: Running: C:/Users/sunboot/AppData/Local/Temp/vagrant-shell20180718-20392-1ylgzm6
385 | default: Renaming machine to 'sunboot'...
386 | default: Installing packages...
387 | default: Adjusting kernel settings...
388 | default: Enable rdate service...
389 | default: Creating server directories...
390 | default: Configuring NFS daemons...
391 | default: Setting up rsh shims...
392 | default: Configuring bridge interface...
393 | default: sunboot initialization complete.
394 | ==> default: Running provisioner: provision (shell)...
395 | default: Running: C:/Users/sunboot/AppData/Local/Temp/vagrant-shell20180718-20392-1yn3bxy
396 | default: --------------------------------------
397 | default: Installing target "ssx"...
398 | default: --------------------------------------
399 | default: Mounting CD-ROM image...
400 | default: Found Solaris 2.3
401 | default: --------------------------------------
402 | default: Solaris(TM) 2.3 Hardware: 8/94, Binary
403 | default: SPARC SUNBIN
404 | default: CD-ROM (Rockridge Format)
405 | default: Part Number: 258-4455
406 | default: --------------------------------------
407 | default: Available architectures on this media:
408 | default: sparc.sol5.Solaris_2.3
409 | default: sparc.sol6.Solaris_2.3
410 | default: sparc.sun4c.Solaris_2.3
411 | default: sparc.sun4d.Solaris_2.3
412 | default: sparc.sun4e.Solaris_2.3
413 | default: sparc.sun4m1.Solaris_2.3
414 | default: sparc.sun4m.Solaris_2.3
415 | default: sparc.sun4.Solaris_2.3
416 | default: Detected version: Solaris_2.3
417 | default: Selected architecture: sparc.sun4m.Solaris_2.3
418 | default: Copying sun4m miniroot to /export/root/ssx
419 | default: Configuring NFS exports...
420 | default: Configuring bootparams...
421 | default: --------------------------------------
422 | default: Install complete for "ssx".
423 | default: --------------------------------------
424 |
425 | ==> default: Machine 'default' has a post `vagrant up` message. This is a message
426 | ==> default: from the creator of the Vagrantfile, and not from Vagrant itself:
427 | ==> default:
428 | ==> default: ["sunboot initialization complete."]
429 |
430 | ```
431 |
432 | Serial console:
433 | ```
434 | SPARCclassic, No Keyboard
435 | ROM Rev. 2.12, 72 MB memory installed, Serial #190146.
436 | Ethernet address 8:0:20:5:61:c2, Host ID: 8002e6c2.
437 |
438 |
439 |
440 | Type help for more information
441 | ok boot net
442 | Boot device: /iommu/sbus/ledma@4,8400010/le@4,8c00000 File and args:
443 | hostname: ssx
444 | domainname: (none)
445 | root server: sunboot
446 | root directory: /export/root/ssx
447 | SunOS Release 5.3 Version Generic [UNIX(R) System V Release 4.0]
448 | Copyright (c) 1983-1993, Sun Microsystems, Inc.
449 | WARNING: TOD clock not initialized -- CHECK AND RESET THE DATE!
450 | Configuring the /devices directory
451 | Configuring the /dev directory
452 | The system is coming up. Please wait.
453 |
454 | What type of terminal are you using?
455 | 1) ANSI Standard CRT
456 | 2) DEC VT52
457 | 3) DEC VT100
458 | 4) Heathkit 19
459 | 5) Lear Siegler ADM31
460 | 6) PC Console
461 | 7) Sun Command Tool
462 | 8) Sun Workstation
463 | 9) Televideo 910
464 | 10) Televideo 925
465 | 11) Wyse Model 50
466 | 12) Other
467 | Type the number of your choice and press Return:3
468 | starting rpc services: rpcbind sysidnis
469 |
470 |
471 | Do you want to configure this system as a client of a name service? If so,
472 | which name service do you want to use? If you do not want to use a name
473 | service select `none' and consult your Install documentation.
474 |
475 |
476 |
477 | lqqqqqqqqqqqqqqqqqqqqqqqqqk
478 | x>NIS+ Client x
479 | x NIS (formerly yp) Clientx
480 | x None - use /etc files x
481 | mqqqqqqqqqqqqqqqqqqqqqqqqqj
482 |
483 |
484 |
485 |
486 | Use the arrow keys to select an item. (CTRL-n next, CTRL-p previous)
487 |
488 | Press Return to continue.
489 |
490 | Does this workstation's network have sub-networks?
491 |
492 |
493 |
494 | lqqqqk
495 | x>No x
496 | x Yesx
497 | mqqqqj
498 |
499 |
500 |
501 |
502 | Use the arrow keys to select an item. (CTRL-n next, CTRL-p previous)
503 |
504 | Press Return to continue.
505 |
506 | This is your default netmask value. You may change it if necessary, but the
507 | format must remain as four numbers separated by periods.
508 |
509 |
510 | lqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
511 | x x
512 | x Netmask: 255.255.255.0___ x
513 | x x
514 | mqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
515 |
516 |
517 |
518 |
519 | Press Return to continue.
520 |
521 | Is the following information correct?
522 |
523 | Name service: none
524 | Network is sub-netted: Yes
525 | Netmask: 255.255.255.0
526 |
527 |
528 |
529 | lqqqqqqqqqqqqqqqqqqqqqqqqqk
530 | x No, re-enter informationx
531 | x>Yes, continue x
532 | mqqqqqqqqqqqqqqqqqqqqqqqqqj
533 |
534 |
535 |
536 |
537 | Use the arrow keys to select an item. (CTRL-n next, CTRL-p previous)
538 |
539 | Press Return to continue.
540 |
541 | < time zone selection screens, etc. snipped >
542 |
543 | lqqqqqqqqqqqqqqqqqqqqqqqqqqq[ Solaris Installation ]qqqqqqqqqqqqqqqqqqqqqqqqqqqk
544 | x x
545 | x x
546 | x x
547 | x x
548 | x x
549 | x ( Quick Install... ) x
550 | x x
551 | x ( Custom Install... ) x
552 | x x
553 | x ( Exit Install... ) x
554 | x x
555 | x ( Help... ) x
556 | x x
557 | x x
558 | x x
559 | x x
560 | x x
561 | x x
562 | x x
563 | tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu
564 | x Select; Next Field; Help x
565 | mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
566 | ```
567 |
568 | ---
569 |
570 | ## Maintenance
571 |
572 | Since sunboot supports diskless clients you probably don't want to be destroying/recreating the VM very often. There's a couple commands built in that help add new clients and remove old ones.
573 |
574 | To run these commands you'll need to log into the Vagrant VM with `vagrant ssh`.
575 |
576 | ### Commands
577 |
578 | - `sudo target_rm `
579 | - This will remove all of the install artifacts for the given target, including its NFS exports, root filesystem, etc. It does *not* remove the target configuration file or the generic miniroot/exec/protoroot environment for the target's operating system.
580 | - This is particularly recommended for SunOS diskful targets after the OS has been installed to disable root rsh capability to the boot server.
581 | - `sudo install_targets`
582 | - Run this command to reprocess all the target files in the `targets` directory. It skips any targets that already have root filesystems in place (in `/export/root/`)
583 | - `sudo mount_media `
584 | - When multiple machines are configured for diskful installs, the correct install media may not be ready for the client. Run this to ensure that the appropriate media for this target is configured.
585 |
586 | ---
587 |
588 | ## License
589 | The MIT License
590 |
591 | Copyright 2018 Andrew Liles
592 |
593 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
594 |
595 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
596 |
597 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/Vagrantfile:
--------------------------------------------------------------------------------
1 | # -*- mode: ruby -*-
2 | # vi: set ft=ruby :
3 |
4 | Vagrant.configure("2") do |config|
5 | config.vm.box = "debian/contrib-jessie64"
6 | config.vm.box_version = "8.11.0"
7 | config.vm.network "public_network", auto_config: false, bridge: "eth1"
8 | config.vm.provision "initialize", type: "shell", path: "scripts/sunboot_init", run: "once"
9 | config.vm.provision "provision", type: "shell", path: "scripts/install_targets", run: "always"
10 |
11 | config.vm.post_up_message = [ "sunboot initialization complete." ]
12 | end
13 |
--------------------------------------------------------------------------------
/scripts/functions.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # sunboot functions.sh
4 | CDROM=/cdrom
5 |
6 | . /vagrant/scripts/utils.sh
7 |
8 | function cdrom_detect() {
9 | if [ -f $CDROM/.cdtoc ]; then
10 | if [ $(grep PRODNAME $CDROM/.cdtoc | cut -d '=' -f 2 | tr a-z A-Z) = "SOLARIS" ]; then
11 | SOLARIS=1
12 | SUNOS=0
13 | SOLARIS_VERSION=$(grep PRODVERS $CDROM/.cdtoc | cut -d '=' -f 2)
14 | echo "Found Solaris $SOLARIS_VERSION"
15 | fi
16 | elif [ -f $CDROM/avail_arches ]; then
17 | SUNOSTMP=$(grep sunos $CDROM/avail_arches | head -1)
18 | if [[ $SUNOSTMP =~ sunos\.(.*)$ ]]; then
19 | SUNOS_VERSION="${BASH_REMATCH[1]}"
20 | SUNOS=1
21 | SOLARIS=0
22 | echo "Found SunOS $SUNOS_VERSION"
23 | fi
24 | else
25 | error_exit "Unable to detect SunOS or Solaris on the CD-ROM."
26 | fi
27 | }
28 |
29 | function cdrom_select_arch_sunos() {
30 | # Read version/architecture info
31 | if [ -f $CDROM/_copyright ]; then
32 | echo "--------------------------------------"
33 | sed -e '/^$/,$d' $CDROM/_copyright
34 | echo "--------------------------------------"
35 | fi
36 |
37 | if [ -f $CDROM/avail_arches ]; then
38 | echo "Available architectures on this media:"
39 | cat $CDROM/avail_arches
40 | fi
41 |
42 | # select architecture
43 | case $TARGETARCH in
44 | sun4*)
45 | SELECTEDARCH=$(grep sun4.$TARGETARCH $CDROM/avail_arches)
46 | SELECTEDVERSION=$(expr $SELECTEDARCH : ".*\.sunos\.\(.*\)$")
47 | ;;
48 | *)
49 | error_exit "Target arch $TARGETARCH is not supported for CD-ROM releases."
50 | ;;
51 | esac
52 |
53 | echo "Detected version: $SELECTEDVERSION"
54 | echo "Selected architecture: $SELECTEDARCH"
55 |
56 | if ! grep -q $TARGETARCH $CDROM/avail_arches; then
57 | error_exit "This media does not support the $TARGETARCH architecture specified in the target."
58 | fi
59 | }
60 |
61 | function cdrom_select_arch_solaris() {
62 | if [ -f $CDROM/Copyright ]; then
63 | echo "--------------------------------------"
64 | sed -e '/Copyright/,$ d' -e '/^$/d' $CDROM/Copyright
65 | echo "--------------------------------------"
66 | fi
67 |
68 | if [ -d $CDROM/archinfo ]; then
69 | echo "Available architectures on this media:"
70 | ls -1 $CDROM/archinfo
71 | fi
72 |
73 | if [ -d $CDROM/export/exec/kvm/*.$TARGETARCH.* ]; then
74 | SELECTEDARCH=$(basename $CDROM/export/exec/kvm/*.$TARGETARCH.*)
75 | SELECTEDVERSION=$(expr $SELECTEDARCH : "[a-zA-Z0-9]*\.$TARGETARCH\.\(.*\)")
76 | echo "Detected version: $SELECTEDVERSION"
77 | echo "Selected architecture: $SELECTEDARCH"
78 | else
79 | error_exit "This media does not support the $TARGETARCH architecture specified in the target."
80 | fi
81 | }
82 |
83 | function cdrom_select_arch() {
84 | if [ $SOLARIS -eq 1 ]; then
85 | cdrom_select_arch_solaris
86 | elif [ $SUNOS -eq 1 ]; then
87 | cdrom_select_arch_sunos
88 | fi
89 | }
90 |
91 | function cdrom_mount() {
92 | # mount the cdrom, checking if it's already mounted
93 | lmount=$(mount | grep $CDROM | cut -d ' ' -f 1)
94 | if [ ! -z $lmount ]; then
95 | # check if this is the CDROM we want
96 | lfile=$(losetup -l -n -O NAME,BACK-FILE | grep $lmount | cut -d ' ' -f 2-)
97 | if [ $lfile != "/vagrant/sunos/$INSTALLMEDIAPATH" ]; then
98 | umount $lmount || error_exit "Failed to unmount existing CD-ROM"
99 | losetup -d $lmount || error_exit "Failed to unconfigure loop device"
100 | losetup -r -P /dev/loop0 /vagrant/sunos/$INSTALLMEDIAPATH || error_exit "Failed to configure loop device"
101 | mount -o ro /dev/loop0 $CDROM || error_exit "Failed to mount CD-ROM"
102 | fi
103 | else
104 | losetup -d /dev/loop0 >/dev/null 2>&1
105 | losetup -r -P /dev/loop0 /vagrant/sunos/$INSTALLMEDIAPATH || error_exit "Failed to configure loop device"
106 | mount -o ro /dev/loop0 $CDROM || error_exit "Failed to mount CD-ROM"
107 | fi
108 | }
109 |
110 | function cdrom_unmount() {
111 | umount /dev/loop0
112 | losetup -d /dev/loop0
113 | }
114 |
115 | function cdrom_copy_miniroot() {
116 | # copy from disc if we don't already have a copy
117 | if [ ! -d /export/miniroot/$SELECTEDARCH ]; then
118 | mkdir -p /export/miniroot/$SELECTEDARCH
119 |
120 | # different steps if Solaris vs. SunOS
121 |
122 | if [ $SUNOS -eq 1 ]; then
123 | losetup -r /dev/loop1 $CDROM/export/exec/kvm/$TARGETARCH_sunos_*/miniroot_$TARGETARCH
124 | mount -o ro,ufstype=sun /dev/loop1 /mnt
125 | rsync -a /mnt/ /export/miniroot/$SELECTEDARCH
126 | umount /mnt
127 | mv /export/miniroot/$SELECTEDARCH/boot.$TARGETARCH /export/miniroot/$SELECTEDARCH/boot
128 | elif [ $SOLARIS -eq 1 ]; then
129 | pushd $CDROM/export/exec/kvm/$SELECTEDARCH
130 | find . -depth -print | cpio -pdm /export/miniroot/$SELECTEDARCH >/dev/null 2>&1
131 | popd
132 | AARCH=$(expr $SELECTEDARCH : "\(.*\)\.$TARGETARCH\.$SELECTEDVERSION")
133 | pushd $CDROM/export/exec/$AARCH.$SELECTEDVERSION/lib/fs/nfs
134 | if [ -f inetboot.$SELECTEDARCH ]; then
135 | cp inetboot.$SELECTEDARCH /export/miniroot/$SELECTEDARCH/inetboot
136 | elif [ -f inetboot ]; then
137 | cp inetboot /export/miniroot/$SELECTEDARCH/inetboot
138 | else
139 | error_exit "Could not find Solaris bootloader."
140 | fi
141 | popd
142 | else
143 | error_exit "Unknown operating system."
144 | fi
145 |
146 | fi
147 | if [ -d /export/root/$TARGETNAME ]; then
148 | echo "Root directory /export/root/$TARGETNAME already exists, not overwriting."
149 | exit 1
150 | fi
151 | mkdir -p /export/root/$TARGETNAME
152 | rsync -a /export/miniroot/$SELECTEDARCH/ /export/root/$TARGETNAME
153 | }
154 |
155 | function cdrom_install_diskless() {
156 | # for SunOS 4.1.4 (possibly any 4.1.x CD-ROM release) this should do:
157 | # if new version/arch combo, extract proto root to /export/proto/arch_sunos_version
158 | # create new /export/root dir for target host from proto
159 | # untar distribution on top
160 | # move /usr into /export/exec/version_arch
161 | # configure hostname, network, etc in target root
162 |
163 | if [ $SOLARIS -eq 1 ]; then error_exit "Solaris not yet supported"; fi
164 |
165 | ARCHTMP=sunos_$(echo $SELECTEDVERSION | tr . _)
166 |
167 | if [ -z $SELECTEDARCH ]; then
168 | echo "No distribution architecture has been selected."
169 | exit 1
170 | fi
171 |
172 | if [ ! -d /export/proto/$SELECTEDARCH ]; then
173 | mkdir -p /export/proto/$SELECTEDARCH
174 | pushd /export/proto/$SELECTEDARCH
175 | tar xf $CDROM/export/exec/proto_root_$ARCHTMP
176 | # untar kvm, sys
177 | mkdir -p usr/kvm
178 | pushd usr/kvm
179 | tar xf $CDROM/export/exec/kvm/${TARGETARCH}_${ARCHTMP}/kvm
180 | tar xf $CDROM/export/exec/kvm/${TARGETARCH}_${ARCHTMP}/sys
181 | popd
182 | pushd usr
183 | # untar rest of distribution sets here (in export/exec/sun4_sunos_4_1_4)
184 | for tarfile in $CDROM/export/exec/*sunos*/* $CDROM/export/share/*/* ; do
185 | echo "Extracting \"$(basename $tarfile)\" set..."
186 | tar xf $tarfile
187 | done
188 | popd
189 |
190 | cp usr/kvm/stand/{kadb,vmunix} .
191 | cp usr/kvm/stand/boot.$TARGETARCH ./boot
192 | cp usr/kvm/boot/* ./sbin
193 | cp usr/stand/sh ./sbin
194 | cp usr/bin/hostname ./sbin
195 | popd
196 |
197 | if [ -d /export/exec/$SELECTEDARCH ]; then rm -rf /export/exec/$SELECTEDARCH; fi
198 | mv /export/proto/$SELECTEDARCH/usr /export/exec/$SELECTEDARCH
199 | mkdir -p /export/proto/$SELECTEDARCH/usr
200 | fi
201 |
202 | # create new install for $TARGETNAME
203 |
204 | ROOT=/export/root/$TARGETNAME
205 |
206 | if [ -d $ROOT ]; then
207 | echo "Existing root for \"$TARGETNAME\" exists, moving it to $ROOT.old"
208 | rm -rf $ROOT.old
209 | mv $ROOT $ROOT.old
210 | fi
211 |
212 | mkdir -p $ROOT
213 | rsync -a /export/proto/$SELECTEDARCH/ $ROOT
214 |
215 | pushd $ROOT
216 |
217 | # customize for our target
218 |
219 | # edit hosts, hostname.xxx, fstab
220 | printf "$TARGETADDR $TARGETNAME\n$SERVERADDR $SERVERNAME\n" >> etc/hosts
221 | echo "$TARGETNAME" > etc/hostname.le0
222 | cat << EOF > etc/fstab
223 | $SERVERNAME:$ROOT / nfs rw 0 0
224 | $SERVERNAME:/export/exec/$SELECTEDARCH /usr nfs ro 0 0
225 | $SERVERNAME:/export/home /home nfs rw 0 0
226 | EOF
227 | # todo: find out how to make sunos respect subnet netmask
228 |
229 | # patch/run MAKEDEV std pty0 pty1 pty2 win0 win1 win2
230 | pushd dev
231 | sed -e 's#^PATH=.*$#PATH=/vagrant/shims:$PATH#' MAKEDEV > MAKEDEV.sunboot && chmod u+x MAKEDEV.sunboot
232 | ./MAKEDEV.sunboot std pty0 pty1 pty2 win0 win1 win2 >/dev/null
233 | popd
234 | # move 'yp' dir out of place
235 | mv var/yp var/yp.disabled
236 | popd
237 |
238 | echo "$SELECTEDARCH" > $ROOT/.sunboot
239 |
240 | }
241 |
242 | # setup NFS exports
243 | function configure_nfs() {
244 | # setup swap space for client
245 | rm -f /export/swap/$TARGETNAME
246 | dd if=/dev/zero of=/export/swap/$TARGETNAME bs=1M count=$TARGETSWAPSIZE >/dev/null 2>&1
247 |
248 | cat << EOF >> /etc/exports
249 | /export/root/$TARGETNAME $TARGETADDR(rw,sync,no_root_squash,no_subtree_check)
250 | /export/swap/$TARGETNAME $TARGETADDR(rw,sync,no_root_squash,no_subtree_check)
251 | EOF
252 |
253 | exportfs -ra
254 | }
255 |
256 | # Setup rarp, bootparams and rsh
257 | function config_boot() {
258 | ETHER=$(normal_ether $TARGETETHER)
259 | BOOTPARAMS="root=$SERVERNAME:/export/root/$TARGETNAME swap=$SERVERNAME:/export/swap/$TARGETNAME"
260 | BOOTPROGRAM="boot"
261 |
262 | if [ $SOLARIS -eq 1 ]; then
263 | BOOTPROGRAM="inetboot"
264 | if [ $INSTALLMETHOD = "DISKFUL" ]; then
265 | BOOTPARAMS="root=$SERVERNAME:/export/root/$TARGETNAME install=$SERVERNAME:$CDROM"
266 | fi
267 | fi
268 |
269 | if [ $SUNOS -eq 1 ]; then
270 | echo "$TARGETNAME root" > /root/.rhosts
271 | fi
272 |
273 | # todo - remove existing entries before blindly adding them
274 | echo "$TARGETNAME $BOOTPARAMS" >> /etc/bootparams
275 | echo "$ETHER $TARGETNAME" >> /etc/ethers
276 | echo "$TARGETADDR $TARGETNAME" >> /etc/hosts
277 | arp -s $TARGETADDR $ETHER
278 |
279 | # Link bootloader
280 | IPHEX=$(iphex $TARGETADDR)
281 | pushd /srv/tftp
282 | cp -f /export/root/$TARGETNAME/$BOOTPROGRAM ./$BOOTPROGRAM.$SELECTEDARCH
283 | ln -s $BOOTPROGRAM.$SELECTEDARCH $IPHEX
284 | ln -s $BOOTPROGRAM.$SELECTEDARCH $IPHEX.$(echo $TARGETARCH | tr a-z A-Z)
285 | popd
286 |
287 | systemctl restart bootparamd
288 | }
289 |
--------------------------------------------------------------------------------
/scripts/insecure_disable:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # insecure_disable
4 | #
5 | # Turn off obviously-insecure services that are not necessary
6 | # for running diskless clients (only for running diskful installs).
7 | #
8 | # Affects: rsh
9 |
10 | if [[ $EUID -ne 0 ]]; then
11 | echo "This script must be run as root"
12 | exit 1
13 | fi
14 |
--------------------------------------------------------------------------------
/scripts/insecure_enable:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # insecure_disable
4 | #
5 | # Turn on obviously-insecure services needed for running network
6 | # installs for SunOS.
7 | #
8 | # Affects: rsh
9 |
10 | if [[ $EUID -ne 0 ]]; then
11 | echo "This script must be run as root"
12 | exit 1
13 | fi
--------------------------------------------------------------------------------
/scripts/install_targets:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # sunboot install_targets
4 | # run this script to automatically process the targets directory
5 |
6 | if [[ $EUID -ne 0 ]]; then
7 | echo "This script must be run as root"
8 | exit 1
9 | fi
10 |
11 | . /vagrant/sunboot-settings
12 | . /vagrant/scripts/functions.sh
13 |
14 | DISKFUL_COUNT=0
15 |
16 | function do_install() {
17 | case $INSTALLMEDIA in
18 | CDROM)
19 | echo "Mounting CD-ROM image..."
20 | cdrom_mount
21 | cdrom_detect
22 | cdrom_select_arch
23 | ;;
24 | TAPE)
25 | echo "Tape media not yet supported."
26 | exit 1
27 | ;;
28 | esac
29 |
30 | case $INSTALLMETHOD in
31 | DISKFUL)
32 | echo "Copying $TARGETARCH miniroot to /export/root/$TARGETNAME"
33 | cdrom_copy_miniroot
34 | echo "Configuring NFS exports..."
35 | configure_nfs
36 | echo "Configuring bootparams..."
37 | config_boot
38 | DISKFUL_COUNT=$(($DISKFUL_COUNT+1))
39 | DISKFUL_TARGET=$(basename $target)
40 | ;;
41 | DISKLESS)
42 | echo "Creating diskless install..."
43 | cdrom_install_diskless
44 | configure_nfs
45 | config_boot
46 | ;;
47 | esac
48 | }
49 |
50 | tcount=$(ls -1 /vagrant/targets | wc -l)
51 | if [ $tcount -eq 0 ]; then
52 | echo "No targets specified."
53 | exit 1
54 | fi
55 |
56 | for target in /vagrant/targets/* ; do
57 | DISABLED=0
58 | . $target
59 | if [ $DISABLED -eq 1 ]; then continue; fi
60 | if [ ! -d /export/root/$TARGETNAME ]; then
61 | echo "--------------------------------------"
62 | echo "Installing target \"$TARGETNAME\"..."
63 | echo "--------------------------------------"
64 | do_install
65 | echo "--------------------------------------"
66 | echo "Install complete for \"$TARGETNAME\"."
67 | echo "--------------------------------------"
68 | else
69 | echo "Skipping \"$TARGETNAME\", root dir already exists"
70 | fi
71 | done
72 |
73 | if [ $DISKFUL_COUNT -gt 1 ]; then
74 | echo "More than one diskful install is configured!"
75 | echo "use \"sudo mount_media \" to switch which target media is mounted to correctly install these targets."
76 | elif [ $DISKFUL_COUNT -eq 1 ]; then
77 | /vagrant/scripts/mount_media $DISKFUL_TARGET # ensure the media for the diskful install is mounted
78 | fi
--------------------------------------------------------------------------------
/scripts/iphex:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | . /vagrant/scripts/functions.sh
4 |
5 | iphex $1
6 | echo
--------------------------------------------------------------------------------
/scripts/mount_media:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # mount_media
4 | #
5 | # When more than one diskful install is configured in 'targets', which media
6 | # should be mounted at any given time is ambiguous. This script ensures that
7 | # the media specified for the given target is available for a diskful install.
8 | #
9 | # Usage:
10 | # mount_media
11 | #
12 | # where target is one of the files in the 'target' subdirectory of sunboot.
13 |
14 | if [[ $EUID -ne 0 ]]; then
15 | echo "This script must be run as root"
16 | exit 1
17 | fi
18 |
19 | . /vagrant/scripts/functions.sh
20 |
21 | if [ ! -f /vagrant/targets/$1 ]; then
22 | error_exit "Target \"$1\" not found."
23 | fi
24 |
25 | . /vagrant/targets/$1
26 |
27 | case $INSTALLMEDIA in
28 | CDROM)
29 | cdrom_mount
30 | ;;
31 | TAPE)
32 | error_exit "Not yet supported"
33 | ;;
34 | esac
--------------------------------------------------------------------------------
/scripts/proto_install:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # sunboot proto_install
4 | # Installs root filesystem prototypes and exec directories
5 | # for all of the architectures on the provided media.
6 |
7 | # Usage:
8 | # proto_install [-t CDROM|TAPE] path_to_media
9 | #
10 | # In the case of CDROM media, path_to_media should be a CDROM image (ISO9660)
11 | # For tape, the path should be a directory that contains subdirectories named
12 | # tape1, tape2, etc, each containing numbered files representing the tape
13 | # file layout.
14 | #
15 | # The script will inspect the media and take the appropriate steps to copy
16 | # everything needed to support booting clients.
17 |
18 | if [[ $EUID -ne 0 ]]; then
19 | echo "This script must be run as root"
20 | exit 1
21 | fi
22 |
23 | echo "Not yet implemented!"
24 | exit 1
--------------------------------------------------------------------------------
/scripts/sunboot_init:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | . /vagrant/sunboot-settings
4 |
5 | echo "Renaming machine to '$SERVERNAME'..."
6 | cp /etc/hosts /etc/hosts.orig
7 | echo "$SERVERNAME" > /etc/hostname
8 | printf "127.0.0.1 localhost\n$SERVERADDR $SERVERNAME\n" > /etc/hosts
9 | /etc/init.d/hostname.sh
10 | invoke-rc.d rsyslog restart
11 |
12 | # Install required packages
13 | echo "Installing packages..."
14 | apt-get install -y rsync openbsd-inetd rsh-server rsh-client bootparamd \
15 | nfs-kernel-server tftpd-hpa rarpd tcpdump >/dev/null 2>&1
16 | modprobe -a ufs
17 |
18 | # todo make rarpd/tftpd/bootparamd only listen on eth1 (and possibly only respond to our targets)
19 |
20 | echo "Adjusting kernel settings..."
21 | echo << EOF >> /etc/sysctl.conf
22 | net.ipv4.ip_no_pmtu_disc=1
23 | net.ipv4.ip_local_port_range = 2048 32767
24 | EOF
25 | sysctl -p
26 |
27 | echo "Enable rdate service..."
28 | sed -i 's/^#time/time/' /etc/inetd.conf
29 | systemctl restart openbsd-inetd
30 |
31 | # Set up server directories
32 | echo "Creating server directories..."
33 | mkdir -p /cdrom /usr/etc/install /export/{root,exec,swap,home,proto,miniroot,opt} /srv/tftp
34 | ln -sf /cdrom /usr/etc/install/tar
35 |
36 | # Setup NFS for v2/v3 support
37 | echo "Configuring NFS daemons..."
38 | sed -i 's/^RPCMOUNTDOPTS.*/RPCMOUNTDOPTS="--manage-gids --no-nfs-version 4"/' /etc/default/nfs-kernel-server
39 | sed -i 's/^NEED_STATD.*/NEED_STATD=yes/' /etc/default/nfs-common
40 | # todo: limit exports to our subnet
41 | echo "/export/exec *(ro,sync,no_root_squash,no_subtree_check)" >> /etc/exports
42 | echo "/export/home *(rw,sync,no_root_squash,no_subtree_check)" >> /etc/exports
43 | echo "/cdrom *(ro,sync,no_root_squash,no_subtree_check)" >> /etc/exports
44 | systemctl enable nfs-kernel-server >/dev/null 2>&1
45 | systemctl enable rpcbind >/dev/null 2>&1
46 | systemctl restart nfs-kernel-server
47 | systemctl restart rpcbind
48 |
49 | # Enable $SERVERNAME shims for rsh (mount, dd, mt)
50 | echo "Setting up rsh shims..."
51 | cat << EOF >> /root/.bashrc
52 | if [ $(ps -o comm= -p $PPID) == "in.rshd" ]; then
53 | export PATH=/vagrant/shims:\$PATH
54 | export HISTFILE=/vagrant/rsh_history.txt
55 | set -o history
56 | fi
57 | EOF
58 |
59 | # add our scripts to PATH in the user acct and in sudo
60 | sed -i 's#secure_path="#secure_path="/vagrant/scripts:#' /etc/sudoers
61 | echo 'export PATH=/vagrant/scripts:$PATH' >> ~vagrant/.bashrc
62 |
63 | # ensure our scripts are executable
64 | chmod 755 /vagrant/scripts/* /vagrant/shims/*
65 |
66 | # do dumb things; SunOS installers expect classful IP addressing
67 | # todo: change so this is only applied when SunOS <= 4.x.x targets are present
68 | echo "Configuring bridge interface..."
69 | IFS=. read -r i1 i2 i3 i4 <<< $SERVERADDR
70 | echo "iface eth1 inet static" >> /etc/network/interfaces
71 | echo " address $SERVERADDR" >> /etc/network/interfaces
72 | if [ $i1 -lt 128 ]; then
73 | echo " netmask 255.0.0.0" >> /etc/network/interfaces
74 | elif [ $i1 -lt 192 ]; then
75 | echo " netmask 255.255.0.0" >> /etc/network/interfaces
76 | else
77 | echo " netmask 255.255.255.0" >> /etc/network/interfaces
78 | fi
79 | ifup eth1
80 |
81 |
82 | echo "sunboot initialization complete."
--------------------------------------------------------------------------------
/scripts/target_add:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # sunboot target_add
4 | #
5 | # This script adds a new target to the system, prompting for
6 | # the critical variables if they are not specified on the command
7 | # line.
8 |
9 | if [[ $EUID -ne 0 ]]; then
10 | echo "This script must be run as root"
11 | exit 1
12 | fi
13 |
14 | echo "Not yet implemented!"
15 | exit 1
16 |
--------------------------------------------------------------------------------
/scripts/target_rm:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # sunboot target_rm
4 | #
5 | # This script removes all traces of a given target from sunboot,
6 | # including its root filesystem, swap file, NFS exports, bootparams
7 | # entries, hostfile entries and ethers entries.
8 | # This does not delete the actual 'target' file, just the resulting install.
9 | #
10 | # Usage: target_rm [-f] target_name
11 | #
12 | # -f performs the operation without asking for confirmation.
13 |
14 | if [[ $EUID -ne 0 ]]; then
15 | echo "This script must be run as root"
16 | exit 1
17 | fi
18 |
19 | . /vagrant/scripts/utils.sh
20 |
21 | FORCE=0
22 |
23 | usage() {
24 | >&2 echo "Usage: $(basename $0) [-f] target_name"
25 | exit 1
26 | }
27 |
28 | if [ $# -eq 2 ] && [ $1 = '-f' ]; then
29 | FORCE=1; TARGET=$2;
30 | elif [ $# -eq 2 ] && [ $2 = '-f' ]; then
31 | FORCE=1; TARGET=$1;
32 | elif [ $# -eq 1 ] && [ $1 != '-f' ]; then
33 | TARGET=$1
34 | else
35 | usage
36 | fi
37 |
38 | if [ ! -f /vagrant/targets/$TARGET ]; then
39 | >&2 echo "No target \"$TARGET\" specified in targets directory."
40 | exit 1
41 | fi
42 |
43 | if [ $FORCE -eq 0 ]; then
44 | while true; do
45 | read -p "Really delete all settings and data associated with target \"$TARGET\"? yes/[no]: " yn
46 | case $yn in
47 | [yY]*) break;;
48 | *) exit;;
49 | esac
50 | done
51 | fi
52 |
53 | . /vagrant/targets/$TARGET
54 |
55 | if [ -z $TARGETNAME ]; then
56 | >&2 echo "TARGETNAME is blank, exiting"
57 | exit 1
58 | fi
59 |
60 | sed -i "/$TARGETADDR $TARGETNAME\$/d" /etc/hosts >/dev/null 2>&1
61 | sed -i "/^$TARGETNAME /d" /etc/bootparams >/dev/null 2>&1
62 | sed -i "/$(normal_ether $TARGETETHER) $TARGETNAME\$/d" /etc/ethers >/dev/null 2>&1
63 | sed -i "/ $TARGETADDR(/d" /etc/exports >/dev/null 2>&1
64 | sed -i "/^$TARGETNAME /d" /root/.rhosts >/dev/null 2>&1
65 |
66 | IPHEX=$(iphex $TARGETADDR)
67 |
68 | rm -f /srv/tftp/$IPHEX*
69 | rm -f /export/swap/$TARGETNAME
70 | rm -rf /export/root/$TARGETNAME
71 |
72 | echo "Target \"$TARGET\" removed."
--------------------------------------------------------------------------------
/scripts/utils.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | pushd () {
4 | command pushd "$@" > /dev/null
5 | }
6 | popd () {
7 | command popd "$@" > /dev/null
8 | }
9 | error_exit() {
10 | echo $@
11 | exit 1
12 | }
13 | normal_ether() {
14 | local e1 e2 e3 e4 e5 e6
15 | IFS=: read -r e1 e2 e3 e4 e5 e6 <<< $1
16 | printf "%02X:%02X:%02X:%02X:%02X:%02X" 0x$e1 0x$e2 0x$e3 0x$e4 0x$e5 0x$e6
17 | }
18 | iphex() {
19 | local i1 i2 i3 i4
20 | IFS=. read -r i1 i2 i3 i4 <<< $1
21 | printf "%02X%02X%02X%02X" $i1 $i2 $i3 $i4
22 | }
--------------------------------------------------------------------------------
/scripts/xdrtoc.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 |
3 | # xdrtoc.py
4 | #
5 | # Read Sun XDRTOC files to determine contents/layout of tape and CD-ROM install media
6 | # These are a binary-packed data format so we are using Python struct() to read it.
7 |
8 | import struct
9 |
10 | # header/magic: 0x674D2309
11 |
--------------------------------------------------------------------------------
/shims/arch:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | . /vagrant/sunboot-settings
4 |
5 | echo $TARGETARCH
6 |
--------------------------------------------------------------------------------
/shims/dd:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # sunboot 'dd' - shim to read distribution files
4 | # depending on the if= path, either use the current linked tapefile
5 | # or read the actual file from a mounted CD-ROM
6 |
7 | echo "dd $@" >> /vagrant/cmd_history.txt
8 |
9 | BLOCKSIZE=512
10 |
11 | for p in $@
12 | do
13 | IFS='=' read -r cmd param <<< $p
14 | case $cmd in
15 | bs)
16 | BLOCKSIZE=$param
17 | ;;
18 | if)
19 | INPUTFILE=$param
20 | ;;
21 | esac
22 | done
23 |
24 | case $INPUTFILE in
25 | /dev*)
26 | /bin/dd bs=$BLOCKSIZE if="/root/tapefile"
27 | # increment the tape file
28 | ;;
29 | /usr/etc/install*)
30 | /bin/dd bs=$BLOCKSIZE if=$INPUTFILE
31 | ;;
32 | esac
33 |
34 |
35 |
--------------------------------------------------------------------------------
/shims/mount:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # CD-ROM media should already be mounted to /usr/etc/install/tar
4 | echo "mount $@" >> /vagrant/cmd_history.txt
5 |
--------------------------------------------------------------------------------
/shims/mt:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # sunboot 'mt' - emulate tape control commands (rewind/fastforward)
4 | #
5 | # mt [-f ] [command [parameter]]
6 | #
7 | # The -f parameter is accepted but is ignored.
8 | #
9 | # Commands implemented:
10 | # fsf
11 | # rew
12 | #
13 |
14 | echo "mt $@" >> /vagrant/cmd_history.txt
15 |
16 | while getopts "f:" opt; do
17 | case opt in
18 | f)
19 | echo "Option -f specified, value: $OPTARG"
20 | ;;
21 | \?)
22 | echo "Invalid option: -$OPTARG" >&2
23 | exit 1
24 | ;;
25 | :)
26 | echo "Option -$OPTARG requires a value." >&2
27 | exit 1
28 | ;;
29 | esac
30 | done
31 |
32 | shift $((OPTIND-1))
33 |
34 | case $1 in
35 | fsf)
36 | FILENUM=$2
37 | echo "Fast forward to file number $FILENUM"
38 | # link correct tape file to /root/tapefile
39 | ;;
40 | rew)
41 | echo "Rewind tape"
42 | # link first tape file to /root/tapefile
43 | ;;
44 | esac
45 |
--------------------------------------------------------------------------------
/sunboot-settings:
--------------------------------------------------------------------------------
1 | # General environment settings
2 |
3 | SERVERNAME=sunboot
4 | SERVERADDR=10.94.42.7
5 | NETMASK=255.255.255.0
6 | GATEWAY=10.94.42.1
7 |
--------------------------------------------------------------------------------
/sunos/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/halfmanhalftaco/sunboot/154926eb37291e9eb7853a042ec70dc50918ba78/sunos/.gitkeep
--------------------------------------------------------------------------------
/targets-disabled/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/halfmanhalftaco/sunboot/154926eb37291e9eb7853a042ec70dc50918ba78/targets-disabled/.gitkeep
--------------------------------------------------------------------------------
/targets-disabled/ssx:
--------------------------------------------------------------------------------
1 | # SPARCclassic Solaris 2.3 Diskful Install Example
2 |
3 | TARGETARCH=sun4m
4 | TARGETNAME=ssx
5 | TARGETETHER=8:0:20:5:61:c2
6 | TARGETADDR=10.94.42.209
7 | TARGETSWAPSIZE=64
8 |
9 | # options: DISKLESS or DISKFUL
10 | INSTALLMETHOD=DISKFUL
11 |
12 | # options: CDROM or TAPE
13 | INSTALLMEDIA=CDROM
14 |
15 | # path (within 'sunos' directory) to the install CD-ROM or directory that contains 'tape1', 'tape2', etc. dirs
16 | INSTALLMEDIAPATH=solaris_2.3_sparc.iso
17 |
--------------------------------------------------------------------------------
/targets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/halfmanhalftaco/sunboot/154926eb37291e9eb7853a042ec70dc50918ba78/targets/.gitkeep
--------------------------------------------------------------------------------
/targets/hobbes:
--------------------------------------------------------------------------------
1 | # SPARCstation IPC SunOS 4.1.4 Diskless Install Example
2 |
3 | TARGETARCH=sun4c
4 | TARGETNAME=hobbes
5 | TARGETETHER=8:0:20:a:7d:8f
6 | TARGETADDR=10.94.42.208
7 | TARGETSWAPSIZE=64
8 |
9 | # options: DISKLESS or DISKFUL
10 | INSTALLMETHOD=DISKLESS
11 |
12 | # options: CDROM or TAPE
13 | INSTALLMEDIA=CDROM
14 |
15 | # path (within 'sunos' directory) to the install CD-ROM or directory that contains 'tape1', 'tape2', etc. dirs
16 | INSTALLMEDIAPATH=solaris1.1.2.iso
17 |
--------------------------------------------------------------------------------