shithub: x

Download patch

ref: 020e88c686a75f53c7238f3b8bd3b94319789248
parent: 96faac9c22974980466fa647e6dfcddfafea2919
author: kvik <kvik@a-b.xyz>
date: Wed Aug 28 17:03:15 EDT 2019

x/mnt: enable mounting multiple hosts at once

--- /dev/null
+++ b/mnt
@@ -1,0 +1,32 @@
+#!/bin/rc
+
+rfork e
+
+fn usage {
+	echo usage: x/mnt [[user@]host ...] >[1=2]
+	exit usage
+}
+
+fn mnt {
+	user=(root $user)
+	host=$1
+	if(~ $host *@*){
+		x=`'@'{echo -n $host}
+		user=$x(1)
+		host=$x(2)
+	}
+	for(u in $user){
+		userhost=$u@$host
+		if(! test -e /srv/$userhost)
+			sshfs -M -r / -s $userhost $userhost
+		mount -c /srv/$userhost /x/$userhost
+	}
+}
+
+hosts=$*
+if(~ $#hosts 0)
+	hosts=`{x/path -l}
+if(~ $#hosts 0)
+	usage
+for(h in $hosts)
+	mnt $h