forked from drupal-composer/drupal-project
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup-base.sh
executable file
·68 lines (57 loc) · 2.34 KB
/
setup-base.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
#
# Base setup script. Takes care of setting up files directories.
#
# This will be invoked via the phapp setup command when a site is setup.
cd `dirname $0`/..
source scripts/util/os-compat-helpers.sh
# Copy example settings.
cp web/sites/example.local.services.yml web/sites/local.services.yml
cp web/sites/example.local.settings.php web/sites/local.settings.php
# For drunomics-CI generate additional variables that can be used in its
# dotenv file.
if [[ $PHAPP_ENV = "drunomics-ci" ]]; then
echo "CONTAINER_HOST=$(hostname -f)" > .container.env
echo "CONTAINER_NAME=$(hostname -s)" >> .container.env
fi
# Default to first sub-site during development.
if [ ! -L web/sites/default ]; then
rm -rf web/sites/default
DIR=$(cd web/sites/ && ls -d */ | grep -v all/ | head -n 1)
ln -s $DIR web/sites/default
fi
# Load dotenv.
source dotenv/loader.sh
# Be sure files directories are setup.
for SITE in `ls -d web/sites/*/`; do
SITE=`basename $SITE`
if [[ $SITE == 'all' ]] || [[ $SITE == 'default' ]]; then
continue;
fi
mkdir -p $PERSISTENT_FILES_DIR/$SITE/public/translations
mkdir -p $PERSISTENT_FILES_DIR/$SITE/private
if [ -n "$ENV_UNIX_GROUP_WEBSERVER" ]; then
if [[ $(id -u) -eq 0 || $(command -v sudo) ]]; then
# Note: this group may not exist on the host OS (MacOS), so the command
# fails. Just ignore the error; chmods are still done and things work OK.
sudo chown -R :$ENV_UNIX_GROUP_WEBSERVER $PERSISTENT_FILES_DIR/$SITE/
# When a custom group is set, ensure sub-directory and files are always
# webserver writable via the setgid bit. This makes the right group to be
# propagated down.
sudo chmod 2775 $PERSISTENT_FILES_DIR/$SITE/public
sudo chmod 2775 $PERSISTENT_FILES_DIR/$SITE/public/translations
sudo chmod 2775 $PERSISTENT_FILES_DIR/$SITE/private
fi
fi
# Move files for existing dev-installations.
if [[ -d web/sites/$SITE/files ]] && [[ ! -L web/sites/$SITE/files ]]; then
# Ignore errors moving something.
mv web/sites/$SITE/files/* $PERSISTENT_FILES_DIR/$SITE/public || true
rm -rf web/sites/$SITE/files
fi
# Link public files directory to persistent files.
mkdir -p web/sites/$SITE
if [[ ! -L web/sites/$SITE/files ]]; then
os_compat_link_directory ../../../$PERSISTENT_FILES_DIR/$SITE/public web/sites/$SITE/files
fi
done