From e7423780e82614229d299798f1ebc8152df9d789 Mon Sep 17 00:00:00 2001 From: yukkop Date: Tue, 21 Oct 2025 17:27:09 +0000 Subject: [PATCH] ruined every thing again --- .../module/hectic/hardware/hetzner-cloud.nix | 60 +++++++++++++++++-- package/sentinèlla/sentinel.sh | 11 +++- 2 files changed, 64 insertions(+), 7 deletions(-) diff --git a/nixos/module/hectic/hardware/hetzner-cloud.nix b/nixos/module/hectic/hardware/hetzner-cloud.nix index 1802559..cd3e536 100644 --- a/nixos/module/hectic/hardware/hetzner-cloud.nix +++ b/nixos/module/hectic/hardware/hetzner-cloud.nix @@ -11,19 +11,69 @@ }: let cfg = config.hectic.hardware.hetzner-cloud; in { - options.hectic.hardware.hetzner-cloud.enable = lib.mkEnableOption "Enable hetzner-cloud hardware configurations"; + options.hectic.hardware.hetzner-cloud = { + enable = lib.mkEnableOption "Enable hetzner-cloud hardware configurations"; + #bootParUuid = lib.mkOption { + # type = with lib.types; nullOr oneOf [ + # (lib.types.strMatching "^[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}$") + # (lib.types.strMatching "^[0-9a-fA-F-]{36}$") + # ]; + # default = null; + # example = "5628-19B6"; + # description = '' + # boot partition uuid if it is null + # then will use "/dev/sda15" (default hetzner cloud boot device) + # ''; + #}; + device = lib.mkOption { + type = lib.types.str; + default = "/dev/sda/"; + example = "/dev/disk/by-uuid/f184a16b-6eca-41cb-b48a-ff37cdce1d79"; + description = '' + boot device uuid + if it is null then will use "/dev/sda" + /dev/sda - default hetzner cloud device + !! But can changes on reboot if server have volumes + !! So use IDs + ''; + }; + }; config = lib.mkIf cfg.enable { - boot.loader.grub.device = "/dev/sda"; + boot.loader.grub.device = cfg.device; boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "xen_blkfront" ] ++ (if pkgs.system != "aarch64-linux" then [ "vmw_pvscsi" ] else []); boot.initrd.kernelModules = ["nvme"]; - fileSystems."/" = { - device = "/dev/sda1"; - fsType = "ext4"; + + disko.devices.disk.vda = { + device = cfg.device; + type = "disk"; + content = { + type = "gpt"; + partitions = { + ESP = { + size = "512M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "umask=0077" ]; + }; + }; + root = { + size = "100%"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + }; + }; + }; + }; }; }; } diff --git a/package/sentinèlla/sentinel.sh b/package/sentinèlla/sentinel.sh index 9945dd8..0901761 100644 --- a/package/sentinèlla/sentinel.sh +++ b/package/sentinèlla/sentinel.sh @@ -61,10 +61,12 @@ notify() { # sid(text) sid() { printf '%s' "$1" | cksum | awk '{print $1}'; } +# | parse_summary parse_summary() { - sed -n 's/.*"summary":{"total":\([0-9][0-9]*\),"ok":\([0-9][0-9]*\)}.*/\1 \2/p' + jq -r '.status.summary | "\(.total) \(.ok)"' } +# list_failures list_failures() { awk ' BEGIN{FS="\""; u=""; c=""} @@ -74,6 +76,11 @@ list_failures() { ' } +# server_status_message(msg_prefix, server, ok_amount, total_amount, fail_list) +server_status_message() { + msg=$(printf '%s: %s [%s/%s]%s' "${1:?}" "${2:?}" "${3:?}" "${4:?}" "$5") +} + # --- main loop --- # NOTE: remove temp response body on any exit @@ -110,7 +117,7 @@ while :; do fails=$(printf '%s' "$body" | list_failures | sed 's/[ ]$//') [ -n "$fails" ] && fail_list=" — ${fails}" fi - msg=$(printf '%s: %s [%s/%s]%s' "$msg_prefix" "$srv" "$good" "$tot" "$fail_list") + msg=$(server_status_message "$msg_prefix" "$srv" "$good" "$tot" "$fail_list") sfile="${STATE_DIR}/$(sid "$srv").state" last=""; [ -f "$sfile" ] && last=$(cat "$sfile")