Hey everyone! I am working on a workflow for my company's zero-touch setup. I have 4 scripts that I am testing out and it is failing on the last one. Script 1- Create a folder on root of drive called "NAME", chmod 777 to that folder, then- have an input box for the client to put in the asset tag information to upload it to JSS using recon-assettag - Verified working.
Script 2- Query the JSS for the Asset Tag information, and echo it into a text file called /name/asset.txt
Verified working
Script 3- run a sysctl command that echoes out the hardware model, simple if statement that says if the word "MacBook" is present, then echo the name "LM" into a text file called /name/model.txt, if not, then echo "DM" into same file (Company naming convention)
Here's where I am running into problems, maybe I'm looking at this the entirely wrong way. Script 4, I want to create a variable of the contents of both of those text files and use jamf setcomputername -name $V1$V2. Ex: LM1234
Here is my script, to the best of my knowledge it should be working, but should and are, are never the same. I have a feeling it will be something banally simple, but I'm still very wet behind the ears with scripting.
!/bin/bash
This script will pull the contents of 2 files model.txt and asset.txt and combine them into the machine name
Pull in Model information from Script 1
model= $(cat ‘/name/model.txt' )
Pull in asset tag information from Script 2
asset= $(cat ‘/name/assettag.txt' )
Just to prove that the logic works - will remove
echo $model$asset > /name/machinename.txt
Set computer name to modelAsset Normally errors out saying that I need the "-name" flag, which is present
jamf setcomputername -name $model$asset
Thanks for your input fellow Nationers.