summaryrefslogtreecommitdiffstats
path: root/retiolum/bin/announce_pubkey
blob: ce5aed1969e095d8eb6e0b2c38f76c011321bed6 (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
35
#!/bin/sh
set -euf
HOST="${1:-}"

usage (){
cat <<EOF
usage: $0 HOSTNAME

also, you are made of stupid
EOF
exit 23
}

[ "x$HOST" = "x" ] && usage

CHANNEL="#krebsco"
IRCHOST="irc.freenode.net"
PORT=6667
RETIOLUM="/etc/tinc/retiolum"
PUBFILE="$RETIOLUM/hosts/$HOST"

if [ ! -e $PUBFILE ] ;then
    echo "cannot find $PUBFILE - host $HOST wrong?" ; 
    echo
    usage
fi

NICK="${HOST}_$((RANDOM%666))"

(   echo "NICK $NICK";
    echo "USER $NICK $IRCHOST bla : $NICK";
    echo "JOIN $CHANNEL";
    sleep 23;
    sed "s/^\(.*\)/PRIVMSG $CHANNEL : \1/" $PUBFILE;
    sleep 5; ) | telnet $IRCHOST $PORT