diff --git a/deploy.php b/deploy.php index 5fb1c5d..c7acb80 100644 --- a/deploy.php +++ b/deploy.php @@ -17,5 +17,32 @@ after('deploy:vendors', 'deploy:d3OxidTasks'); desc('Oxid related tasks'); task('deploy:d3OxidTasks', [ 'deploy:clear_paths', - 'deploy:update_code' // reset committed shop files + 'deploy:setShopsOffline', + 'deploy:setShopsOnline' ]); + +desc('set shops offline'); +task('deploy:setShopsOffline', function() { + if (has('bin/mysql') && strlen(get('bin/mysql')) && + has('dbName') && strlen(get('dbName')) && + has('dbConfPath') && strlen(get('dbConfPath')) && test("[ -f {{dbConfPath}} ]") + ) { + $query = "UPDATE oxshops SET oxactive = '0', OXREGISTERSUBJECT = CONCAT('..', OXREGISTERSUBJECT) WHERE oxactive = '1';"; + run('{{bin/mysql}} --defaults-extra-file={{dbConfPath}} {{dbName}} -e "'.$query.'"'); + } else { + info('missing config, task skipped'); + } +})->select('role=production,role=stage'); + +desc('set shops online'); +task('deploy:setShopsOnline', function() { + if (has('bin/mysql') && strlen(get('bin/mysql')) && + has('dbName') && strlen(get('dbName')) && + has('dbConfPath') && strlen(get('dbConfPath')) && test("[ -f {{dbConfPath}} ]") + ) { + $query = "UPDATE oxshops SET oxactive = '1', OXREGISTERSUBJECT = SUBSTR(OXREGISTERSUBJECT, 3) WHERE oxactive = '0' AND OXREGISTERSUBJECT LIKE '..%';"; + run('{{bin/mysql}} --defaults-extra-file={{dbConfPath}} {{dbName}} -e "'.$query.'"'); + } else { + info('missing config, task skipped'); + } +})->select('role=production,role=stage'); diff --git a/inventory.yml b/inventory.yml index 9b01f79..711f77a 100644 --- a/inventory.yml +++ b/inventory.yml @@ -3,10 +3,12 @@ config: keep_releases: 5 repository: gitfhfac@git.d3data.de:Customers/my.shop.com.git bin/php: /usr/local/php8.2/bin/php + bin/mysql: /usr/local/mysql/bin/mysql .base: &base local: true deploy_path: /home/XXX/{{application}}_{{alias}} + dbConfPath: /home/phfhcwoc/dbConf/my_{{alias}}.cnf shared_files: - .htpasswd - .env # otherwise source/config.inc.php @@ -24,12 +26,16 @@ config: hosts: production: <<: *base - roles: production branch: rel_7.0.x + dbName: myProdDatabase + labels: + role: production # production | stage | development development: <<: *base - roles: development branch: dev_7.1.x + dbName: myDevDatabase keep_releases: 1 composer_options: --verbose --prefer-dist --no-progress --no-interaction # without no-dev option + labels: + role: development