mirror of
https://github.com/PurpleComputing/helpful-scripts.git
synced 2026-02-03 13:53:24 +00:00
Update dockutil-labels-user.sh
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user