shithub: bin.rc

ref: 4e18dc77f2ab9257b363ccb480a69cb9def901ba
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