1+ #! /bin/bash
2+ set -eo pipefail
3+
4+ # ensure we're working in the workspace folder
5+ if [ -n " $WORKSPACE_FOLDER " ]; then
6+ cd $WORKSPACE_FOLDER
7+ else
8+ echo " No WORKSPACE_FOLDER environment variable set, please update your devcontainer.json file."
9+ # as a transitional fallback, check to see if composer.json exists in the current directory, in which case we assume we're in the workspace folder
10+ if [ ! -f composer.json ]; then
11+ echo " No composer.json found in the current directory, please run this script from the root of your project."
12+ exit 1
13+ fi
14+ fi
15+
16+ # re-run composer install (e.g. in case we've switched branches since last time we ran this script)
17+ composer install
18+
19+ # re-build the theme (likewise in case of changes)
20+ composer compile-theme
21+
22+ # during first run, the new PATH from the on-create script is not yet in effect
23+ if ( ! command -v drush > /dev/null ); then
24+ export PATH=" ` pwd` /vendor/bin:$PATH "
25+ fi
26+
27+ # we need to preserve gitconfig if it already exists
28+ if [ -f ~ /.gitconfig ]; then
29+ gitconfig_existed=true
30+ fi
31+ # ownership of the workspace directory won't match when using bindfs
32+ git config --global --add safe.directory " $( pwd) "
33+ # gh runs git, so we need to set the safe.directory in order for it to work
34+ gh release download --clobber --pattern ' *.gz'
35+ # but later on vscode will try setting global git config (credential helper, etc) ONLY if gitconfig doesn't exist
36+ if [ ! $gitconfig_existed ]; then
37+ rm ~ /.gitconfig
38+ fi
39+ # FWIW vscode will also fix the safe.directory setting
40+
41+ tar zx --no-same-permissions --strip-components 1 -C web/sites/default/files -f files.tar.gz
42+ rm files.tar.gz
43+
44+ # no-same-permissions doesn't seem to work so we fix it here
45+ sudo find web/sites/default/files -type d -exec chmod g+ws {} +
46+ sudo find web/sites/default/files -type f -exec chmod g+w {} +
47+
48+ # the first time we run this script the default umask is still in effect,
49+ # which messes up permissions on the profiler directory that gets created when the caches are rebuilt by db-rebuild.sh
50+ umask 002
51+
52+ sudo service mariadb start
53+ build/db-rebuild.sh database.sql.gz
54+ rm database.sql.gz
55+
56+ # Run local devcontainer lifecycle scripts
57+ if [ -x .devcontainer/updateContent.sh ]; then
58+ .devcontainer/updateContent.sh
59+ fi
0 commit comments