ruined every thing again
This commit is contained in:
@@ -11,19 +11,69 @@
|
|||||||
}: let
|
}: let
|
||||||
cfg = config.hectic.hardware.hetzner-cloud;
|
cfg = config.hectic.hardware.hetzner-cloud;
|
||||||
in {
|
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 {
|
config = lib.mkIf cfg.enable {
|
||||||
boot.loader.grub.device = "/dev/sda";
|
boot.loader.grub.device = cfg.device;
|
||||||
boot.initrd.availableKernelModules = [
|
boot.initrd.availableKernelModules = [
|
||||||
"ata_piix"
|
"ata_piix"
|
||||||
"uhci_hcd"
|
"uhci_hcd"
|
||||||
"xen_blkfront"
|
"xen_blkfront"
|
||||||
] ++ (if pkgs.system != "aarch64-linux" then [ "vmw_pvscsi" ] else []);
|
] ++ (if pkgs.system != "aarch64-linux" then [ "vmw_pvscsi" ] else []);
|
||||||
boot.initrd.kernelModules = ["nvme"];
|
boot.initrd.kernelModules = ["nvme"];
|
||||||
fileSystems."/" = {
|
|
||||||
device = "/dev/sda1";
|
disko.devices.disk.vda = {
|
||||||
fsType = "ext4";
|
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 = "/";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,10 +61,12 @@ notify() {
|
|||||||
# sid(text)
|
# sid(text)
|
||||||
sid() { printf '%s' "$1" | cksum | awk '{print $1}'; }
|
sid() { printf '%s' "$1" | cksum | awk '{print $1}'; }
|
||||||
|
|
||||||
|
# <stream> | parse_summary
|
||||||
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() {
|
list_failures() {
|
||||||
awk '
|
awk '
|
||||||
BEGIN{FS="\""; u=""; c=""}
|
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 ---
|
# --- main loop ---
|
||||||
|
|
||||||
# NOTE: remove temp response body on any exit
|
# NOTE: remove temp response body on any exit
|
||||||
@@ -110,7 +117,7 @@ while :; do
|
|||||||
fails=$(printf '%s' "$body" | list_failures | sed 's/[ ]$//')
|
fails=$(printf '%s' "$body" | list_failures | sed 's/[ ]$//')
|
||||||
[ -n "$fails" ] && fail_list=" — ${fails}"
|
[ -n "$fails" ] && fail_list=" — ${fails}"
|
||||||
fi
|
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"
|
sfile="${STATE_DIR}/$(sid "$srv").state"
|
||||||
last=""; [ -f "$sfile" ] && last=$(cat "$sfile")
|
last=""; [ -f "$sfile" ] && last=$(cat "$sfile")
|
||||||
|
|||||||
Reference in New Issue
Block a user