2016-02-14 04:18:33 +00:00
|
|
|
#!/bin/rc
|
|
|
|
rfork e
|
|
|
|
|
|
|
|
argv0=$0
|
|
|
|
fn usage {
|
2018-01-07 01:44:53 +00:00
|
|
|
echo 'usage:' $argv0 '[-abcCnq] [-s name] [-u user] [-k keypattern] [-p] [-t timeout] host tree [mountpoint]' >[1=2]
|
2016-02-14 04:18:33 +00:00
|
|
|
exit 'usage'
|
|
|
|
}
|
|
|
|
|
|
|
|
fn domount {
|
|
|
|
if(~ $#sname 1){
|
|
|
|
rm -f /srv/$sname
|
|
|
|
echo -n 0 >/srv/$sname
|
|
|
|
}
|
|
|
|
~ $#mtpt 0 || mount -n $mopt /fd/0 $mtpt
|
|
|
|
}
|
|
|
|
|
|
|
|
tree=()
|
|
|
|
mopt=()
|
|
|
|
mtpt=()
|
|
|
|
sname=()
|
|
|
|
exportfs=/bin/exportfs
|
|
|
|
connect=/bin/rconnect
|
|
|
|
|
|
|
|
while(~ $1 -*){
|
|
|
|
switch($1){
|
|
|
|
case -p; connect=($connect $1)
|
|
|
|
case -[abcCnq]*; mopt=($mopt $1)
|
|
|
|
case *
|
|
|
|
~ $#* 1 && usage
|
|
|
|
switch($1){
|
2018-01-07 01:44:53 +00:00
|
|
|
case -[ukt]; connect=($connect $1 $2)
|
2016-02-14 04:18:33 +00:00
|
|
|
case -s; sname=`{basename $2}
|
|
|
|
case *; usage
|
|
|
|
}
|
|
|
|
shift
|
|
|
|
}
|
|
|
|
shift
|
|
|
|
}
|
|
|
|
switch($#*){
|
|
|
|
case 2 3; tree=$2; mtpt=$$#*
|
|
|
|
case *; usage
|
|
|
|
}
|
|
|
|
|
|
|
|
fn pvar {
|
|
|
|
while(! ~ $#* 0){
|
2018-11-13 10:03:37 +00:00
|
|
|
~ $#$1 0 && echo $1'=()' ||
|
|
|
|
path=/dev/null builtin whatis $1
|
2016-02-14 04:18:33 +00:00
|
|
|
shift
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
exec $connect $1 <{pvar tree; echo exec $exportfs -r '$tree'} domount
|