Skip to content

Instantly share code, notes, and snippets.

@jeremy4971
Last active January 6, 2024 10:30
Show Gist options
  • Save jeremy4971/8d31d92f9da8c6b27e71065b31825ccf to your computer and use it in GitHub Desktop.
Save jeremy4971/8d31d92f9da8c6b27e71065b31825ccf to your computer and use it in GitHub Desktop.
#!/bin/bash
###
#
# Created : 2021-02-08
# Last Modified : 2022-11-05
# Version : 1.02
# Tested with : macOS 13.0
#
###
# Mac@IBM Notifications binary path
NA_PATH="/Applications/IBM Notifier.app/Contents/MacOS/IBM Notifier"
#################
### FUNCTIONS ###
#################
unnecessary() {
WINDOWTYPE="systemalert"
ICON="https://i.imgur.com/i6qx4pJ.png"
TITLE="Nothing to do!"
BUTTON_1="OK"
SUBTITLE="Sudo Touch ID is already configured."
"${NA_PATH}" "-type" "${WINDOWTYPE}" "-icon_path" "${ICON}" "-title" "${TITLE}" "-subtitle" "${SUBTITLE}" "-main_button_label" "${BUTTON_1}"; echo $?
}
success() {
WINDOWTYPE="systemalert"
ICON="https://i.imgur.com/i6qx4pJ.png"
TITLE="Done!"
BUTTON_1="OK"
SUBTITLE="Sudo Touch ID is now configured.
Please quit your Terminal"
"${NA_PATH}" "-type" "${WINDOWTYPE}" "-icon_path" "${ICON}" "-title" "${TITLE}" "-subtitle" "${SUBTITLE}" "-main_button_label" "${BUTTON_1}"; echo $?
}
#####################
### END FUNCTIONS ###
#####################
# Reading 2nd row
CHECK_2ND_ROW=$(cat /private/etc/pam.d/sudo | sed -n 2p)
# Checking if Sudo Touch ID is already configured
if [ "$CHECK_2ND_ROW" = "auth sufficient pam_tid.so" ]; then
unnecessary
else
# Backup sudo file then add 2nd row
sed -i '.bak' '2s/^/auth sufficient pam_tid.so\'$'\n/g' /private/etc/pam.d/sudo
success
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment