Skip to content

Commit 2e18024

Browse files
authored
fix: DEV-2107: Make setup-base.sh not create self-referencing link (#73)
2 parents b911452 + 52ad61d commit 2e18024

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

scripts/setup-base.sh

+14-8
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,17 @@ for SITE in `ls -d web/sites/*/`; do
3939
mkdir -p $PERSISTENT_FILES_DIR/$SITE/private
4040

4141
if [ -n "$ENV_UNIX_GROUP_WEBSERVER" ]; then
42-
sudo chown -R :$ENV_UNIX_GROUP_WEBSERVER $PERSISTENT_FILES_DIR/$SITE/
43-
# When a custom group is set, ensure sub-directory and files are always
44-
# webserver writable via the setgid bit. This makes the right group to be
45-
# propagated down.
46-
sudo chmod 2775 $PERSISTENT_FILES_DIR/$SITE/public
47-
sudo chmod 2775 $PERSISTENT_FILES_DIR/$SITE/public/translations
48-
sudo chmod 2775 $PERSISTENT_FILES_DIR/$SITE/private
42+
if [[ $(id -u) -eq 0 || $(command -v sudo) ]]; then
43+
# Note: this group may not exist on the host OS (MacOS), so the command
44+
# fails. Just ignore the error; chmods are still done and things work OK.
45+
sudo chown -R :$ENV_UNIX_GROUP_WEBSERVER $PERSISTENT_FILES_DIR/$SITE/
46+
# When a custom group is set, ensure sub-directory and files are always
47+
# webserver writable via the setgid bit. This makes the right group to be
48+
# propagated down.
49+
sudo chmod 2775 $PERSISTENT_FILES_DIR/$SITE/public
50+
sudo chmod 2775 $PERSISTENT_FILES_DIR/$SITE/public/translations
51+
sudo chmod 2775 $PERSISTENT_FILES_DIR/$SITE/private
52+
fi
4953
fi
5054

5155
# Move files for existing dev-installations.
@@ -57,6 +61,8 @@ for SITE in `ls -d web/sites/*/`; do
5761

5862
# Link public files directory to persistent files.
5963
mkdir -p web/sites/$SITE
60-
os_compat_link_directory ../../../$PERSISTENT_FILES_DIR/$SITE/public web/sites/$SITE/files
64+
if [[ ! -L web/sites/$SITE/files ]]; then
65+
os_compat_link_directory ../../../$PERSISTENT_FILES_DIR/$SITE/public web/sites/$SITE/files
66+
fi
6167
done
6268

0 commit comments

Comments
 (0)