I ran into trouble setting up a script to toggle show/hide hidden folders because of a user(_xcsbuildd) that xcode server has running. The script ran fine on computers without xcode server, but failed on the computers with the server. The script wouldn't function properly because 'who' would return _xcsbuildd as $CurrentUser. I tried substituting 'id -un' instead of 'who' and the modified script ran flawlessly straight from the computer, but failed once I ran it through Self Service.
ORIGINAL SCRIPT
!/bin/bash
CurrentUser=who | grep "console" | awk '{print $1}'
STATUS=sudo -u $CurrentUser defaults read com.apple.finder AppleShowAllFiles
if [ $STATUS = TRUE ];
then
sudo -u $CurrentUser defaults write com.apple.finder AppleShowAllFiles FALSE
else**
sudo -u $CurrentUser defaults write com.apple.finder AppleShowAllFiles TRUE
fi
killall Finder
MODIFIED SCRIPT
!/bin/bash
CurrentUser=id -un | awk '{print $1}'
STATUS=sudo -u $CurrentUser defaults read com.apple.finder AppleShowAllFiles
if [ $STATUS = TRUE ];
then
sudo -u $CurrentUser defaults write com.apple.finder AppleShowAllFiles FALSE
else
sudo -u $CurrentUser defaults write com.apple.finder AppleShowAllFiles TRUE
fi
killall Finder
Can anyone tell me why It ran fine on the computer, but not when deployed via Self Service Policy ?
