Update dockutil-labels-user.sh

This commit is contained in:
Michael
2023-02-06 13:57:08 +00:00
committed by GitHub
parent 968f1eccac
commit ecc77ce860

View File

@@ -1,15 +1,17 @@
DEPLOG=/var/tmp/depnotify.log
echo *** DOCKUTIL LABELS AS USER ***
currentUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ { print $3 }' )
currentUser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ { print $3 }')
uid=$(id -u "$currentUser")
runAsUser() {
if [ "$currentUser" != "loginwindow" ]; then
launchctl asuser "$uid" sudo -u "$currentUser" "$@"
echo logged in user is $( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ { print $3 }' )
launchctl asuser "$uid" sudo -u "$currentUser" "$@"
else
echo "no user logged in"
exit 1
echo "No user logged in."
# uncomment the exit command
# to make the function exit with an error when no user is logged in
# exit 1
fi
}