timelapse: change creds
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
./syncthing
|
||||
./syncthing-relay
|
||||
./tailscale
|
||||
./timelapse-r11
|
||||
./vaultwarden
|
||||
./wifibackup
|
||||
];
|
||||
|
||||
@@ -30,31 +30,6 @@ let
|
||||
done
|
||||
'';
|
||||
};
|
||||
timelapseScript = pkgs.writeShellApplication {
|
||||
name = "timelapse-r11";
|
||||
runtimeInputs = with pkgs; [ ffmpeg ];
|
||||
text = ''
|
||||
set -x
|
||||
NOW=$(date +%F_%T)
|
||||
DATE=''${NOW%_*}
|
||||
TIME=''${NOW#*_}
|
||||
mkdir -p /var/lib/timelapse-r11/"''${DATE}"
|
||||
EXITCODE=0
|
||||
ffmpeg -hide_banner -y \
|
||||
-rtsp_transport tcp \
|
||||
-i "rtsp://frigate:''${FRIGATE_RTSP_PASSWORD}@192.168.188.10/cam/realmonitor?channel=2&subtype=0" \
|
||||
-vframes 1 \
|
||||
/var/lib/timelapse-r11/"''${DATE}"/"ptz-''${DATE}_''${TIME}.jpg" || EXITCODE=$?
|
||||
|
||||
ffmpeg -hide_banner -y \
|
||||
-rtsp_transport tcp \
|
||||
-i "rtsp://frigate:''${FRIGATE_RTSP_PASSWORD}@192.168.188.10/cam/realmonitor?channel=1&subtype=0" \
|
||||
-vframes 1 \
|
||||
/var/lib/timelapse-r11/"''${DATE}"/"panorama-''${DATE}_''${TIME}.jpg" || EXITCODE=$?
|
||||
|
||||
exit "$EXITCODE"
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
options.mj.services.frigate = with lib.types; {
|
||||
@@ -64,17 +39,10 @@ in
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
mj.base.unitstatus.units = [
|
||||
"timelapse-r11"
|
||||
"go2rtc"
|
||||
"frigate"
|
||||
];
|
||||
|
||||
systemd.timers.timelapse-r11 = {
|
||||
#timerConfig.OnCalendar = "*-*-* 7..19:00/5 Europe/Vilnius";
|
||||
timerConfig.OnCalendar = "*:0/5";
|
||||
wantedBy = [ "timers.target" ];
|
||||
};
|
||||
|
||||
systemd.services = {
|
||||
go2rtc-prober = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
@@ -84,17 +52,6 @@ in
|
||||
Restart = "always";
|
||||
};
|
||||
};
|
||||
timelapse-r11 = {
|
||||
preStart = "ln -sf $CREDENTIALS_DIRECTORY/secrets.env /run/timelapse-r11/secrets.env";
|
||||
serviceConfig = {
|
||||
ExecStart = lib.getExe timelapseScript;
|
||||
EnvironmentFile = [ "-/run/timelapse-r11/secrets.env" ];
|
||||
LoadCredential = [ "secrets.env:${cfg.secretsEnv}" ];
|
||||
RuntimeDirectory = "timelapse-r11";
|
||||
StateDirectory = "timelapse-r11";
|
||||
DynamicUser = true;
|
||||
};
|
||||
};
|
||||
go2rtc = {
|
||||
preStart = "ln -sf $CREDENTIALS_DIRECTORY/secrets.env /run/go2rtc/secrets.env";
|
||||
serviceConfig = {
|
||||
|
||||
69
modules/services/timelapse-r11/default.nix
Normal file
69
modules/services/timelapse-r11/default.nix
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.mj.services.timelapse-r11;
|
||||
|
||||
timelapseScript = pkgs.writeShellApplication {
|
||||
name = "timelapse-r11";
|
||||
runtimeInputs = with pkgs; [ ffmpeg ];
|
||||
text = ''
|
||||
set -x
|
||||
NOW=$(date +%F_%T)
|
||||
DATE=''${NOW%_*}
|
||||
TIME=''${NOW#*_}
|
||||
mkdir -p /var/lib/timelapse-r11/"''${DATE}"
|
||||
EXITCODE=0
|
||||
ffmpeg -hide_banner -y \
|
||||
-rtsp_transport tcp \
|
||||
-i "rtsp://timelapse:''${TIMELAPSE_RTSP_PASSWORD}@192.168.188.10/cam/realmonitor?channel=2&subtype=0" \
|
||||
-vframes 1 \
|
||||
/var/lib/timelapse-r11/"''${DATE}"/"ptz-''${DATE}_''${TIME}.jpg" || EXITCODE=$?
|
||||
|
||||
ffmpeg -hide_banner -y \
|
||||
-rtsp_transport tcp \
|
||||
-i "rtsp://timelapse:''${TIMELAPSE_RTSP_PASSWORD}@192.168.188.10/cam/realmonitor?channel=1&subtype=0" \
|
||||
-vframes 1 \
|
||||
/var/lib/timelapse-r11/"''${DATE}"/"panorama-''${DATE}_''${TIME}.jpg" || EXITCODE=$?
|
||||
|
||||
exit "$EXITCODE"
|
||||
'';
|
||||
};
|
||||
|
||||
in
|
||||
{
|
||||
options.mj.services.timelapse-r11 = with lib.types; {
|
||||
enable = lib.mkEnableOption "enable timelapse-r11";
|
||||
secretsEnv = lib.mkOption { type = path; };
|
||||
onCalendar = lib.mkOption { type = string; };
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
mj.base.unitstatus.units = [
|
||||
"timelapse-r11"
|
||||
];
|
||||
|
||||
systemd.timers.timelapse-r11 = {
|
||||
timerConfig.OnCalendar = cfg.onCalendar;
|
||||
wantedBy = [ "timers.target" ];
|
||||
};
|
||||
|
||||
systemd.services.timelapse-r11 = {
|
||||
preStart = "ln -sf $CREDENTIALS_DIRECTORY/secrets.env /run/timelapse-r11/secrets.env";
|
||||
serviceConfig = {
|
||||
ExecStart = lib.getExe timelapseScript;
|
||||
EnvironmentFile = [ "-/run/timelapse-r11/secrets.env" ];
|
||||
LoadCredential = [ "secrets.env:${cfg.secretsEnv}" ];
|
||||
RuntimeDirectory = "timelapse-r11";
|
||||
StateDirectory = "timelapse-r11";
|
||||
DynamicUser = true;
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user