Created
October 19, 2016 19:05
-
-
Save smashism/51a6a3862b27aa6ab46dd7f614c549d2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get current user and OS information. | |
CURRENT_USER=$(/usr/bin/stat -f%Su /dev/console) | |
USER_ID=$(id -u "$CURRENT_USER") | |
OS_MAJOR=$(/usr/bin/sw_vers -productVersion | awk -F . '{print $1}') | |
OS_MINOR=$(/usr/bin/sw_vers -productVersion | awk -F . '{print $2}') | |
# Launch the app using launchctl. | |
echo "Launching App Store..." | |
if [[ "$OS_MAJOR" -eq 10 && "$OS_MINOR" -le 9 ]]; then | |
LOGINWINDOW_PID=$(pgrep -x -u "$USER_ID" loginwindow) | |
launchctl bsexec "$LOGINWINDOW_PID" open "macappstore://showUpdatesPage" | |
elif [[ "$OS_MAJOR" -eq 10 && "$OS_MINOR" -gt 9 ]]; then | |
launchctl asuser "$USER_ID" open "macappstore://showUpdatesPage" | |
else | |
echo "[ERROR] macOS $OS_MAJOR.$OS_MINOR is not supported." | |
exit 1004 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment