m 2 elchos: update irc-token
This commit is contained in:
parent
e177454d68
commit
4560e94c10
|
@ -3,19 +3,20 @@ with import <stockholm/lib>;
|
||||||
let
|
let
|
||||||
secret = (import <secrets/elchos-token.nix>);
|
secret = (import <secrets/elchos-token.nix>);
|
||||||
in {
|
in {
|
||||||
systemd.services.elchos-irctoken = {
|
systemd.services.elchos-irctoken2 = {
|
||||||
startAt = "*:0/30";
|
startAt = "*:0/5";
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
RuntimeMaxSec = "20";
|
RuntimeMaxSec = "20";
|
||||||
};
|
};
|
||||||
script = ''
|
script = ''
|
||||||
set -euf
|
set -euf
|
||||||
now=$(date -u +%Y-%m-%dT%H:%M)
|
now=$(date -u +%Y-%m-%dT%H:%M)
|
||||||
sec=$(echo -n "${secret}$now" | md5sum | cut -d\ -f1)
|
sleep 5
|
||||||
message="The secret valid for 30 minutes is $sec"
|
sec=$(cat /tmp/irc-secret)
|
||||||
echo "token for $now (UTC) is $sec"
|
message="The current secret is $sec"
|
||||||
|
echo "$message"
|
||||||
LOGNAME=sec-announcer
|
LOGNAME=sec-announcer
|
||||||
HOSTNAME=$(${pkgs.systemd}/bin/hostnamectl --static)
|
HOSTNAME=$(${pkgs.systemd}/bin/hostnamectl --transient)
|
||||||
IRC_SERVER=irc.freenode.net
|
IRC_SERVER=irc.freenode.net
|
||||||
IRC_PORT=6667
|
IRC_PORT=6667
|
||||||
IRC_NICK=$HOSTNAME-$$
|
IRC_NICK=$HOSTNAME-$$
|
||||||
|
@ -59,4 +60,18 @@ in {
|
||||||
| ${pkgs.netcat}/bin/netcat "$IRC_SERVER" "$IRC_PORT" |tee -a ircin
|
| ${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"
|
||||||
|
'';
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue