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'';
};
} else { # NxACE
kernelPackages = pkgs.linuxPackages_latest;
extraModulePackages = with config.boot.kernelPackages; [ v4l2loopback ];
boot.loader.grub = {
enable = true;
configurationLimit = 30;
device = "nodev";
# useOSProber = true;
efiSupport = true;
fontSize = 50;
boot = {
loader = {
efi.canTouchEfiVariables = true;
splashImage = null;
grub = {
enable = true;
device = "nodev";
efiSupport = true;
};
};
};
};
}

View File

@@ -1,10 +1,6 @@
{ config, pkgs, lib, user, host, ... }:
{ pkgs, lib, user, host, ... }:
lib.mkIf (host == "NxACE")
{
imports = if host == "NxACE" then [
] else [];
config = lib.mkIf (host == "NxACE") {
systemd = {
timers."namecheap-dynamic-dns" = {
wantedBy = [ "timers.target" ];
@@ -14,9 +10,43 @@
Unit = "namecheap-dynamic-dns.service";
};
};
services."namecheap-dynamic-dns" = {
services."namecheap-dynamic-dns" =
let
u = pkgs.writeScriptBin "update_namecheap" ''
my_ip=$(curl -s https://ipinfo.io/ip)
dns_ip=$(nslookup nx2.site | grep -E "Address: [0-9]" | cut -c 10-)
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 = ''
/home/nx2/nx2site/domain/update-namecheap.sh
set -eu
${u}/bin/update_namecheap
'';
serviceConfig = {
Type = "oneshot";
@@ -24,5 +54,4 @@
};
};
};
};
}