|
1 | 1 | function devcontainer_on_create() { |
2 | | - # Change default umask and add user to web group so we can share write permission on web files |
3 | | - sed -i 's/^#umask\s*022/umask 002/' ~/.profile |
4 | | - echo "umask 002" >> ~/.zshrc |
5 | | - echo "umask 002" >> ~/.bashrc |
| 2 | + # Change default umask and add user to web group so we can share write permission on web files |
| 3 | + sed -i 's/^#umask\s*022/umask 002/' ~/.profile |
| 4 | + echo "umask 002" >>~/.zshrc |
| 5 | + echo "umask 002" >>~/.bashrc |
6 | 6 |
|
7 | | - sudo sh -c "cat >> /etc/apache2/sites-available/000-default.conf" <<-EOF |
| 7 | + sudo sh -c "cat >> /etc/apache2/sites-available/000-default.conf" <<-EOF |
8 | 8 | <Directory /var/www/html> |
9 | 9 | AllowOverride All |
10 | 10 | </Directory> |
11 | 11 | EOF |
12 | 12 |
|
13 | | - # This is how the example codespace changes the docroot. If it's good enough for them, it's good enough for me. |
14 | | - sudo chmod a+x "$(pwd)" && sudo rm -rf /var/www/html && sudo ln -s "$(pwd)/web" /var/www/html |
| 13 | + # This is how the example codespace changes the docroot. If it's good enough for them, it's good enough for me. |
| 14 | + sudo chmod a+x "$(pwd)" && sudo rm -rf /var/www/html && sudo ln -s "$(pwd)/web" /var/www/html |
15 | 15 |
|
16 | | - # Setup database if MYSQL_HOST = 127.0.0.1 |
17 | | - cat > ~/.my.cnf <<-EOF |
| 16 | + # Setup database if MYSQL_HOST = 127.0.0.1 |
| 17 | + cat >~/.my.cnf <<-EOF |
18 | 18 | [client] |
19 | 19 | host="$MYSQL_HOST" |
20 | 20 | user="$MYSQL_USER" |
21 | 21 | password="$MYSQL_PASSWORD" |
22 | 22 | EOF |
23 | 23 |
|
24 | | - # translate mysql env vars to our template vars |
25 | | - export DB_HOST="$MYSQL_HOST" DB_PORT="$MYSQL_TCP_PORT" DB_USER="$MYSQL_USER" DB_PASSWORD="$MYSQL_PASSWORD" DB_NAME="$MYSQL_DATABASE" |
| 24 | + # translate mysql env vars to our template vars |
| 25 | + export DB_HOST="$MYSQL_HOST" DB_PORT="$MYSQL_TCP_PORT" DB_USER="$MYSQL_USER" DB_PASSWORD="$MYSQL_PASSWORD" DB_NAME="$MYSQL_DATABASE" |
26 | 26 |
|
27 | | - # Setup our Drupal app |
28 | | - composer dev-initialize-local |
29 | | - cat >> web/sites/default/settings.local.php <<-EOF |
| 27 | + # Setup our Drupal app |
| 28 | + composer dev-initialize-local |
| 29 | + cat >>web/sites/default/settings.local.php <<-EOF |
30 | 30 | \$settings['trusted_host_patterns'] = []; |
31 | 31 |
|
32 | 32 | # make drupal play nice with codespace proxy |
33 | 33 | \$settings['reverse_proxy'] = TRUE; |
34 | 34 | \$settings['reverse_proxy_addresses'] = array(\$_SERVER['REMOTE_ADDR']); |
35 | 35 | EOF |
36 | 36 |
|
37 | | - composer install |
38 | | - composer compile-theme |
39 | | - |
40 | | - # Set file permissions so both httpd and user can write to files |
41 | | - chgrp www-data web/sites/default/files |
42 | | - chmod g+s web/sites/default/files |
43 | | - |
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 | | - # The database image might be out of date so deploy any new changes from code |
54 | | - vendor/bin/drush deploy |
55 | | - |
56 | | - # Setup drush and other vendor binaries |
57 | | - echo "export PATH=\"`pwd`/vendor/bin:\$PATH\"" | tee -a ~/.bashrc ~/.zshrc ~/.zshrc.local |
58 | | - |
59 | | - # Setup VS Code |
60 | | - mkdir -p $WORKSPACE_FOLDER/.vscode |
61 | | - cp /usr/local/share/vscode/* $WORKSPACE_FOLDER/.vscode/ |
62 | | - |
63 | | - # Install Claude Code |
64 | | - sudo npm install -g @anthropic-ai/claude-code |
65 | | - |
66 | | - # Setup shell completion |
67 | | - uceap completion bash | sudo sh -c "cat > /etc/bash_completion.d/uceap" |
68 | | - gh completion --shell bash | sudo sh -c "cat > /etc/bash_completion.d/gh" |
69 | | - uceap completion zsh | sudo sh -c "cat > /usr/local/share/zsh/site-functions/_uceap" |
70 | | - gh completion --shell zsh | sudo sh -c "cat > /usr/local/share/zsh/site-functions/_gh" |
71 | | - # Force loading of the completion script because I can't get it to autoload |
72 | | - echo "autoload -Uz _uceap && compdef _uceap uceap" | tee -a ~/.zshrc ~/.zshrc.local |
73 | | - |
74 | | - # Run local devcontainer lifecycle scripts |
75 | | - if [ -x .devcontainer/onCreate.sh ]; then |
76 | | - .devcontainer/onCreate.sh |
77 | | - fi |
| 37 | + composer install |
| 38 | + composer compile-theme |
| 39 | + |
| 40 | + # Set file permissions so both httpd and user can write to files |
| 41 | + chgrp www-data web/sites/default/files |
| 42 | + chmod g+s web/sites/default/files |
| 43 | + |
| 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 | + # The database image might be out of date so deploy any new changes from code |
| 54 | + vendor/bin/drush deploy |
| 55 | + |
| 56 | + # Setup drush and other vendor binaries |
| 57 | + echo "export PATH=\"$(pwd)/vendor/bin:\$PATH\"" | tee -a ~/.bashrc ~/.zshrc ~/.zshrc.local |
| 58 | + |
| 59 | + # Setup VS Code |
| 60 | + mkdir -p $WORKSPACE_FOLDER/.vscode |
| 61 | + cp /usr/local/share/vscode/* $WORKSPACE_FOLDER/.vscode/ |
| 62 | + |
| 63 | + # Install Claude Code |
| 64 | + sudo npm install -g @anthropic-ai/claude-code |
| 65 | + |
| 66 | + # Setup shell completion |
| 67 | + uceap completion bash | sudo sh -c "cat > /etc/bash_completion.d/uceap" |
| 68 | + gh completion --shell bash | sudo sh -c "cat > /etc/bash_completion.d/gh" |
| 69 | + uceap completion zsh | sudo sh -c "cat > /usr/local/share/zsh/site-functions/_uceap" |
| 70 | + gh completion --shell zsh | sudo sh -c "cat > /usr/local/share/zsh/site-functions/_gh" |
| 71 | + # Force loading of the completion script because I can't get it to autoload |
| 72 | + echo "autoload -Uz _uceap && compdef _uceap uceap" | tee -a ~/.zshrc ~/.zshrc.local |
| 73 | + |
| 74 | + # Run local devcontainer lifecycle scripts |
| 75 | + if [ -x .devcontainer/onCreate.sh ]; then |
| 76 | + .devcontainer/onCreate.sh |
| 77 | + fi |
78 | 78 | } |
79 | 79 |
|
80 | 80 | _devcontainer_on_create_desc='runs when the devcontainer is created' |
|
0 commit comments