From 09cfa29cf744645f3d48850f737ed08ef18c4a1e Mon Sep 17 00:00:00 2001 From: Tormi Tabor Date: Wed, 3 Apr 2019 15:53:59 +0300 Subject: [PATCH 1/5] Pevent syncing to @prod environment. --- drupal/drush/Commands/PolicyCommands.php | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 drupal/drush/Commands/PolicyCommands.php diff --git a/drupal/drush/Commands/PolicyCommands.php b/drupal/drush/Commands/PolicyCommands.php new file mode 100644 index 00000000..290b4e03 --- /dev/null +++ b/drupal/drush/Commands/PolicyCommands.php @@ -0,0 +1,38 @@ +input()->getArgument('target') == '@prod') { + throw new \Exception(dt('Per !file, you may never overwrite the production database.', ['!file' => __FILE__])); + } + } + + /** + * Limit rsync operations to production site. + * + * @hook validate core:rsync + * + * @throws \Exception + */ + public function rsyncValidate(CommandData $commandData) { + if (preg_match("/^@prod/", $commandData->input()->getArgument('target'))) { + throw new \Exception(dt('Per !file, you may never rsync to the production site.', ['!file' => __FILE__])); + } + } +} From 4a998825e4104564cabfddcd94c85382a1894014 Mon Sep 17 00:00:00 2001 From: Tormi Tabor Date: Wed, 3 Apr 2019 16:19:35 +0300 Subject: [PATCH 2/5] Add Drush 9 aliases files & configure .lando.yml. --- drupal/.lando.yml | 7 +++---- drupal/drush/README.md | 1 + drupal/drush/drush.yml | 6 ++++++ drupal/drush/drushrc.php | 5 ----- drupal/drush/sites/self.site.yml | 20 ++++++++++++++++++++ drupal/scripts/drush/aliases.sh | 10 ++++++++++ 6 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 drupal/drush/README.md create mode 100644 drupal/drush/drush.yml delete mode 100644 drupal/drush/drushrc.php create mode 100644 drupal/drush/sites/self.site.yml create mode 100755 drupal/scripts/drush/aliases.sh diff --git a/drupal/.lando.yml b/drupal/.lando.yml index cb64ff8f..30860d86 100644 --- a/drupal/.lando.yml +++ b/drupal/.lando.yml @@ -30,6 +30,9 @@ services: build: # Perform composer install. - composer install + # Enable Drush aliases. + - chmod +x /app/scripts/drush/aliases.sh + - /app/scripts/drush/aliases.sh # build_as_root: # - "apt-get update -y" # - "apt-get install python-yaml -y" @@ -74,7 +77,3 @@ events: # Clear caches after a database import post-db-import: - appserver: cd $LANDO_WEBROOT && drush cr -y - # Enable Drush aliases. - post-start: - - appserver: mkdir -p $LANDO_MOUNT/.drush/site-aliases - - appserver: ln -sf /app/drush/wundertools.aliases.drushrc.php $LANDO_MOUNT/.drush/site-aliases/wundertools.aliases.drushrc.php diff --git a/drupal/drush/README.md b/drupal/drush/README.md new file mode 100644 index 00000000..9d7bd397 --- /dev/null +++ b/drupal/drush/README.md @@ -0,0 +1 @@ +This directory contains commands, configuration and site aliases for Drush. See https://packagist.org/search/?type=drupal-drush for a directory of Drush commands installable via Composer. diff --git a/drupal/drush/drush.yml b/drupal/drush/drush.yml new file mode 100644 index 00000000..a8cbd007 --- /dev/null +++ b/drupal/drush/drush.yml @@ -0,0 +1,6 @@ +# +# A Drush configuration file +# +# Docs at https://github.com/drush-ops/drush/blob/master/examples/example.drush.yml +# +# Edit or remove this file as needed. diff --git a/drupal/drush/drushrc.php b/drupal/drush/drushrc.php deleted file mode 100644 index 918054d9..00000000 --- a/drupal/drush/drushrc.php +++ /dev/null @@ -1,5 +0,0 @@ - Date: Wed, 3 Apr 2019 16:43:46 +0300 Subject: [PATCH 3/5] Refactor build.sh. --- build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index ad3f983b..ad7d6d42 100755 --- a/build.sh +++ b/build.sh @@ -27,11 +27,11 @@ popd > /dev/null # Parse project config PROJECTCONF=$ROOT/conf/project.yml eval $(parse_yaml $PROJECTCONF) -ALIASFILE=${project_name}.aliases.drushrc.php -ALIASTARGET=$HOME/.drush/$ALIASFILE +ALIASFILE=self.site.yml +ALIASTARGET=$HOME/.drush/sites/$ALIASFILE if [ -z "$drush_alias_path" ]; then - ALIASPATH=$ROOT/drupal/conf/$ALIASFILE + ALIASPATH=$ROOT/drupal/drush/sites/$ALIASFILE else ALIASPATH=$ROOT/${drush_alias_path}/$ALIASFILE fi From f5ee4f1600f73f1d116a3db52d4dd24ff46eb123 Mon Sep 17 00:00:00 2001 From: Tormi Tabor Date: Wed, 3 Apr 2019 16:57:12 +0300 Subject: [PATCH 4/5] Convert wundertools.aliases.drushrc.php to self.site.yml. --- drupal/drush/sites/self.site.yml | 61 ++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 15 deletions(-) diff --git a/drupal/drush/sites/self.site.yml b/drupal/drush/sites/self.site.yml index 2cb7d383..24e010b7 100644 --- a/drupal/drush/sites/self.site.yml +++ b/drupal/drush/sites/self.site.yml @@ -1,20 +1,51 @@ -# Edit or remove this file as needed. # Docs at https://github.com/drush-ops/drush/blob/master/examples/example.site.yml +dev: + host: dev.wundertools.com + options: + command-specific: + sql-sync: + no-cache: true + paths: + dump-dir: /home/www-admin + root: /var/www/dev.wundertools.com/web + uri: 'https://dev.wundertools.com' + user: www-admin + local: + host: local.wundertools.com + options: + env: vagrant + parent: '@parent' + site: wundertools paths: - files: /app/web/sites/default/files - root: /app/web -# uri: 'https://wunderlando.lndo.site/' + files: /vagrant/drupal/files + dump-dir: /home/vagrant + root: /vagrant/drupal/web + user: vagrant + ssh: + options: '-i ' -#prod: -# host: prod.domain.com -# user: www-admin -# root: /path/to/drupal -# uri: http://www.example.com -# -#stage: -# host: stage.domain.com -# user: www-admin -# root: /path/to/drupal -# uri: http://stage.example.com \ No newline at end of file +prod: + host: wundertools.com + options: + command-specific: + sql-sync: + no-cache: true + paths: + dump-dir: /home/www-admin + root: /var/www/wundertools.com/web + uri: 'https://wundertools.com' + user: www-admin + +stage: + host: stage.wundertools.com + options: + command-specific: + sql-sync: + no-cache: true + paths: + dump-dir: /home/www-admin + root: /var/www/stage.wundertools.com/web + uri: 'https://stage.wundertools.com' + user: www-admin From 8317d885780ed5c318f7ee2e0d01df0b70d45fbf Mon Sep 17 00:00:00 2001 From: Tormi Tabor Date: Wed, 3 Apr 2019 17:23:15 +0300 Subject: [PATCH 5/5] Update Setup.md to reflect aliases file changes. --- docs/Setup.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/Setup.md b/docs/Setup.md index 86af9369..6c291777 100644 --- a/docs/Setup.md +++ b/docs/Setup.md @@ -38,9 +38,7 @@ git init ## Configure Drupal build * Edit `drupal/conf/site.yml`, remove things you don't need and add stuff you want in your project. -* Rename `drupal/drush/wundertools.aliases.drushrc.php` to `drupal/drush/[PROJECT_NAME].aliases.drushrc.php` and -configure it to fit your setup. - - this file will be automatically symlinked from `~/.drush` when running vagrant up +* Configure `drupal/drush/sites/self.site.yml` to fit your setup. This file will be automatically symlinked from `~/.drush` when running vagrant up. ## Create new drupal installation