20 lines
1.0 KiB
Bash
Executable File
20 lines
1.0 KiB
Bash
Executable File
#!/bin/sh
|
|
#########################################################################################
|
|
# Shellscript : Set Computername
|
|
# Autor : Andreas Vogel, nextenterprise gmbh
|
|
#########################################################################################
|
|
# set -x
|
|
######################### Variablen #####################################################
|
|
apiuser="$4"
|
|
apipass="$5"
|
|
serial=$(ioreg -c IOPlatformExpertDevice -d 2 | awk -F\" '/IOPlatformSerialNumber/{print $(NF-1)}')
|
|
response=$(curl -k -H "accept: application/xml" -u "${apiuser}:${apipass}" https://exasol.jamfcloud.com/JSSResource/computers/serialnumber/${serial}/subset/general)
|
|
assetTag=$(echo $response | /usr/bin/awk -F'<asset_tag>|</asset_tag>' '{print $2}');
|
|
|
|
######################### Setting computername ##########################################
|
|
echo "Setting computer name...$assetTag"
|
|
scutil --set ComputerName "$assetTag"
|
|
scutil --set HostName "$assetTag"
|
|
scutil --set LocalHostName "$assetTag"
|
|
|
|
exit 0 |