timer fix?

This commit is contained in:
Lennart J. Kurzweg (Nx2)
2024-06-25 15:11:07 +02:00
parent 2513906a22
commit 6914a99658
2 changed files with 60 additions and 33 deletions

View File

@@ -57,17 +57,15 @@ in
extraModprobeConfig = ''options v4l2loopback devices=1 video_nr=1 card_label="OBS Cam" exclusive_caps=1''; extraModprobeConfig = ''options v4l2loopback devices=1 video_nr=1 card_label="OBS Cam" exclusive_caps=1'';
}; };
} else { # NxACE } else { # NxACE
kernelPackages = pkgs.linuxPackages_latest; boot = {
extraModulePackages = with config.boot.kernelPackages; [ v4l2loopback ]; loader = {
boot.loader.grub = { efi.canTouchEfiVariables = true;
enable = true; grub = {
configurationLimit = 30; enable = true;
device = "nodev"; device = "nodev";
# useOSProber = true; efiSupport = true;
efiSupport = true; };
fontSize = 50; };
efi.canTouchEfiVariables = true;
splashImage = null;
}; };
}; };
} }

View File

@@ -1,27 +1,56 @@
{ config, pkgs, lib, user, host, ... }: { pkgs, lib, user, host, ... }:
lib.mkIf (host == "NxACE")
{ {
imports = if host == "NxACE" then [ systemd = {
timers."namecheap-dynamic-dns" = {
] else []; wantedBy = [ "timers.target" ];
timerConfig = {
config = lib.mkIf (host == "NxACE") { OnBootSec = "2m";
systemd = { OnUnitActiveSec = "10m";
timers."namecheap-dynamic-dns" = { Unit = "namecheap-dynamic-dns.service";
wantedBy = [ "timers.target" ];
timerConfig = {
OnBootSec = "2m";
OnUnitActiveSec = "10m";
Unit = "namecheap-dynamic-dns.service";
};
}; };
services."namecheap-dynamic-dns" = { };
script = '' services."namecheap-dynamic-dns" =
/home/nx2/nx2site/domain/update-namecheap.sh let
''; u = pkgs.writeScriptBin "update_namecheap" ''
serviceConfig = { my_ip=$(curl -s https://ipinfo.io/ip)
Type = "oneshot"; dns_ip=$(nslookup nx2.site | grep -E "Address: [0-9]" | cut -c 10-)
User = "nx2"; fdc="/home/nx2/nx2site/domain/count.txt"
};
force_update=false
while getopts "f" opt; do
case $opt in
f)
force_update=true
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done
if [ "$force_update" == true ] || [ "$my_ip" != "$dns_ip" ]; then
count=$(<$fdc)
echo [ $count times ] $(date) from $dns_ip to $my_ip >> /home/nx2/nx2site/domain/updates.log
pw=$(cat /home/nx2/nx2site/domain/pw.txt)
# cat /home/nx2/nx2site/domain/subdomain.list | parallel -j2 "curl -s 'https://dynamicdns.park-your-domain.com/update?host={}&domain=nx2.site&password=$pw&ip=$my_ip'"
curl -s "https://dynamicdns.park-your-domain.com/update?host=@&domain=nx2.site&password=$pw&ip=$my_ip"
curl -s "https://dynamicdns.park-your-domain.com/update?host=*&domain=nx2.site&password=$pw&ip=$my_ip"
echo curl -s "https://dynamicdns.park-your-domain.com/update?host=*&domain=nx2.site&password=$pw&ip=$my_ip"
echo 0 > $fdc
fi
'';
in
{
script = ''
set -eu
${u}/bin/update_namecheap
'';
serviceConfig = {
Type = "oneshot";
User = "nx2";
}; };
}; };
}; };