From 52b2de9122168567c0949faadb5c1560c67a24bd Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 20 Aug 2019 17:42:34 -0700 Subject: [PATCH 1/2] civi-download-tools - Add drush-backdrop plugin Before ------ On Backdrop builds, `drush` cannot be used - because the drush-backdrop plugin is missing. After ----- On Backdrop builds, `drush` can be used - because the plugin is present. Comments -------- This has come up a few ways - e.g. * Test/demo sites don't have a test/demo user - https://lab.civicrm.org/infra/ops/issues/906 * When QA'ing patches for civicrm-backdrop's copy of `civicrm.drush.inc` - e.g. https://github.com/civicrm/civicrm-backdrop/pull/98 --- bin/civi-download-tools | 16 ++++++++++++++++ src/drush/drush8.tmpl | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/bin/civi-download-tools b/bin/civi-download-tools index 237dc0de..fa37b841 100755 --- a/bin/civi-download-tools +++ b/bin/civi-download-tools @@ -34,6 +34,7 @@ CIVISTRINGSURL="https://download.civicrm.org/civistrings/civistrings.phar-2018-0 JOOMLAURL="https://download.civicrm.org/joomlatools-console/joomla.phar-2017-06-19-62ff6a9df" CODECEPTION_PHP5_URL="http://codeception.com/releases/2.3.6/php54/codecept.phar" CODECEPTION_PHP7_URL="http://codeception.com/releases/2.3.6/codecept.phar" +DRUSH_BD_URL="https://github.com/backdrop-contrib/drush/archive/1.0.0.zip" IS_QUIET= IS_FORCE= IS_FULL= @@ -751,6 +752,21 @@ pushd $PRJDIR >> /dev/null make_link "$PRJDIR/bin" "../extern/phpunit5/phpunit5.phar" "phpunit5" make_link "$PRJDIR/bin" "../extern/phpunit6/phpunit6.phar" "phpunit6" + ## Download "drush" addons + if [ -z "$IS_FORCE" -a -e "$PRJDIR/extern/drush-lib/backdrop" -a "$(cat $PRJDIR/extern/drush-lib-backdrop.txt)" == "$DRUSH_BD_URL" ]; then + echo_comment "[[drush-backdrop ($PRJDIR/extern/drush-lib/backdrop) already exists. Skipping.]]" + else + download_url "$DRUSH_BD_URL" "$TMPDIR/drush-backdrop.zip" + [ -d "$PRJDIR/extern/drush-lib/backdrop" ] && rm -rf "$PRJDIR/extern/drush-lib/backdrop" + mkdir -p "$PRJDIR/extern/drush-lib/backdrop" + pushd "$PRJDIR/extern/drush-lib/backdrop" >> /dev/null + # touch created-by-me + unzip "$TMPDIR/drush-backdrop.zip" + popd >> /dev/null + rm -f "$TMPDIR/drush-backdrop.zip" + echo "$DRUSH_BD_URL" > "$PRJDIR/extern/drush-lib-backdrop.txt" + fi + ## Download "hub" touch "$PRJDIR/extern/hub.txt" if [ -z "$IS_FORCE" -a -e "$PRJDIR/extern/hub/bin/hub" -a -e "$PRJDIR/bin/hub" -a "$(cat $PRJDIR/extern/hub.txt)" == "$HUB_VERSION" ]; then diff --git a/src/drush/drush8.tmpl b/src/drush/drush8.tmpl index 93ec7e22..6383428c 100755 --- a/src/drush/drush8.tmpl +++ b/src/drush/drush8.tmpl @@ -10,4 +10,4 @@ if [ "$PWD" == "$BINDIR" ]; then echo "Error: Cannot run drush from the bin dir. Please navigate to a site dir." >&2 exit 1 fi -exec "$PRJDIR/extern/drush8.phar" "$@" +exec "$PRJDIR/extern/drush8.phar" --include="$PRJDIR/extern/drush-lib" "$@" From 47901e99cc4fda3d806c8eb99d2eeb08d0fe9e0f Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 20 Aug 2019 18:31:46 -0700 Subject: [PATCH 2/2] (infra/ops#906) app/config/backdrop* - Create "demo" user This is only partial fix for infra/ops#906 - it creates the user. (Good.) However, it doesn't configure the role/permissions for the user. (Bad.) I'll post more about that in the discussion of 906. But for the moment, I think this bit is better in than out. --- app/config/backdrop-clean/install.sh | 7 +++++++ app/config/backdrop-demo/install.sh | 7 +++++++ app/config/backdrop-empty/install.sh | 3 +++ 3 files changed, 17 insertions(+) diff --git a/app/config/backdrop-clean/install.sh b/app/config/backdrop-clean/install.sh index d9b72d89..2ce20e5a 100644 --- a/app/config/backdrop-clean/install.sh +++ b/app/config/backdrop-clean/install.sh @@ -33,4 +33,11 @@ civicrm_install pushd "$CMS_ROOT" >> /dev/null php "$SITE_CONFIG_DIR/module-enable.php" civicrm + + ## Setup demo user + # drush -y en civicrm_webtest + drush -y user-create --password="$DEMO_PASS" --mail="$DEMO_EMAIL" "$DEMO_USER" + ##FIXME drush -y user-add-role civicrm_webtest_user "$DEMO_USER" + #echo 'INSERT IGNORE INTO users_roles (uid,role) SELECT uid, "civicrm_webtest_user" FROM users WHERE name = @ENV[DEMO_USER];' \ + # | env DEMO_USER="$DEMO_USER" amp sql -Ncms -e popd >> /dev/null diff --git a/app/config/backdrop-demo/install.sh b/app/config/backdrop-demo/install.sh index ea785f54..8a631706 100644 --- a/app/config/backdrop-demo/install.sh +++ b/app/config/backdrop-demo/install.sh @@ -34,4 +34,11 @@ civicrm_install pushd "$CMS_ROOT" >> /dev/null php "$SITE_CONFIG_DIR/module-enable.php" civicrm civicrm_apply_demo_defaults + + ## Setup demo user + #drush -y en civicrm_webtest + drush -y user-create --password="$DEMO_PASS" --mail="$DEMO_EMAIL" "$DEMO_USER" + ##FIXME: drush -y user-add-role civicrm_webtest_user "$DEMO_USER" + #echo 'INSERT IGNORE INTO users_roles (uid,role) SELECT uid, "civicrm_webtest_user" FROM users WHERE name = @ENV[DEMO_USER];' \ + # | env DEMO_USER="$DEMO_USER" amp sql -Ncms -e popd >> /dev/null diff --git a/app/config/backdrop-empty/install.sh b/app/config/backdrop-empty/install.sh index 7387603e..2d6f3a05 100644 --- a/app/config/backdrop-empty/install.sh +++ b/app/config/backdrop-empty/install.sh @@ -19,3 +19,6 @@ backdrop_install ############################################################################### ## Extra configuration +pushd "$CMS_ROOT" >> /dev/null + drush -y user-create --password="$DEMO_PASS" --mail="$DEMO_EMAIL" "$DEMO_USER" +popd >> /dev/null