blob: 381d39a3d919cbdcc87c958a837a2c0b26641923 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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 "[32m"
cat >$outdir/$host <<EOF
$(ssh ${pubarg} "services@$host" -p "$port" -o PasswordAuthentication=no
2>/dev/null||: )
EOF
#printf "[0m"
done
|