summaryrefslogtreecommitdiffstats
path: root/server/ipxe/bash_scripts/addServer.sh
blob: ad6e3aa6fc9e43e271cbe1b613c3cb30501ce79e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash

json_data()
{
  cat << EOF
{
    "client": {
        "parents": [709403],
        "type": "SERVER",
        "uuid": "$(dmidecode -q -s system-uuid | grep -v '^#' | head -n 1 | tr '[a-z]' '[A-Z]')",
        "network": {
            "mac": "$(ip addr show | grep -Eo -m 1 'ether\s.*\sbrd' | awk '{print $2}')",
            "ip": "$(hostname -I | awk '{print $1}')"
        },
        "location": {
            "option": "Horizontal",
            "insertion": "Back",
            "pos": 46
        },
        "formfactor": {
            "formfactor": "19\"",
            "rackunits": 1
        }
    },
    "ipxe": false
}
EOF
}

curl -d "$(json_data)" -H "Content-Type: application/json" -X POST --insecure https://bas.intra.uni-freiburg.de/api/registration
# curl --data "$(json_data)" -H "Content-Type: application/json" -X POST --insecure https://bas.stfu-kthx.net:8888/api/registration