storage-ng: add streamdump
This commit is contained in:
parent
f23e2ac2d2
commit
0608a20f46
|
@ -1,4 +1,4 @@
|
||||||
{ config, pkgs, lib, strings, ... }:
|
{ hostRegistry, config, pkgs, lib, strings, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
eth0 = "ens18";
|
eth0 = "ens18";
|
||||||
|
@ -7,6 +7,7 @@ in
|
||||||
imports = [
|
imports = [
|
||||||
# Include the results of the hardware scan.
|
# Include the results of the hardware scan.
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
|
./streamdump.nix
|
||||||
# ../../config
|
# ../../config
|
||||||
# ../../config/hq.nix
|
# ../../config/hq.nix
|
||||||
# ../../config/shared.nix
|
# ../../config/shared.nix
|
||||||
|
@ -48,6 +49,11 @@ in
|
||||||
|
|
||||||
defaultGateway.address = "172.22.99.4";
|
defaultGateway.address = "172.22.99.4";
|
||||||
defaultGateway.interface = eth0;
|
defaultGateway.interface = eth0;
|
||||||
|
nameservers = [
|
||||||
|
hostRegistry.hosts.dnscache.ip4
|
||||||
|
hostRegistry.hosts.dnscache.ip6
|
||||||
|
"9.9.9.9"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
|
|
40
hosts/storage-ng/streamdump.nix
Normal file
40
hosts/storage-ng/streamdump.nix
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
let
|
||||||
|
archiveRoot = "/mnt/cephfs/c3d2/Radio";
|
||||||
|
streams = {
|
||||||
|
coloradio = "http://streaming.fueralle.org/coloradio_160.mp3";
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
systemd.services = builtins.foldl' (result: stream:
|
||||||
|
let
|
||||||
|
url = streams.${stream};
|
||||||
|
in result // {
|
||||||
|
"streamdump-${stream}" = {
|
||||||
|
description = "Stream archive for ${stream}";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
path = with pkgs; [
|
||||||
|
wget
|
||||||
|
mp3splt
|
||||||
|
];
|
||||||
|
script = ''
|
||||||
|
DIR=${archiveRoot}/${stream}/$(date +%F)
|
||||||
|
mkdir -p $DIR
|
||||||
|
cd $DIR
|
||||||
|
|
||||||
|
NAME=${stream}-$(date +%T)
|
||||||
|
set +e
|
||||||
|
wget --quiet -O $NAME.mp3 "${url}"
|
||||||
|
set -e
|
||||||
|
mp3splt -s -p th=-44,min=2 -o "@f-@N" $NAME.mp3
|
||||||
|
rm $NAME.mp3
|
||||||
|
'';
|
||||||
|
serviceConfig = {
|
||||||
|
User = "k-ot";
|
||||||
|
Group = config.users.users.k-ot.group;
|
||||||
|
Restart = "always";
|
||||||
|
RestartSec = "5sec";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
) {} (builtins.attrNames streams);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user