From b2a6274c13a49a5d1e9362850df2cc32b1b7a183 Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Thu, 11 Oct 2018 21:02:32 +0000 Subject: [registration] Set registration state when client is added [configloader] Add functionality to boot the ipxe script or minilinux. Add ipxe script, which boots the minilinux. Add script to grep the hw data with dmidecode --- server/ipxe/grepSystemInfo.sh | 75 +++++++++++++++++++++++++++++++++++++++++++ server/ipxe/minilinux.ipxe | 6 ++++ 2 files changed, 81 insertions(+) create mode 100644 server/ipxe/grepSystemInfo.sh create mode 100644 server/ipxe/minilinux.ipxe (limited to 'server/ipxe') diff --git a/server/ipxe/grepSystemInfo.sh b/server/ipxe/grepSystemInfo.sh new file mode 100644 index 0000000..024fb52 --- /dev/null +++ b/server/ipxe/grepSystemInfo.sh @@ -0,0 +1,75 @@ +#!/bin/bash + +#dmidecode | grep -i UUID + +# MAC +MAC=$(ip addr show | grep -Eo -m 1 'ether\s.*\sbrd') +MAC=${MAC#"ether "} +MAC=${MAC%" brd"} +echo "MAC: $MAC" + +# UUID +UUID=$(dmidecode -q -s system-uuid | grep -v '^#' | head -n 1 | tr '[a-z]' '[A-Z]') +echo "UUID: $UUID" + +# System Information +echo "" +echo "######## System Informations ########" +MANUFACTURER=$(dmidecode -q -s system-manufacturer) +echo "Manufacturer: $MANUFACTURER" + +MODEL=$(dmidecode -q -s system-product-name) +echo "Model: $MODEL" + +SERIAL=$(dmidecode -q -s system-serial-number) +echo "Serial number: $SERIAL" + +VENDOR=$(dmidecode | grep -Eo '(Vendor).*') +VENDOR=${VENDOR#Vendor: } +echo "Vendor: $VENDOR" + +# Mainboard +echo "" +echo "######## Mainboard Informations ########" +MAINBOARD_MANUFACTURER=$(dmidecode -q -s baseboard-manufacturer) +echo "Manufacturer: $MAINBOARD_MANUFACTURER" +MAINBOARD_MODEL=$(dmidecode -q -s baseboard-product-name) +echo "Model: $MAINBOARD_MODEL" +MAINBOARD_SERIAL_NUMBER=$(dmidecode -q -s baseboard-serial-number) +echo "Serial: $MAINBOARD_SERIAL_NUMBER" + +# CPU +echo "" +echo "######## CPU Informations ########" +CPU_MODEL=$(dmidecode -q -s processor-version) +echo "Model: $CPU_MODEL" +CPU_MANUFACTURER=$(dmidecode -q -s processor-manufacturer) +echo "Manufacturer: $CPU_MANUFACTURER" +CPU_TYPE=$(dmidecode -q -s processor-family) +echo "Type: $CPU_TYPE" +CPUCORES=$(cat /sys/devices/system/cpu/cpu*/topology/thread_siblings_list | sort -u | wc -l) +echo "$CPUCORES Cores" +#CPUMODEL=$(grep -m1 '^model name\s*:' /proc/cpuinfo | sed 's/^model name\s*:\s*//;s/\s\s*/ /g;s/^ //;s/ $//') +#echo "$CPUMODEL" +CPU_FREQUENCY=$(dmidecode -q -s processor-frequency) +echo "Frequency: $CPU_FREQUENCY" + +# RAM +echo "" +echo "######## RAM Informations ########" +RAM=$(grep -m1 '^MemTotal:' /proc/meminfo | awk '{print $2}') +RAM=$(( $RAM / 1024 )) +if [ -z "$RAM" ] || [ "$RAM" -lt 500 ]; then + # Fallback to dmidecode + RAM=0 + for c in $(dmidecode -t 17 | grep -o 'Size:.*MB$' | awk '{print $2}'); do + RAM=$(( $RAM + $c )) + done +fi +echo "$RAM MB RAM" + +echo "" +#echo "######## CURL ########" +#curl --data "state=6" --insecure https://bas.stfu-kthx.net:8888/api/registrations/$UUID/state +#echo "" +#echo "" diff --git a/server/ipxe/minilinux.ipxe b/server/ipxe/minilinux.ipxe new file mode 100644 index 0000000..9d05ccc --- /dev/null +++ b/server/ipxe/minilinux.ipxe @@ -0,0 +1,6 @@ +#!ipxe + +kernel tftp://10.8.102.124/kernel/kernel +initrd tftp://10.8.102.124/initramfs-stage31-bss +imgargs kernel ip=${net0/ip}:10.8.102.124:${net0/gateway}:${net0/netmask} BOOTIF=01-${net0/mac} bas=bas.stfu-kthx.net:8888 +boot \ No newline at end of file -- cgit v1.2.3-55-g7522