@@ -5,8 +5,19 @@ set -euo pipefail
55# allow this script to be invoked from any folder
66DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
77
8- if [ $EUID -ne 0 ]; then
9- echo " This script must be run with sudo"
8+ # macOS detection
9+ IS_DARWIN=false
10+ if [[ " $( uname) " == " Darwin" ]]; then
11+ IS_DARWIN=true
12+ fi
13+
14+ if $IS_DARWIN && [[ $EUID -eq 0 ]]; then
15+ echo " Do NOT run this script with sudo on macOS"
16+ exit 1
17+ fi
18+
19+ if ! $IS_DARWIN && [[ $EUID -ne 0 ]]; then
20+ echo " This script must be run with sudo on Linux"
1021 exit 1
1122fi
1223
@@ -17,7 +28,11 @@ tmpfile=$(mktemp)
1728git submodule status --recursive > " $tmpfile "
1829
1930if grep -q " ^-" " $tmpfile " ; then
20- sudo -u $SUDO_USER git submodule update --init --recursive
31+ if $IS_DARWIN ; then
32+ git submodule update --init --recursive
33+ else
34+ sudo -u $SUDO_USER git submodule update --init --recursive
35+ fi
2136elif grep -q " ^+" " $tmpfile " ; then
2237 # Make it easy for users who are not hacking ORFS to do the right thing,
2338 # run with current submodules, at the cost of having ORFS
@@ -27,4 +42,8 @@ elif grep -q "^+" "$tmpfile"; then
2742fi
2843
2944" $DIR /etc/DependencyInstaller.sh" -base
30- sudo -u $SUDO_USER " $DIR /etc/DependencyInstaller.sh" -common -prefix=" $DIR /dependencies"
45+ if $IS_DARWIN ; then
46+ " $DIR /etc/DependencyInstaller.sh" -common -prefix=" $DIR /dependencies"
47+ else
48+ sudo -u $SUDO_USER " $DIR /etc/DependencyInstaller.sh" -common -prefix=" $DIR /dependencies"
49+ fi
0 commit comments