new env variables for data-accumulator
This commit is contained in:
parent
3dc3a267ab
commit
756e8e8f7e
|
@ -237,8 +237,8 @@
|
||||||
nixpkgs.overlays = [ radio-conf.overlay."aarch64-linux" decode-server.overlay."aarch64-linux" ];
|
nixpkgs.overlays = [ radio-conf.overlay."aarch64-linux" decode-server.overlay."aarch64-linux" ];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
hydraJobs = {
|
hydraJobs = {
|
||||||
data-hoarder."x86_64-linux" = self.nixosConfigurations.data-hoarder.config.system.build.toplevel;
|
data-hoarder."x86_64-linux" = self.nixosConfigurations.data-hoarder.config.system.build.toplevel;
|
||||||
|
|
|
@ -36,15 +36,15 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
"pg-dvbdump-setup" = {
|
"pg-dvbdump-setup" = {
|
||||||
description = "prepare dvbdump postgres database";
|
description = "prepare dvbdump postgres database";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
after = [ "networking.target" "postgresql.service" ];
|
after = [ "networking.target" "postgresql.service" ];
|
||||||
serviceConfig.Type = "oneshot";
|
serviceConfig.Type = "oneshot";
|
||||||
|
|
||||||
path = [ pkgs.sudo config.services.postgresql.package ];
|
path = [ pkgs.sudo config.services.postgresql.package ];
|
||||||
script = ''
|
script = ''
|
||||||
sudo -u ${config.services.postgresql.superUser} psql -c "ALTER ROLE dvbdump WITH PASSWORD '$(cat ${config.sops.secrets.postgres_password.path})'"
|
sudo -u ${config.services.postgresql.superUser} psql -c "ALTER ROLE dvbdump WITH PASSWORD '$(cat ${config.sops.secrets.postgres_password.path})'"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,12 +12,15 @@
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|
||||||
script = ''
|
script = ''
|
||||||
|
export POSTGRES_PASSWORD=$(cat ${config.sops.secrets.postgres_password.path})
|
||||||
exec ${pkgs.data-accumulator}/bin/data-accumulator --host 0.0.0.0 --port 8080&
|
exec ${pkgs.data-accumulator}/bin/data-accumulator --host 0.0.0.0 --port 8080&
|
||||||
'';
|
'';
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
"INFLUX_HOST" = "http://localhost:8086";
|
"INFLUX_HOST" = "http://localhost:8086";
|
||||||
"GRPC_HOST" = "http://127.0.0.1:50051";
|
"GRPC_HOST" = "http://127.0.0.1:50051";
|
||||||
|
"POSTGRES_HOST" = "127.0.0.1";
|
||||||
|
"POSTGRES_PORT" = "5432";
|
||||||
};
|
};
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "forking";
|
Type = "forking";
|
||||||
|
|
|
@ -26,13 +26,13 @@
|
||||||
systemd.services.dump-csv = {
|
systemd.services.dump-csv = {
|
||||||
path = with pkgs; [ influxdb gzip ];
|
path = with pkgs; [ influxdb gzip ];
|
||||||
script = ''
|
script = ''
|
||||||
cd /tmp
|
cd /tmp
|
||||||
TMPFILE=$(mktemp telegrams.XXXXX.csv.gz)
|
TMPFILE=$(mktemp telegrams.XXXXX.csv.gz)
|
||||||
TIMESTAMP=$(date +"%Y%m%d-%H%M")
|
TIMESTAMP=$(date +"%Y%m%d-%H%M")
|
||||||
influx -precision rfc3339 -database dvbdump -execute "SELECT * FROM telegram_r_09 WHERE time > now()-1h" -format csv | gzip -c > $TMPFILE
|
influx -precision rfc3339 -database dvbdump -execute "SELECT * FROM telegram_r_09 WHERE time > now()-1h" -format csv | gzip -c > $TMPFILE
|
||||||
chmod a+r $TMPFILE
|
chmod a+r $TMPFILE
|
||||||
|
|
||||||
mv $TMPFILE /var/lib/data-accumulator/data/telegrams-''${TIMESTAMP}.csv.gz
|
mv $TMPFILE /var/lib/data-accumulator/data/telegrams-''${TIMESTAMP}.csv.gz
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
systemd.timers.dump-csv = {
|
systemd.timers.dump-csv = {
|
||||||
|
|
|
@ -1,32 +1,32 @@
|
||||||
{ pkgs, config, lib, ... }:
|
{ pkgs, config, lib, ... }:
|
||||||
let
|
let
|
||||||
receiver = pkgs.gnuradio-decoder;
|
receiver = pkgs.gnuradio-decoder;
|
||||||
cfg = config.services.dump-dvb.gnuradio;
|
cfg = config.services.dump-dvb.gnuradio;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.services.dump-dvb.gnuradio = {
|
options.services.dump-dvb.gnuradio = {
|
||||||
enable = lib.mkOption {
|
enable = lib.mkOption {
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = ''Wether to enable dump-dvb gnuradio reciever'';
|
description = ''Wether to enable dump-dvb gnuradio reciever'';
|
||||||
};
|
|
||||||
device = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "";
|
|
||||||
example = "hackrf=0";
|
|
||||||
description = ''Device string to pass to gnuradio'';
|
|
||||||
};
|
|
||||||
frequency = lib.mkOption {
|
|
||||||
type = lib.types.int;
|
|
||||||
default = 170795000;
|
|
||||||
description = ''Frequency to tune radio to'';
|
|
||||||
};
|
|
||||||
offset = lib.mkOption {
|
|
||||||
type = lib.types.int;
|
|
||||||
default = 19550;
|
|
||||||
description = ''Offset of the signal from center frequency'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
device = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "";
|
||||||
|
example = "hackrf=0";
|
||||||
|
description = ''Device string to pass to gnuradio'';
|
||||||
|
};
|
||||||
|
frequency = lib.mkOption {
|
||||||
|
type = lib.types.int;
|
||||||
|
default = 170795000;
|
||||||
|
description = ''Frequency to tune radio to'';
|
||||||
|
};
|
||||||
|
offset = lib.mkOption {
|
||||||
|
type = lib.types.int;
|
||||||
|
default = 19550;
|
||||||
|
description = ''Offset of the signal from center frequency'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
config = lib.mkIf config.services.dump-dvb.gnuradio.enable {
|
config = lib.mkIf config.services.dump-dvb.gnuradio.enable {
|
||||||
|
|
||||||
|
@ -45,20 +45,20 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
users.groups.gnuradio = {};
|
users.groups.gnuradio = { };
|
||||||
users.users.gnuradio = {
|
users.users.gnuradio = {
|
||||||
name = "gnuradio";
|
name = "gnuradio";
|
||||||
description = "gnu radio service user";
|
description = "gnu radio service user";
|
||||||
isSystemUser = true;
|
isSystemUser = true;
|
||||||
group = "gnuradio";
|
group = "gnuradio";
|
||||||
extraGroups = [ "plugdev" ];
|
extraGroups = [ "plugdev" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
security.wrappers.gnuradio-decode = {
|
security.wrappers.gnuradio-decode = {
|
||||||
owner = "gnuradio";
|
owner = "gnuradio";
|
||||||
group = "users";
|
group = "users";
|
||||||
capabilities = "cap_sys_nice+eip";
|
capabilities = "cap_sys_nice+eip";
|
||||||
source = "${receiver}/bin/gnuradio-decoder-cpp";
|
source = "${receiver}/bin/gnuradio-decoder-cpp";
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,62 +2,62 @@
|
||||||
let
|
let
|
||||||
cfg = config.services.dump-dvb.telegram-decoder;
|
cfg = config.services.dump-dvb.telegram-decoder;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.services.dump-dvb.telegram-decoder = {
|
options.services.dump-dvb.telegram-decoder = {
|
||||||
enable = lib.mkOption {
|
enable = lib.mkOption {
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = ''Wether to enable dump-dvb telegram-decoder'';
|
description = ''Wether to enable dump-dvb telegram-decoder'';
|
||||||
};
|
};
|
||||||
server = lib.mkOption {
|
server = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.str;
|
type = lib.types.listOf lib.types.str;
|
||||||
default = [ "https://dump.dvb.solutions/" ];
|
default = [ "https://dump.dvb.solutions/" ];
|
||||||
description = ''URL of the dump-dvb websocket'';
|
description = ''URL of the dump-dvb websocket'';
|
||||||
};
|
};
|
||||||
configFile = lib.mkOption {
|
configFile = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default = "/etc/telegram-decoder/settings.json";
|
default = "/etc/telegram-decoder/settings.json";
|
||||||
description = ''Path to telegram-decoder config'';
|
description = ''Path to telegram-decoder config'';
|
||||||
};
|
};
|
||||||
authTokenFile = lib.mkOption {
|
authTokenFile = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default = "/etc/telegram-decoder/token";
|
default = "/etc/telegram-decoder/token";
|
||||||
description = ''Path to telegram-decoder auth token'';
|
description = ''Path to telegram-decoder auth token'';
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
config = lib.mkIf config.services.dump-dvb.telegram-decoder.enable {
|
||||||
|
|
||||||
|
environment.systemPackages = [ pkgs.telegram-decoder ];
|
||||||
|
|
||||||
|
users.groups.telegram-decoder = { };
|
||||||
|
|
||||||
|
users.users.telegram-decoder = {
|
||||||
|
name = "telegram-decoder";
|
||||||
|
description = "gnu radio service user";
|
||||||
|
group = "telegram-decoder";
|
||||||
|
isSystemUser = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.services."telegram-decoder" = {
|
||||||
|
enable = true;
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|
||||||
config = lib.mkIf config.services.dump-dvb.telegram-decoder.enable {
|
script = "exec ${pkgs.telegram-decoder}/bin/telegram-decode --config ${cfg.configFile} --server ${builtins.concatStringsSep " " cfg.server} &";
|
||||||
|
|
||||||
environment.systemPackages = [ pkgs.telegram-decoder ];
|
environment = {
|
||||||
|
AUTHENTICATION_TOKEN_PATH = cfg.authTokenFile;
|
||||||
users.groups.telegram-decoder = {};
|
|
||||||
|
|
||||||
users.users.telegram-decoder = {
|
|
||||||
name = "telegram-decoder";
|
|
||||||
description = "gnu radio service user";
|
|
||||||
group = "telegram-decoder";
|
|
||||||
isSystemUser = true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services."telegram-decoder" = {
|
serviceConfig = {
|
||||||
enable = true;
|
Type = "forking";
|
||||||
wantedBy = [ "multi-user.target" ];
|
User = "telegram-decoder";
|
||||||
|
Restart = "on-failure";
|
||||||
script = "exec ${pkgs.telegram-decoder}/bin/telegram-decode --config ${cfg.configFile} --server ${builtins.concatStringsSep " " cfg.server} &";
|
StartLimitBurst = "2";
|
||||||
|
StartLimitIntervalSec = "150s";
|
||||||
environment = {
|
|
||||||
AUTHENTICATION_TOKEN_PATH=cfg.authTokenFile;
|
|
||||||
};
|
|
||||||
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "forking";
|
|
||||||
User = "telegram-decoder";
|
|
||||||
Restart = "on-failure";
|
|
||||||
StartLimitBurst = "2";
|
|
||||||
StartLimitIntervalSec = "150s";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
let
|
let
|
||||||
|
|
||||||
file = "/etc/nixos/configs" + "/config_${toString config.dump-dvb.systemNumber}.json"; # make sure that the box has our nix-config checkout, lol
|
file = "/etc/nixos/configs" + "/config_${toString config.dump-dvb.systemNumber}.json"; # make sure that the box has our nix-config checkout, lol
|
||||||
receiver_configs = [
|
receiver_configs = [
|
||||||
{ frequency = 170795000; offset = 19550; device = "hackrf=0"; } # dresden - barkhausen
|
{ frequency = 170795000; offset = 19550; device = "hackrf=0"; } # dresden - barkhausen
|
||||||
{ frequency = 170795000; offset = 19500; device = "hackrf=0"; } # dresden - zentralwerk
|
{ frequency = 170795000; offset = 19500; device = "hackrf=0"; } # dresden - zentralwerk
|
||||||
{ frequency = 153850000; offset = 20000; device = ""; } # chemnitz
|
{ frequency = 153850000; offset = 20000; device = ""; } # chemnitz
|
||||||
{ frequency = 170795000; offset = 19550; device = "hackrf=0"; } # dresden unused
|
{ frequency = 170795000; offset = 19550; device = "hackrf=0"; } # dresden unused
|
||||||
{ frequency = 170795000; offset = 19550; device = "hackrf=0"; } # dresden unused
|
{ frequency = 170795000; offset = 19550; device = "hackrf=0"; } # dresden unused
|
||||||
];
|
];
|
||||||
|
|
||||||
receiver_config = lib.elemAt receiver_configs config.dump-dvb.systemNumber;
|
receiver_config = lib.elemAt receiver_configs config.dump-dvb.systemNumber;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
services.dump-dvb.gnuradio = {
|
services.dump-dvb.gnuradio = {
|
||||||
|
|
|
@ -3,7 +3,8 @@ let
|
||||||
|
|
||||||
installScript = (system:
|
installScript = (system:
|
||||||
let ip = "10.13.37.${toString (system.config.dump-dvb.systemNumber + 100)}";
|
let ip = "10.13.37.${toString (system.config.dump-dvb.systemNumber + 100)}";
|
||||||
in (pkgs.writeScriptBin "deploy" ''
|
in
|
||||||
|
(pkgs.writeScriptBin "deploy" ''
|
||||||
#!${pkgs.runtimeShell}
|
#!${pkgs.runtimeShell}
|
||||||
ssh root@${ip} "ps cax | grep \"nixos-rebuild\" > /dev/null"
|
ssh root@${ip} "ps cax | grep \"nixos-rebuild\" > /dev/null"
|
||||||
if [ $? -eq 0 ]
|
if [ $? -eq 0 ]
|
||||||
|
@ -16,21 +17,25 @@ let
|
||||||
fi
|
fi
|
||||||
''));
|
''));
|
||||||
|
|
||||||
installScripts = pkgs.lib.mapAttrs' (name: system:
|
installScripts = pkgs.lib.mapAttrs'
|
||||||
pkgs.lib.attrsets.nameValuePair ("deploy-" + name) (installScript system))
|
(name: system:
|
||||||
|
pkgs.lib.attrsets.nameValuePair ("deploy-" + name) (installScript system))
|
||||||
systems;
|
systems;
|
||||||
|
|
||||||
deployAllExecutablePathsConcatted =
|
deployAllExecutablePathsConcatted =
|
||||||
pkgs.lib.strings.concatMapStringsSep " " (path: "${path}/bin/deploy")
|
pkgs.lib.strings.concatMapStringsSep " " (path: "${path}/bin/deploy")
|
||||||
(builtins.attrValues installScripts);
|
(builtins.attrValues installScripts);
|
||||||
|
|
||||||
deployAllScript = (name:
|
deployAllScript = (name:
|
||||||
pkgs.writeScriptBin name (''
|
pkgs.writeScriptBin name (
|
||||||
#!${pkgs.runtimeShell} -ex
|
''
|
||||||
${pkgs.parallel}/bin/parallel --will-cite -j10 ::: ${deployAllExecutablePathsConcatted} || echo "Some deployment failed"
|
#!${pkgs.runtimeShell} -ex
|
||||||
''));
|
${pkgs.parallel}/bin/parallel --will-cite -j10 ::: ${deployAllExecutablePathsConcatted} || echo "Some deployment failed"
|
||||||
|
''
|
||||||
|
));
|
||||||
|
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
deploy-all = deployAllScript "deploy-all";
|
deploy-all = deployAllScript "deploy-all";
|
||||||
nuke-all = deployAllScript "nuke-all";
|
nuke-all = deployAllScript "nuke-all";
|
||||||
} // installScripts
|
} // installScripts
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
services.dump-dvb.gnuradio = {
|
services.dump-dvb.gnuradio = {
|
||||||
enable = true;
|
enable = true;
|
||||||
# frequency = 105200000;
|
# frequency = 105200000;
|
||||||
# offset = 1100;
|
# offset = 1100;
|
||||||
# device = "";
|
# device = "";
|
||||||
};
|
};
|
||||||
services.dump-dvb.telegram-decoder = {
|
services.dump-dvb.telegram-decoder = {
|
||||||
enable = true;
|
enable = true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue