9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] A modified version of /rc/bin/C
@ 2003-02-15 23:01 Dan Cross
  0 siblings, 0 replies; only message in thread
From: Dan Cross @ 2003-02-15 23:01 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 1428 bytes --]

A while back, I couldn't figure out why my `C' command couldn't find
the consoles on my console server.  Russ was quick to point out that I
needed to mount /srv/consoles in namespace.$sysname.  However, I didn't
like that because it seemd like something one shouldn't *need* to do.
Instead, I modified C to import '#s' from the console server, and mount
'#s/consoles' directly on the client.  I like this better, since C now
works everywhere, without any sort of dependencies on the namespace
from the server.

Another thing that bothered me about /rc/bin/C was that one needed to
modify it to explicitly set one's console server.  That struck me as
kind of bogus; shouldn't there be a more systematic way to do it?  So
today, I modified /rc/bin/C on my system to get the name of the console
server using ndb/ipquery.  This way, I can set up multiple console
servers all over the network, and tell C where they are by putting
console=foo paits into /lib/ndb/local and friends.  This is much
easier, in my opinion, than putting local policy into a script in
/rc/bin.  It also makes maintenance of C itself easier (not that it
really needs to be maintained all that much; it's a pretty simple
script).  Using ndb/ipquery makes it sensative to what network I'm on,
and allows me to set a default.

Anyway, here's my version; Russ, how would you feel about putting this
into the distribution?

	- Dan C.


[-- Attachment #2: Type: text/plain, Size: 734 bytes --]

#!/bin/rc

rfork n
switch($1){
case -r
	shift
	opt=''
case *
	opt=-r
}

# change to console server
# may want to use a switch on the
# machine name to support multiple
# console servers

server=`{ndb/ipquery sys $1 console | sed 's/console=//'}
if (~ $server '')
	server=$sysname

if(! test -e /mnt/consoles/$1){
	switch($sysname){
	case $server
		mount /srv/consoles /mnt/consoles
	case *
		mntgen
		import $server '#s' /n/$server^srv
		mount /n/$server^srv/consoles /mnt/consoles
	}
}

if(! test -e /mnt/consoles/$1 && test -e /srv/consoles)
	mount /srv/consoles /mnt/consoles

if(! test -e /mnt/consoles/$1){
	echo console not found
	exit 'console not found'
}

con -l $opt /mnt/consoles/$1

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-02-15 23:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-15 23:01 [9fans] A modified version of /rc/bin/C Dan Cross

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).