Posted on 06-24-2020 11:15 AM
Hi,
Currently I am running a script that asks the user for the machine name after the first login. On older laptops with Mojave or earlies OS the script gets triggered and runs perfectly, however on the new laptops that come with Catalina it won’t work. This is the script used. I wonder if the issue is caused by any security policies on Catalina or because it's bash and not zsh?
/usr/bin/osascript << EOF property compName : ""
repeat while compName is ""
tell application "Finder"
activate
display dialog "What should this computer be named:" default answer compName
set compName to text returned of result
end tell
end repeat
try
do shell script "hostname " & quoted form of compName
on error errorMsg number errorNum
display alert "Error " & errorNum message errorMsg buttons "Cancel" default button 1
end try
EOF
name=$(hostname)
scutil --set ComputerName "${name}"
scutil --set LocalHostName "${name}"
scutil --set HostName "${name}"
jamf recon
jamf policy -event ADBind
jamf policy -event set-domains
if ! [ -f "/etc/ma.d/EPOAGENT3000/config.xml" ] ; then
jamf policy -event install-mcafee
else
VERSION="Not installed."
fi
Posted on 06-24-2020 08:04 PM
@Viziri, which part of the script isn't working? At what point does it fail?
Have you also considered using the jamf binary's setComputerName feature as well? It should do what you're trying to do with the scutil command.
Posted on 06-26-2020 03:54 AM
it's the very first part of the script that is failing..the prompt to rename the mac doesn’t appear and the other parts of the scripts don’t get triggered in the end. and yes if I run the jamf command then it works. I’m just puzzled why it doesn’t work on Catalina only and wether there’s a way to make the script work or i just should use manual command and rename the mac in the terminal.
Posted on 06-26-2020 06:37 AM
@Viziri, I've seen the same behavior found a solution here on Jamf Nation that resolved it for me.
Here's a link to a script I put together for a customer that works on Catalina. The important piece of it was the different way to call osascript. See line 20. It's important that you run the command now as the currently logged in user. That means you also need to get the current user's name. See line 14.
Because osascript calls AppleScript (a different scripting language), I like to put my AppleScript command in a variable (line 19) and then call it with osascript. You don't have to do that part like I did. Just follow the example on line 20.
https://gist.github.com/talkingmoose/0fbc4213fe92d305f8d72b1a0dabda53