Plan 9 from Bell Labs’s /usr/web/sources/contrib/mycroftiv/root/rc/bin/hub

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc
# wrapper script for hubfs and hubshell - starts both servers and clients

rfork
while (~ $1 -*){
	switch($1){
	case -b
		background = yes
		echo initial rc will be backgrounded
		shift
	case *
		echo bad flag $1
		shift
	}
}
srvname = $1
attach = $2
if(~ $srvname ''){
	srvname = hubfs
}
if(~ $attach ''){
	attach = io
}

if (test -e /n/$srvname/$attach'0'){
	echo attaching hubshell to $srvname/$attach hubgroup
	hubshell /n/$srvname/$attach
	echo hubshell ended
	exit
}

if (test -e /n/$srvname/io0){
	touch /n/$srvname/$attach'0'
	touch /n/$srvname/$attach'1'
	touch /n/$srvname/$attach'2'
	rfork
	echo created /$srvname/$attach hubgroup and starting initial rc
	oldprompt = $prompt
	prompt =($attach'% ')
	rc -i </n/$srvname/$attach'0' >/n/$srvname/$attach'1' >[2]/n/$srvname/$attach'2' &
	prompt = $oldprompt
	rfork
	if(! ~ $background yes){
		sleep 1
		echo attaching hubshell to $srvname/$attach hubgroup
		hubshell /n/$srvname/$attach
		echo hubshell ended
	}
	exit
}

if (! test -e /srv/$srvname){
	create = yes
	echo creating hubfs /srv/$srvname
	hubfs -s $srvname
}

mount -c /srv/$srvname /n/$srvname
if (! test -e /n/$srvname/$attach'0'){
	if(! test -e /n/$srvname/ctl){
		touch /n/$srvname/ctl
	}
	touch /n/$srvname/$attach'0'
	touch /n/$srvname/$attach'1'
	touch /n/$srvname/$attach'2'
	rfork
	echo created /$srvname/$attach hubgroup and starting initial rc
	oldprompt = $prompt
	prompt =($attach'% ')
	rc -i </n/$srvname/$attach'0' >/n/$srvname/$attach'1' >[2]/n/$srvname/$attach'2' &
	prompt = $oldprompt
	rfork
	sleep 1
}
if(! ~ $background yes){
	echo attaching hubshell to $srvname/$attach hubgroup
	hubshell /n/$srvname/$attach
	echo hubshell ended
}
exit

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.