summaryrefslogtreecommitdiffstats
path: root/services/bin
diff options
context:
space:
mode:
Diffstat (limited to 'services/bin')
-rwxr-xr-xservices/bin/services40
-rwxr-xr-xservices/bin/update-services-pubkeys3
2 files changed, 43 insertions, 0 deletions
diff --git a/services/bin/services b/services/bin/services
new file mode 100755
index 00000000..31aca200
--- /dev/null
+++ b/services/bin/services
@@ -0,0 +1,40 @@
+#! /bin/sh
+# usage: services [user@]hostname[:port]
+# environment:
+# services_identity_file path to ssh(1) identity_file
+set -euf
+
+user=services
+hostname=${1-localhost}
+port=1337
+
+options="${options+$options }-o ControlMaster=no"
+
+if test -n "${services_identity_file-}"; then
+ options="${options+$options }-i $services_identity_file"
+fi
+
+if echo $hostname | grep -q @; then
+ user=`echo $hostname | cut -d@ -f1`
+ hostname=`echo $hostname | cut -d@ -f2`
+fi
+if echo $hostname | grep -q :; then
+ port=`echo $hostname | cut -d: -f2`
+ hostname=`echo $hostname | cut -d: -f1`
+fi
+
+exec 3>&1
+{
+ set +e
+ ssh $options $user@$hostname -p $port
+ echo "# Exit:$?" >&2
+} 2>&1 1>&3 | {
+ err="`cat`"
+ code=`echo "$err" | sed -n 's/^# Exit:\([0-9]\+\)/\1/p'`
+ echo "$err" | sed '
+ /^Connection to '$hostname' closed/d
+ /^Shared connection to '$hostname' closed/d
+ /^# Exit:/d
+ ' >&2
+ exit $code
+}
diff --git a/services/bin/update-services-pubkeys b/services/bin/update-services-pubkeys
new file mode 100755
index 00000000..9936c402
--- /dev/null
+++ b/services/bin/update-services-pubkeys
@@ -0,0 +1,3 @@
+#!/bin/sh
+KREBS_ROOT="${KREBS_ROOT:-/krebs}"
+ssh $1 -t "cd ${KREBS_ROOT};git pull origin master;sudo -u services make -C $KREBS_ROOT/services ssh_authorized_keys"