shithub: scripts

ref: bc762e9c9294990c0d2480295637c792363dcc8c
dir: /bin/rc/urexport/

View raw version
#!/bin/rc

rfork ne

uhost=$1
srvname=$2
srvrem=$3

if(~ $#uhost 0) {
	echo 'usage: urexport host [srv [srvrem]]'
	exit 'usage'
}

if(! ~ $#srvname 0 && ! test -f /srv/$srvname)
	exit $srvname does not exist
if not
	if(~ $#srvrem 0)
		srvrem=srvname

bind '#|' /mnt/urexport
pipe0=/mnt/urexport/data
pipe1=/mnt/urexport/data1

if(~ $#srvname 0) {
	exportfs -r / <$pipe0 >$pipe0 &
}
if not {
	mount /srv/$srvname /n/$srvrem
	exportfs -r /n/$srvrem <$pipe0 >$pipe0 &
}

if(~ $#srvname 0) {
	ssh $uhost .local/bin/socat \
		unix-listen:srv/term.$apid - >$pipe1 <$pipe1 &
#	can't get this working
#	ssh $uhost .local/bin/9 \
#		9pserve unix!srv/term.$apid >$pipe1 <$pipe1 &
}
if not {
	ssh $uhost .local/bin/socat \
		unix-listen:srv/$srvrem - >$pipe1 <$pipe1 &
}