MacOS default group is not user name.

This commit is contained in:
Kevin Baensch 2023-01-09 10:41:41 +01:00
parent 69419a8f9c
commit a24298219e

View file

@ -2,6 +2,12 @@
set -e set -e
PROJECT_PATH=$(dirname $0) PROJECT_PATH=$(dirname $0)
WHOAMI="$(id -un)" WHOAMI="$(id -un)"
if [ "$(uname -s)" = "Linux" ]
then
MYGROUP="${WHOAMI}"
else
MYGROUP="staff"
fi
if [ $(id -u) -eq 0 ] if [ $(id -u) -eq 0 ]
then then
@ -20,10 +26,10 @@ check() {
setup_base() { setup_base() {
printf 'Change ownership of "%s" to "%s"? (setup may fail otherwise)\n' "${PROJECT_PATH}" "${WHOAMI}" printf 'Change ownership of "%s" to "%s"? (setup may fail otherwise)\n' "${PROJECT_PATH}" "${WHOAMI}"
printf 'running: "sudo chown -R %s %s"\n' "${WHOAMI}:${WHOAMI}" "${PROJECT_PATH}" printf 'running: "sudo chown -R %s %s"\n' "${WHOAMI}:${MYGROUP}" "${PROJECT_PATH}"
if check 'Continue? [Y/n] ' if check 'Continue? [Y/n] '
then then
sudo chown -R "${WHOAMI}:${WHOAMI}" "${PROJECT_PATH}" sudo chown -R "${WHOAMI}:${MYGROUP}" "${PROJECT_PATH}"
fi fi