shithub: riscv

Download patch

ref: 17291d91bb3063fe8ba0bb5b73c329d317fa7108
parent: 05f721e9987791aae8e07dd4435f04df6ce33c77
author: 23hiro <[email protected]>
date: Sat Jan 6 21:44:53 EST 2018

rconnect: support -t timeout for aan like in drawterm; also rcpu, rexport/import

--- a/rc/bin/rconnect
+++ b/rc/bin/rconnect
@@ -2,8 +2,9 @@
 rfork e
 
 argv0=$0
+aanto=86400 #one day
 fn usage {
-	echo 'usage:' $argv0 '[-u user] [-k keypattern] [-p] host remotescript localcommand arg ...' >[1=2]
+	echo 'usage:' $argv0 '[-u user] [-k keypattern] [-p] [-t timeout] host remotescript localcommand arg ...' >[1=2]
 	exit 'usage'
 }
 
@@ -24,6 +25,7 @@
 		switch($1){
 		case -k; keyspec=($keyspec $2)
 		case -u; keyspec=($keyspec `{user=$2 pvar user})
+		case -t; aanto=$2
 		case *; usage
 		}
 		shift
@@ -53,7 +55,7 @@
 				echo -n 'announce *!0' >[1=3]
 				echo `{cat $netdir/local} || exit
 				bind '#|' /mnt/aan || exit
-				exec aan $netdir <>/mnt/aan/data1 >[1=0] >[2]/dev/null &
+				exec aan -m $aanto $netdir <>/mnt/aan/data1 >[1=0] >[2]/dev/null &
 			}
 		}
 		<>/mnt/aan/data >[1=0] >[2]/dev/null {
@@ -60,7 +62,7 @@
 			rfork n
 			fn server {
 				echo -n aanserver $netdir >/proc/$pid/args
-				rm -f /env/^('fn#server' 'fn#aanserver')
+				rm -f /env/^('fn#server' 'fn#aanserver' 'aanto')
 				. <{n=`{read} && ! ~ $#n 0 && read -c $n} >[2=1]
 			}
 			exec tlssrv -A /bin/rc -c server
@@ -69,9 +71,9 @@
 	}
 	fn aanclient {
 		host=`{echo $host | sed 's/(.*)!([^!]+)$/\1/'}^!^`{read | sed 's/(.*)!([^!]+)$/\2/'} || exit
-		tlsclient -a -o <>{rfork s; aan -c $host >[1=0]} /bin/rc -c 'sendscript $*' $*
+		tlsclient -a -o <>{rfork s; aan -m $aanto -c $host >[1=0]} /bin/rc -c 'sendscript $*' $*
 	}
-	exec $argv0 -k $"keyspec $host <{builtin whatis aanserver; echo aanserver} aanclient $*
+	exec $argv0 -k $"keyspec $host <{builtin whatis aanserver; pvar aanto; echo aanserver} aanclient $*
 	exit
 }
 
--- a/rc/bin/rcpu
+++ b/rc/bin/rcpu
@@ -3,7 +3,7 @@
 
 argv0=$0
 fn usage {
-	echo 'usage:' $argv0 '[-u user] [-k keypattern] [-P patternfile] [-p] [-h host] [-c cmd arg ...]' >[1=2]
+	echo 'usage:' $argv0 '[-u user] [-k keypattern] [-P patternfile] [-p] [-t timeout] [-h host] [-c cmd arg ...]' >[1=2]
 	exit 'usage'
 }
 
@@ -63,7 +63,7 @@
 		~ $#* 1 && usage
 		switch($1){
 		case -P; exportfs=($exportfs $1 $2)
-		case -[uk]; connect=($connect $1 $2)
+		case -[ukt]; connect=($connect $1 $2)
 		case -h; host=$2
 		case -c; cmd=$*(2-); *=()
 		case *; usage
--- a/rc/bin/rexport
+++ b/rc/bin/rexport
@@ -3,7 +3,7 @@
 
 argv0=$0
 fn usage {
-	echo 'usage:' $argv0 '[-abcCnq] [-s remotename] [-m remotemtpt] [-u user] [-k keypattern] [-P patternfile] [-p] tree host [remotecmd [args ...]]' >[1=2]
+	echo 'usage:' $argv0 '[-abcCnq] [-s remotename] [-m remotemtpt] [-u user] [-k keypattern] [-P patternfile] [-p] [-t timeout] tree host [remotecmd [args ...]]' >[1=2]
 	exit 'usage'
 }
 
@@ -30,7 +30,7 @@
 		~ $#* 1 && usage
 		switch($1){
 		case -P; exportfs=($exportfs $1 $2)
-		case -[uk]; connect=($connect $1 $2)
+		case -[ukt]; connect=($connect $1 $2)
 		case -s; sname=`{basename $2}
 		case -m; mtpt=$2
 		case *; usage
--- a/rc/bin/rimport
+++ b/rc/bin/rimport
@@ -3,7 +3,7 @@
 
 argv0=$0
 fn usage {
-	echo 'usage:' $argv0 '[-abcCnq] [-s name] [-u user] [-k keypattern] [-p] host tree [mountpoint]' >[1=2]
+	echo 'usage:' $argv0 '[-abcCnq] [-s name] [-u user] [-k keypattern] [-p] [-t timeout] host tree [mountpoint]' >[1=2]
 	exit 'usage'
 }
 
@@ -29,7 +29,7 @@
 	case *
 		~ $#* 1 && usage
 		switch($1){
-		case -[uk]; connect=($connect $1 $2)
+		case -[ukt]; connect=($connect $1 $2)
 		case -s; sname=`{basename $2}
 		case *; usage
 		}