summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2014-04-02 13:26:59 +0200
committermakefu <github@syntax-fehler.de>2014-04-02 13:26:59 +0200
commitd8b1fec7469468b0096718ec87c6e7369f871787 (patch)
tree63fa4132532c0995874c1efe6bdb9cc181d3c5a3 /services
parent6d78922eddbbb24d812973558355a74d2bd786c7 (diff)
add scripty to migrate old services hosts
Diffstat (limited to 'services')
-rwxr-xr-xservices/bin/obsolete/copy-services34
1 files changed, 34 insertions, 0 deletions
diff --git a/services/bin/obsolete/copy-services b/services/bin/obsolete/copy-services
new file mode 100755
index 00000000..381d39a3
--- /dev/null
+++ b/services/bin/obsolete/copy-services
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+set -euf
+cd $(dirname $(readlink -f $0))
+usage(){
+ cat <<EOF
+usage: $0 [pubkey-file] [bootstrap-file]
+ if pubkey-file is "" it will be skipped.
+
+ e.g.:
+ $0 "" ../path/to/other/bootstrap
+EOF
+
+}
+pubfile=${1:-}
+bootfile=${2:-../etc/services/bootstrap}
+outdir=$PWD/out
+mkdir -p "$outdir"
+for i in `cat $bootfile`; do
+ # retard uriparsing but good enough for our use case
+ netloc=${i##*//}
+ host=${netloc%%:*}
+ port=${netloc##*:}
+ [ "$port" == "$host" ] && port=1337
+
+ pubarg="${pubfile:+-i $pubfile}"
+ #printf ""
+ cat >$outdir/$host <<EOF
+$(ssh ${pubarg} "services@$host" -p "$port" -o PasswordAuthentication=no
+ 2>/dev/null||: )
+EOF
+ #printf ""
+done
+