Commit 7be17267 authored by Robert Ricci's avatar Robert Ricci

Major re-structuring of the newclient code, and merged it with the

writefloppy code. The point of doing this was for headless nodes, like
the new wireless nodes - both scripts have similar needs in terms of
communicating with the user through beep codes.

Added a '-h' option for headless operation, in which we go into an
infinite loop with a beep code on an error.

Added a '-w' option to make it write the node ID picked by boss to
a floppy.

Added a '-t' option, useful for testing.

Grab the node's CPU speed directly, instead of using cpuspeed.awk -
we don't want to have to keep updating that in the newnode MFS.

At some point, I will probably add the ability to do DHCP to this
script, since that's another thing that could fail that we'd like to
have a beep code for headless nodes.
parent d9543015
This diff is collapsed.
#!/usr/bin/perl -w
# Copyright (c) 2004 University of Utah and the Flux Group.
# All rights reserved.
# Write out a floppy with a unique identifier - for use with the CD-boot
# system and newclient
# Beep codes - beeps every few seonds
# One beep - All's clear, pop the floppy out
# Two beeps - Unrecoverable error
# Three beeps - No floppy in the drive - stick one in, and the script will
# continue
use strict;
my $FLOPPYDEV = "/dev/fd0";
my $FORMAT = "/sbin/newfs_msdos";
my $MOUNTPOINT = "/mnt";
my $MOUNT = "/sbin/mount";
my $UNMOUNT = "/sbin/umount";
# Grab the node's identifier
if (@ARGV != 1) {
die "Usage: $0 <id>";
my ($id) = @ARGV;
# Make sure the floppy is readable
if (!checkfloppy()) {
# Format that sucker
if (system "$FORMAT $FLOPPYDEV") {
print "Floppy format failed: $!\n";
# Drop a file down with the unique identifier we were provided
if (system "$MOUNT -t msdos $FLOPPYDEV $MOUNTPOINT") {
print "Failed to mount floppy: $!\n";
if (!open(IDFILE,">$MOUNTPOINT/")) {
print "Failed to write floppy: $!\n";
print IDFILE "$id\n";
# Let the user know we're done
# Beep for a while - first argument is the number of beeps in each group. If
# the second argument is non-zero, will stop beeping and return when the floppy
# is inserted or removed
sub beep {
my ($count,$exitOnChange) = @_;
$count = 1 unless $count;
my $floppystate;
if ($exitOnChange) {
$floppystate = checkfloppy();
while (1) {
foreach my $i (1 .. $count) {
syswrite STDOUT, "\a";
select(undef, undef, undef,.2);
if ($exitOnChange && (checkfloppy() != $floppystate)) {
# Check to see if the floppy is readable - 1 if it is, 0 if not
sub checkfloppy {
open(FLOPPY,"<$FLOPPYDEV") or return 0;
return 1;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment