shithub: bin.rc

ref: f6706e1759c3e16f6f710ac897b7aa1cb5e22fa4
dir: /bin/mnt/

View raw version
#!/bin/rc

fn usage {
	>[1=2] {
	echo mnt [mount options] [-m mtpt] [-s spec] name cmd [args ...]
	echo mnt [mount options] [-m mtpt] [-s spec] name
	}
	exit usage
}

flags=()
mtpt=()
spec=()
while(~ $1 -* && ! ~ $1 --){
	switch($1){
	case -m
		mtpt=$2
		shift
	case -s
		spec=$2
		shift
	case *
		flags=($flags $1)
	}
	shift
}
if(~ $1 --)
	shift
name=$1
if(~ $#name 0)
	usage
shift
if(~ $#mtpt 0)
	mtpt=/n/$name
cmd=$1
if(! ~ $#cmd 0)
	shift

if(mount $flags /srv/$name $mtpt $spec )
	exit
if(~ $#cmd 0)
	usage
switch($cmd){
case srv srvtls
	$cmd $* $name
case rimport
	rimport $flags -s $name $* $mtpt
	exit
case ramfs
	ramfs -S $name $*
case *
	$cmd -s $name $*
}
mount $flags /srv/$name $mtpt $spec