ruined every thing again

This commit is contained in:
2025-10-21 17:27:09 +00:00
parent b3041edbdc
commit e7423780e8
2 changed files with 64 additions and 7 deletions

View File

@@ -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 = "/";
};
};
};
};
};
};
}

View File

@@ -61,10 +61,12 @@ notify() {
# sid(text)
sid() { printf '%s' "$1" | cksum | awk '{print $1}'; }
# <stream> | 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")