summaryrefslogtreecommitdiffstats
path: root/services/bin/show-services
blob: e94eb7c8847dc66713e74ecab7a99d7abbaa665e (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
#!/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}

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
    echo $netloc
    pubarg="${pubfile:+-i $pubfile}"
    printf "" 
    ssh ${pubarg} "services@$host" -p "$port" \
        -o PasswordAuthentication=no 2>/dev/null||:
    printf ""
done