Automated install issues

KyleEricson
Valued Contributor II

When I run a .pkg file in AirWatch it doesn't install when I run it normally it works fine. This is my post install script:

!/bin/sh

postinstall

pathToScript=$0
pathToPackage=$1
targetLocation=$2
targetVolume=$3

loggedInUser=/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'

mv /tmp/Microsoft /Users/$USER/Library/Application Support/

chown -R $loggedInUser:staff /Users/$USER/Library/Application Support/Microsoft

exit 0 ## Success
exit 1 ## Failure

Read My Blog: https://www.ericsontech.com
4 REPLIES 4

thoule
Valued Contributor II

$USER is an environment variable which is unlikely to be set when run via AirWatch (or any other management system).

Instead of $USER, use $loggedInUser. Really you should look up the user's home directory, but I'm guessing in your environment, that won't be a problem.

Nix4Life
Valued Contributor

@thoule beat me to it

KyleEricson
Valued Contributor II

I changed this but I see the folder isn't moving it has a red line saying I have no access.
09cf9583168d40d88b0f44d088805a83

I updated the postinstall as well.

!/bin/sh

postinstall

pathToScript=$0
pathToPackage=$1
targetLocation=$2
targetVolume=$3

loggedInUser=/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'

mv /tmp/Microsoft /Users/$loggedInUser/Library/Application Support/

chown -R $loggedInUser:staff /Users/$loggedInUser/Library/Application Support/Microsoft

exit 0 ## Success
exit 1 ## Failure

Read My Blog: https://www.ericsontech.com

KyleEricson
Valued Contributor II

I was able to fix the red folder but still can seem to move the folder to the current users Application Support.

Read My Blog: https://www.ericsontech.com