Skip to content

Commit e8dd322

Browse files
committed
move file download to shared script
1 parent 188e724 commit e8dd322

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function _terminus_login() {
2+
if [ -z "$TERMINUS_TOKEN" ]; then
3+
# Fallback to DEVOPS_TERMINUS_TOKEN if personal token is not set (intended for Codespaces).
4+
if [ -z "$DEVOPS_TERMINUS_TOKEN" ]; then
5+
echo "Please set the TERMINUS_TOKEN environment variable."
6+
exit 1
7+
fi
8+
export TERMINUS_TOKEN=$DEVOPS_TERMINUS_TOKEN
9+
fi
10+
terminus auth:login --machine-token=$TERMINUS_TOKEN
11+
}

local/etc/uceap.d/devcontainer_on_create.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ function devcontainer_on_create() {
4141
chgrp www-data web/sites/default/files
4242
chmod g+s web/sites/default/files
4343

44+
# Download files
45+
_terminus_login
46+
TERMINUS_ENV="dev" terminus backup:get --element=files --to=files.tar.gz
47+
tar zx --no-same-permissions --strip-components 1 -C web/sites/default/files -f files.tar.gz
48+
rm files.tar.gz
49+
# no-same-permissions doesn't seem to work so we fix it here
50+
sudo find web/sites/default/files -type d -exec chmod g+ws {} +
51+
sudo find web/sites/default/files -type f -exec chmod g+w {} +
52+
53+
4454
# Setup drush and other vendor binaries
4555
echo "export PATH=\"`pwd`/vendor/bin:\$PATH\"" | tee -a ~/.bashrc ~/.zshrc ~/.zshrc.local
4656

local/etc/uceap.d/devcontainer_post_create.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
function devcontainer_post_create() {
2-
# Authenticate to Pantheon iff the user set a token env var
3-
if [[ -n "$TERMINUS_TOKEN" ]]; then
4-
terminus -n auth:login --machine-token="$TERMINUS_TOKEN"
5-
fi
6-
72
# Install GitHub CLI Copilot Extension
83
if [[ -n "$GH_TOKEN" ]] || [[ -n "$GITHUB_TOKEN" ]] ; then
94
gh extension install github/gh-copilot

0 commit comments

Comments
 (0)