bin/, Makefile: Add some scripts for doing stuff to remote machines.
[profile] / bin / remote-disorder
diff --git a/bin/remote-disorder b/bin/remote-disorder
new file mode 100755 (executable)
index 0000000..2c8d268
--- /dev/null
@@ -0,0 +1,18 @@
+#! /bin/sh -e
+case $# in 1) ;; *) echo >&2 "usage: $0 HOST"; exit 2 ;; esac
+host=$1; shift
+case $host in
+  *[!-a-zA-Z0-9]*) echo >&2 "$0: bad host name \`$host'"; exit 2 ;;
+esac
+cd "$HOME/.disorder"
+if ! [ -f "passwd.$host" ] ||
+   ! grep -q "^connect -unix /.*/\.disorder/sock/disorder@$host" \
+       "passwd.$host"
+then echo >&2 "$0: unknown disorder host \`$host'"; exit 2; fi
+if [ -S "sock/ssh@$host" ]; then
+  ssh -oControlPath="sock/ssh@$host" -Oexit "$host"
+fi
+rm -f "sock/disorder@$host"
+ssh -oControlMaster=yes -oControlPath="sock/ssh@$host" -fnN \
+    -L"sock/disorder@$host:/var/lib/disorder/socket" \
+    "$host"