ma wbob.r: enable bureautomation

This commit is contained in:
makefu 2017-12-08 14:04:35 +01:00
parent 20eb8ac1e2
commit e99a9ac9f1
No known key found for this signature in database
GPG Key ID: 36F7711F3FC0F225
7 changed files with 105 additions and 29 deletions

View File

@ -18,7 +18,6 @@ in {
<stockholm/makefu/2configs/virtualisation/libvirt.nix>
<stockholm/makefu/2configs/tinc/retiolum.nix>
<stockholm/makefu/2configs/mqtt.nix>
<stockholm/makefu/2configs/deployment/led-fader.nix>
# <stockholm/makefu/2configs/gui/wbob-kiosk.nix>
<stockholm/makefu/2configs/stats/client.nix>
@ -34,7 +33,10 @@ in {
<stockholm/makefu/2configs/share/wbob.nix>
<stockholm/makefu/2configs/stats/telegraf>
<stockholm/makefu/2configs/deployment/led-fader.nix>
<stockholm/makefu/2configs/stats/external/aralast.nix>
<stockholm/makefu/2configs/stats/telegraf/airsensor.nix>
<stockholm/makefu/2configs/deployment/bureautomation>
(let
collectd-port = 25826;
influx-port = 8086;
@ -60,13 +62,7 @@ in {
};
networking.firewall.extraCommands = ''
iptables -A INPUT -i ${logging-interface} -p udp --dport ${toString collectd-port} -j ACCEPT
iptables -A INPUT -i ${logging-interface} -p tcp --dport ${toString influx-port} -j ACCEPT
iptables -A INPUT -i ${logging-interface} -p tcp --dport ${toString grafana-port} -j ACCEPT
ip6tables -A INPUT -i ${logging-interface} -p udp --dport ${toString collectd-port} -j ACCEPT
ip6tables -A INPUT -i ${logging-interface} -p tcp --dport ${toString influx-port} -j ACCEPT
ip6tables -A INPUT -i ${logging-interface} -p tcp --dport ${toString grafana-port} -j ACCEPT
'';
})
@ -138,9 +134,6 @@ in {
# rt2870 with nonfree creates wlp2s0 from wlp0s20u2
# not explicitly setting the interface results in wpa_supplicant to crash
networking.wireless.interfaces = [ "wlp2s0" ];
networking.interfaces.enp0s25.ip4 = [
{ address = primaryIP; prefixLength = 24;}
];
networking.interfaces.virbr1.ip4 = [{
address = "10.8.8.11";
prefixLength = 24;

View File

@ -1,4 +1,4 @@
import <stockholm/makefu/source.nix> {
name="wbob";
musnix = true;
# musnix = true;
}

View File

@ -0,0 +1,41 @@
{ pkgs, lib, ... }:
with lib;
let
port = 3001;
runit = pkgs.writeDash "runit" ''
set -xeuf
PATH=${pkgs.curl}/bin:${pkgs.coreutils}/bin
name=''${1?must provide name as first arg}
state=''${2?must provide state as second arg}
# val=''${3?must provide val as third arg}
# we ignore non-alerting events
test $state = alerting || exit 0
echo $name - $state
curl 'http://bauarbeiterlampe/ay?o=1'
sleep 5
curl 'http://bauarbeiterlampe/ay?o=1'
'';
in {
services.logstash = {
package = pkgs.logstash5;
enable = true;
inputConfig = ''
http {
port => ${toString port}
host => "127.0.0.1"
}
'';
filterConfig = ''
'';
outputConfig = ''
stdout { codec => json }
exec { command => "${runit} '%{ruleName}' '%{state}'" }
'';
extraSettings = ''
path.plugins: [ "${pkgs.logstash-output-exec}" ]
'';
};
}

View File

@ -1,27 +1,25 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, buildPythonPackage, ... }:
with import <stockholm/lib>;
let
mq = "192.168.8.11";
pkg = pkgs.stdenv.mkDerivation {
pkg = pkgs.python3Packages.buildPythonPackage {
name = "ampel-master";
src = pkgs.fetchgit {
url = "http://cgit.euer.krebsco.de/ampel";
rev = "07a6791de368e16cc0864d2676fd255eba522cee";
sha256 = "1jxjapvkfglvgapy7gjbr1nra3ay418nvz70bvypcmv7wc8d4h8q";
rev = "531741b";
sha256 = "110yij53jz074zbswylbzcd8jy7z49r9fg6i3j1gk2y3vl91g81c";
};
buildInputs = [
(pkgs.python35.withPackages (pythonPackages: with pythonPackages; [
propagatedBuildInputs = with pkgs.python3Packages; [
docopt
paho-mqtt
]))
requests
pytz
influxdb
httplib2
google_api_python_client
];
installPhase = ''
install -m755 -D fade.py $out/bin/fade.py
install -m755 -D ampel.py $out/bin/ampel
install -m755 -D times.json $out/share/times.json
'';
};
in {
systemd.services.led-fader = {
@ -34,7 +32,9 @@ in {
serviceConfig = {
# User = "nobody"; # need a user with permissions to run nix-shell
ExecStartPre = pkgs.writeDash "sleep.sh" "sleep 2";
ExecStart = "${pkg}/bin/ampel 4 ${pkg}/share/times.json";
ExecStart = "${pkg}/bin/ampel 4";
Restart = "always";
RestartSec = 10;
PrivateTmp = true;
};
};

View File

@ -0,0 +1,38 @@
{config, ... }:{
networking.firewall.allowedUDPPorts = [ 137 138 ];
networking.firewall.allowedTCPPorts = [ 139 445 ];
users.users.smbguest = {
name = "smbguest";
uid = config.ids.uids.smbguest;
description = "smb guest user";
home = "/home/share";
createHome = true;
};
services.samba = {
enable = true;
enableNmbd = true;
shares = {
incoming = {
path = "/data/incoming";
"read only" = "no";
browseable = "yes";
"guest ok" = "yes";
};
data = {
path = "/data/";
"read only" = "yes";
browseable = "yes";
"guest ok" = "yes";
};
};
extraConfig = ''
guest account = smbguest
map to guest = bad user
# disable printing
load printers = no
printing = bsd
printcap name = /dev/null
disable spoolss = yes
'';
};
}

View File

@ -1,6 +1,10 @@
{ pkgs, ...}:
{
services.udev.extraRules = ''
SUBSYSTEMS=="usb", ATTRS{product}=="iAQ Stick", GROUP="input"
'';
users.users.telegraf.extraGroups = [ "input" ];
services.telegraf.extraConfig.inputs.exec = [
{
commands = [ "${pkgs.airsensor-py}/bin/airsensor-py"];

View File

@ -2,16 +2,16 @@
with pkgs.python3Packages;
buildPythonApplication rec {
name = "airsensor-py-${version}";
version = "2017-04-24";
version = "2017-12-05";
propagatedBuildInputs = [
pyusb
click
];
src = fetchFromGitHub {
owner = "dfederschmidt";
owner = "makefu";
repo = "airsensor-py";
rev = "c476918";
sha256 = "0dc88vqxsgx20asbwfdjmz6yl6bvv65k0krvmmss3gcwxdgh9p2q";
rev = "7ac5f185dc848fca1b556e4c0396dd73f6a93995";
sha256 = "0387b025y8kb0zml7916p70hmzc3y18kqh46b9xv5qayljxymq2w";
};
}