summaryrefslogtreecommitdiffstats
path: root/makefu/2configs/elchos/irc-token.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2017-01-05 19:13:29 +0100
committertv <tv@krebsco.de>2017-01-05 19:13:29 +0100
commit62372f917e483bffb78d7e8560a667221e2a160d (patch)
tree622b5117a7b70d4998e9e976340647359c21288e /makefu/2configs/elchos/irc-token.nix
parent0d4911ce2f7b44af8e04bfd37f25593aa1c33eda (diff)
parent2e9d5f604c32c9c938a90c3211d5b7726d17f9ee (diff)
Merge remote-tracking branch 'prism/lassulus'
Diffstat (limited to 'makefu/2configs/elchos/irc-token.nix')
-rw-r--r--makefu/2configs/elchos/irc-token.nix27
1 files changed, 21 insertions, 6 deletions
diff --git a/makefu/2configs/elchos/irc-token.nix b/makefu/2configs/elchos/irc-token.nix
index 3f3c4ffc3..a91223b28 100644
--- a/makefu/2configs/elchos/irc-token.nix
+++ b/makefu/2configs/elchos/irc-token.nix
@@ -3,19 +3,20 @@ with import <stockholm/lib>;
let
secret = (import <secrets/elchos-token.nix>);
in {
- systemd.services.elchos-irctoken = {
- startAt = "*:0/30";
+ systemd.services.elchos-irctoken2 = {
+ startAt = "*:0/5";
serviceConfig = {
RuntimeMaxSec = "20";
};
script = ''
set -euf
now=$(date -u +%Y-%m-%dT%H:%M)
- sec=$(echo -n "${secret}$now" | md5sum | cut -d\ -f1)
- message="The secret valid for 30 minutes is $sec"
- echo "token for $now (UTC) is $sec"
+ sleep 5
+ sec=$(cat /tmp/irc-secret)
+ message="The current secret is $sec"
+ echo "$message"
LOGNAME=sec-announcer
- HOSTNAME=$(${pkgs.systemd}/bin/hostnamectl --static)
+ HOSTNAME=$(${pkgs.systemd}/bin/hostnamectl --transient)
IRC_SERVER=irc.freenode.net
IRC_PORT=6667
IRC_NICK=$HOSTNAME-$$
@@ -59,4 +60,18 @@ in {
| ${pkgs.netcat}/bin/netcat "$IRC_SERVER" "$IRC_PORT" |tee -a ircin
'';
};
+ systemd.services.elchos-create-token = {
+ startAt = "*:0/30";
+ serviceConfig = {
+ RuntimeMaxSec = "20";
+ };
+ script = ''
+ set -euf
+ now=$(date -u +%Y-%m-%dT%H:%M)
+ sec=$(echo -n "${secret}$now" | md5sum | cut -d\ -f1)
+ message="The secret valid for 30 minutes is $sec"
+ echo -n "$sec" > /tmp/irc-secret
+ echo "token for $now (UTC) is $sec"
+ '';
+ };
}