]> git.lizzy.rs Git - plan9front.git/blob - rc/bin/rexport
inst/bootsetup: fix unformated esp check (thanks yellow_apple)
[plan9front.git] / rc / bin / rexport
1 #!/bin/rc
2 rfork e
3
4 argv0=$0
5 fn usage {
6         echo 'usage:' $argv0 '[-abcCnq] [-s remotename] [-m remotemtpt] [-u user] [-k keypattern] [-P patternfile] [-p] tree host [remotecmd [args ...]]' >[1=2]
7         exit 'usage'
8 }
9
10 fn domount {
11         if(~ $#sname 1){
12                 rm -f /srv/$sname
13                 echo -n 0 >/srv/$sname
14         }
15         ~ $#mtpt 0 || mount -n $mopt /fd/0 $mtpt || exit
16         ~ $#cmd 0 || service=import exec $cmd </dev/null >/dev/null >[2=1]
17 }
18
19 sname=()
20 mopt=()
21 mtpt=()
22 exportfs=/bin/exportfs
23 connect=/bin/rconnect
24
25 while(~ $1 -*){
26         switch($1){
27         case -p; connect=($connect $1)
28         case -[abcCnq]*; mopt=($mopt $1)
29         case *
30                 ~ $#* 1 && usage
31                 switch($1){
32                 case -P; exportfs=($exportfs $1 $2)
33                 case -[uk]; connect=($connect $1 $2)
34                 case -s; sname=`{basename $2}
35                 case -m; mtpt=$2
36                 case *; usage
37                 }
38                 shift
39         }
40         shift
41 }
42 ~ $#* 0 1 && usage
43
44 exportfs=($exportfs -r $1)
45 shift
46 host=$1
47 shift
48 cmd=$*
49
50 fn pvar {
51         while(! ~ $#* 0){
52                 ~ $#$1 0 || path=/dev/null builtin whatis $1
53                 shift
54         }
55 }
56
57 exec $connect $host <{pvar sname mtpt mopt cmd; builtin whatis domount; echo domount} exec $exportfs