I built a pkg using Platypus that is designed to run an unattended install using the following script:
#!/bin/sh
sudo installer -allowUntrusted -verboseR -pkg "/path-to-pkg" -target /
I added the following line to present the users with a notification when the installation was complete:
#!/bin/sh
osascript -e 'tell app "System Events" to display dialog "All Done!"'
When I tested, I kept getting mixed results. Sometimes the installation would complete successfully. But, most of my tests were unsuccessful. The application appeared to "install" in a matter of seconds. When I looked in the system log, I kept seeing the following error "sudo: no tty present and no askpass program specified"
The users on these particular machines are admins and should be sudoers. Is there a way to prompt them for their password and pass that through a script?
I tried something like this:
#!/bin/sh
CURPASSWORD="$(osascript -e 'tell application "System Events" to display dialog "Please enter your CURRENT password:" with hidden answer default answer ""' -e 'text returned of result' 2>/dev/null)"
if [ $? -ne 0 ]; then
# Pressed cancel
exit 0
elif [ -z "$CURPASSWORD" ]; then
# Left blank
osascript -e 'tell application "System Events" to display alert "Password can not be left blank." as warning'
else break
fi
echo "$CURPASSWORD" | sudo -S installer —allowUntrusted —VerboseR -pkg "path-to-pkg" -target /
But, that was also not successful.
Any help would be appreciated. Not sure what else to try.
Thanks in advance,
Marcos