#!/Users/yarek/plan9/bin/rc
# Given remote mount path (or cwd), tell the best cpu to run commands on.
#
# To publish: cp $% /n/sources/contrib/yk/lab/unix/
. /Users/yarek/plan9/bin/9.rc
. /Users/yarek/plan9/lib/acme.rc
fn winprefix { winread tag | sed 's! .*!!; s!/[^/]+$!!; 1q' }
if(~ $#* 1)
dir = $1
if not {
if(! ~ $#winid 0 && ! ~ $winid '')
dir = `{winprefix}
if(~ $#dir 0 || ~ $dir '')
dir = `{pwd}
}
if(~ $dir /n/* $HOME/n/*) {
mnt = `{echo $dir | sed 's!^(' ^ $HOME ^ ')?(/n/[^/]*).*!\2!'}
if(remote = `{cat $mnt/etc/hostname >[2]/dev/null}) {
echo $remote
exit
}
# allow unmounted remotes, for scalability
remote = `{basename $mnt}
if(! ~ $remote local remote sources) {
echo $remote
exit
}
}
exit 'unavailable'
|