@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | /** |
| 27 | 27 | * Path to Phinx |
| 28 | 28 | */ |
| 29 | -set('bin/phinx', function () { |
|
| 29 | +set('bin/phinx', function() { |
|
| 30 | 30 | try { |
| 31 | 31 | $phinxPath = run('which phinx'); |
| 32 | 32 | } catch (RunException $e) { |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | |
| 95 | 95 | desc('Migrating database with phinx'); |
| 96 | -task('phinx:migrate', function () { |
|
| 96 | +task('phinx:migrate', function() { |
|
| 97 | 97 | $ALLOWED_OPTIONS = [ |
| 98 | 98 | 'configuration', |
| 99 | 99 | 'date', |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | ); |
| 116 | 116 | |
| 117 | 117 | desc('Rollback database migrations with phinx'); |
| 118 | -task('phinx:rollback', function () { |
|
| 118 | +task('phinx:rollback', function() { |
|
| 119 | 119 | $ALLOWED_OPTIONS = [ |
| 120 | 120 | 'configuration', |
| 121 | 121 | 'date', |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | ); |
| 138 | 138 | |
| 139 | 139 | desc('Seed database with phinx'); |
| 140 | -task('phinx:seed', function () { |
|
| 140 | +task('phinx:seed', function() { |
|
| 141 | 141 | $ALLOWED_OPTIONS = [ |
| 142 | 142 | 'configuration', |
| 143 | 143 | 'environment', |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | ); |
| 159 | 159 | |
| 160 | 160 | desc('Set a migrations breakpoint with phinx'); |
| 161 | -task('phinx:breakpoint', function () { |
|
| 161 | +task('phinx:breakpoint', function() { |
|
| 162 | 162 | $ALLOWED_OPTIONS = [ |
| 163 | 163 | 'configuration', |
| 164 | 164 | 'environment', |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | desc('Notifying RabbitMQ channel about deployment'); |
| 16 | -task('deploy:rabbit', function () { |
|
| 16 | +task('deploy:rabbit', function() { |
|
| 17 | 17 | |
| 18 | 18 | if (!class_exists('PhpAmqpLib\Connection\AMQPConnection')) { |
| 19 | 19 | throw new \RuntimeException("<comment>Please install php package</comment> <info>videlalvaro/php-amqplib</info> <comment>to use rabbitmq</comment>"); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | !isset($config['port']) || |
| 54 | 54 | !isset($config['username']) || |
| 55 | 55 | !isset($config['password']) || |
| 56 | - !isset($config['vhost']) ) |
|
| 56 | + !isset($config['vhost'])) |
|
| 57 | 57 | { |
| 58 | 58 | throw new \RuntimeException("<comment>Please configure rabbit config:</comment> <info>set('rabbit', array('channel' => 'channel', 'host' => 'host', 'port' => 'port', 'username' => 'username', 'password' => 'password'));</info>"); |
| 59 | 59 | } |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | desc('Notifying Sentry of deployment'); |
| 15 | 15 | task( |
| 16 | 16 | 'deploy:sentry', |
| 17 | - static function () { |
|
| 17 | + static function() { |
|
| 18 | 18 | $now = date('c'); |
| 19 | 19 | |
| 20 | 20 | $defaultConfig = [ |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | $config = array_merge($defaultConfig, (array) get('sentry')); |
| 42 | 42 | array_walk( |
| 43 | 43 | $config, |
| 44 | - static function (&$value) use ($config) { |
|
| 44 | + static function(&$value) use ($config) { |
|
| 45 | 45 | if (is_callable($value)) { |
| 46 | 46 | $value = $value($config); |
| 47 | 47 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | function getReleaseGitRef(): Closure |
| 145 | 145 | { |
| 146 | - return static function ($config = []): string { |
|
| 146 | + return static function($config = []): string { |
|
| 147 | 147 | cd('{{release_path}}'); |
| 148 | 148 | |
| 149 | 149 | if (isset($config['git_version_command'])) { |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | function getGitCommitsRefs(): Closure |
| 158 | 158 | { |
| 159 | - return static function ($config = []): array { |
|
| 159 | + return static function($config = []): array { |
|
| 160 | 160 | $previousReleaseRevision = null; |
| 161 | 161 | |
| 162 | 162 | if (has('previous_release')) { |
@@ -177,13 +177,13 @@ discard block |
||
| 177 | 177 | $lines = array_filter( |
| 178 | 178 | // limit number of commits for first release with many commits |
| 179 | 179 | array_map('trim', array_slice(explode("\n", $result), 0, 200)), |
| 180 | - static function (string $line): bool { |
|
| 180 | + static function(string $line): bool { |
|
| 181 | 181 | return !empty($line) && strpos($line, 'commit') !== 0; |
| 182 | 182 | } |
| 183 | 183 | ); |
| 184 | 184 | |
| 185 | 185 | return array_map( |
| 186 | - static function (string $line): array { |
|
| 186 | + static function(string $line): array { |
|
| 187 | 187 | list($ref, $authorName, $authorEmail, $timestamp, $message) = explode('#', $line, 5); |
| 188 | 188 | |
| 189 | 189 | return [ |
@@ -58,30 +58,30 @@ discard block |
||
| 58 | 58 | set('ispmanager_aliaslist', []); |
| 59 | 59 | |
| 60 | 60 | desc('Initialisation'); |
| 61 | -task('ispmanager:init', function () { |
|
| 62 | - $config = get ('ispmanager'); |
|
| 61 | +task('ispmanager:init', function() { |
|
| 62 | + $config = get('ispmanager'); |
|
| 63 | 63 | |
| 64 | - if (!is_null ($config['createDatabase']) || !is_null ($config['deleteDatabase'])) { |
|
| 64 | + if (!is_null($config['createDatabase']) || !is_null($config['deleteDatabase'])) { |
|
| 65 | 65 | invoke('ispmanager:db-server-list'); |
| 66 | 66 | invoke('ispmanager:db-list'); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - if (!is_null ($config['createDomain']) || !is_null ($config['deleteDomain'])) { |
|
| 69 | + if (!is_null($config['createDomain']) || !is_null($config['deleteDomain'])) { |
|
| 70 | 70 | invoke('ispmanager:domain-list'); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - if (!is_null ($config['phpSelect'])) { |
|
| 73 | + if (!is_null($config['phpSelect'])) { |
|
| 74 | 74 | invoke('ispmanager:domain-list'); |
| 75 | 75 | invoke('ispmanager:get-php-list'); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if (!is_null ($config['createAlias']) || !is_null ($config['deleteAlias'])) { |
|
| 78 | + if (!is_null($config['createAlias']) || !is_null($config['deleteAlias'])) { |
|
| 79 | 79 | invoke('ispmanager:domain-list'); |
| 80 | 80 | } |
| 81 | 81 | }); |
| 82 | 82 | |
| 83 | 83 | desc('Take database servers list'); |
| 84 | -task('ispmanager:db-server-list', function () { |
|
| 84 | +task('ispmanager:db-server-list', function() { |
|
| 85 | 85 | $response = ispmanagerRequest('get', [ |
| 86 | 86 | 'func' => 'db.server', |
| 87 | 87 | ]); |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $hostList = []; |
| 90 | 90 | $serverList = []; |
| 91 | 91 | |
| 92 | - if (isset ($response['doc']['elem']) && count ($response['doc']['elem']) > 0) { |
|
| 92 | + if (isset ($response['doc']['elem']) && count($response['doc']['elem']) > 0) { |
|
| 93 | 93 | foreach ($response['doc']['elem'] as $dbServer) { |
| 94 | 94 | $serverList[$dbServer['name']['$']] = [ |
| 95 | 95 | 'host' => $dbServer['host']['$'], |
@@ -97,14 +97,14 @@ discard block |
||
| 97 | 97 | 'version' => $dbServer['savedver']['$'], |
| 98 | 98 | ]; |
| 99 | 99 | |
| 100 | - if (!strpos ($dbServer['host']['$'], ':')) { |
|
| 100 | + if (!strpos($dbServer['host']['$'], ':')) { |
|
| 101 | 101 | $dbHost = $dbServer['host']['$'] . ':3306'; |
| 102 | 102 | } |
| 103 | 103 | else { |
| 104 | 104 | $dbHost = $dbServer['host']['$']; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - $hostList[$dbHost] =[ |
|
| 107 | + $hostList[$dbHost] = [ |
|
| 108 | 108 | 'host' => $dbHost, |
| 109 | 109 | 'name' => $dbServer['name']['$'], |
| 110 | 110 | 'version' => $dbServer['savedver']['$'], |
@@ -119,13 +119,13 @@ discard block |
||
| 119 | 119 | }); |
| 120 | 120 | |
| 121 | 121 | desc('Take databases list'); |
| 122 | -task('ispmanager:db-list', function () { |
|
| 122 | +task('ispmanager:db-list', function() { |
|
| 123 | 123 | $response = ispmanagerRequest('get', [ |
| 124 | 124 | 'func' => 'db', |
| 125 | 125 | ]); |
| 126 | 126 | |
| 127 | 127 | $dbList = []; |
| 128 | - if (isset ($response['doc']['elem']) && count ($response['doc']['elem']) > 0) { |
|
| 128 | + if (isset ($response['doc']['elem']) && count($response['doc']['elem']) > 0) { |
|
| 129 | 129 | foreach ($response['doc']['elem'] as $db) { |
| 130 | 130 | $dbList[$db['pair']['$']] = [ |
| 131 | 131 | 'name' => $db['name']['$'], |
@@ -141,13 +141,13 @@ discard block |
||
| 141 | 141 | }); |
| 142 | 142 | |
| 143 | 143 | desc('Take domain list'); |
| 144 | -task('ispmanager:domain-list', function () { |
|
| 144 | +task('ispmanager:domain-list', function() { |
|
| 145 | 145 | $response = ispmanagerRequest('get', [ |
| 146 | 146 | 'func' => 'webdomain', |
| 147 | 147 | ]); |
| 148 | 148 | |
| 149 | 149 | $domainList = []; |
| 150 | - if (isset ($response['doc']['elem']) && count ($response['doc']['elem']) > 0) { |
|
| 150 | + if (isset ($response['doc']['elem']) && count($response['doc']['elem']) > 0) { |
|
| 151 | 151 | foreach ($response['doc']['elem'] as $domain) { |
| 152 | 152 | $domainList[] = $domain['name']['$']; |
| 153 | 153 | } |
@@ -157,17 +157,17 @@ discard block |
||
| 157 | 157 | }); |
| 158 | 158 | |
| 159 | 159 | desc('Create new database'); |
| 160 | -task('ispmanager:db-create', function () { |
|
| 161 | - $config = get ('ispmanager'); |
|
| 160 | +task('ispmanager:db-create', function() { |
|
| 161 | + $config = get('ispmanager'); |
|
| 162 | 162 | |
| 163 | - if (is_null ($config['createDatabase'])) { |
|
| 164 | - warning ('Action for database create is not active'); |
|
| 163 | + if (is_null($config['createDatabase'])) { |
|
| 164 | + warning('Action for database create is not active'); |
|
| 165 | 165 | return; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | $dsnData = parse_url($config['createDatabase']['dsn']); |
| 169 | 169 | |
| 170 | - $dbInfo = get ('ispmanager_databases'); |
|
| 170 | + $dbInfo = get('ispmanager_databases'); |
|
| 171 | 171 | |
| 172 | 172 | $hostInfo = NULL; |
| 173 | 173 | foreach ($dbInfo['hosts'] as $hostData) { |
@@ -177,11 +177,11 @@ discard block |
||
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - if (is_null ($hostInfo)) { |
|
| 180 | + if (is_null($hostInfo)) { |
|
| 181 | 181 | throw new Exception('Incorrect DB host'); |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - $dbName = substr ($dsnData['path'], 1); |
|
| 184 | + $dbName = substr($dsnData['path'], 1); |
|
| 185 | 185 | |
| 186 | 186 | $dbLocation = $dbName . '->' . $hostInfo['name']; |
| 187 | 187 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | throw new Exception('Database already exists!'); |
| 191 | 191 | } |
| 192 | 192 | else { |
| 193 | - warning ('Database already exists - skipping'); |
|
| 193 | + warning('Database already exists - skipping'); |
|
| 194 | 194 | return true; |
| 195 | 195 | } |
| 196 | 196 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | $dbCreateRequest['username'] = $dbName; |
| 210 | 210 | |
| 211 | 211 | if ($dsnData['pass'] == '*') { |
| 212 | - $dbCreateRequest['password'] = generatePassword (8); |
|
| 212 | + $dbCreateRequest['password'] = generatePassword(8); |
|
| 213 | 213 | } |
| 214 | 214 | else { |
| 215 | 215 | $dbCreateRequest['password'] = $dsnData['pass']; |
@@ -226,20 +226,20 @@ discard block |
||
| 226 | 226 | throw new Exception($response['doc']['error']['msg']['$']); |
| 227 | 227 | } |
| 228 | 228 | else { |
| 229 | - info ('Database successfully created'); |
|
| 229 | + info('Database successfully created'); |
|
| 230 | 230 | } |
| 231 | 231 | }); |
| 232 | 232 | |
| 233 | 233 | desc('Delete database'); |
| 234 | -task('ispmanager:db-delete', function () { |
|
| 235 | - $config = get ('ispmanager'); |
|
| 234 | +task('ispmanager:db-delete', function() { |
|
| 235 | + $config = get('ispmanager'); |
|
| 236 | 236 | |
| 237 | - if (is_null ($config['deleteDatabase'])) { |
|
| 238 | - warning ('Action for database delete is not active'); |
|
| 237 | + if (is_null($config['deleteDatabase'])) { |
|
| 238 | + warning('Action for database delete is not active'); |
|
| 239 | 239 | return; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - $dbInfo = get ('ispmanager_databases'); |
|
| 242 | + $dbInfo = get('ispmanager_databases'); |
|
| 243 | 243 | $dsnData = parse_url($config['deleteDatabase']['dsn']); |
| 244 | 244 | |
| 245 | 245 | $hostInfo = NULL; |
@@ -250,11 +250,11 @@ discard block |
||
| 250 | 250 | } |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - if (is_null ($hostInfo)) { |
|
| 253 | + if (is_null($hostInfo)) { |
|
| 254 | 254 | throw new Exception('Incorrect DB host'); |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - $dbName = substr ($dsnData['path'], 1); |
|
| 257 | + $dbName = substr($dsnData['path'], 1); |
|
| 258 | 258 | |
| 259 | 259 | $dbLocation = $dbName . '->' . $hostInfo['name']; |
| 260 | 260 | |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | throw new Exception('Database not exist!'); |
| 264 | 264 | } |
| 265 | 265 | else { |
| 266 | - warning ('Database not exist - skipping'); |
|
| 266 | + warning('Database not exist - skipping'); |
|
| 267 | 267 | return true; |
| 268 | 268 | } |
| 269 | 269 | } |
@@ -279,16 +279,16 @@ discard block |
||
| 279 | 279 | throw new Exception($response['doc']['error']['msg']['$']); |
| 280 | 280 | } |
| 281 | 281 | else { |
| 282 | - info ('Database successfully deleted'); |
|
| 282 | + info('Database successfully deleted'); |
|
| 283 | 283 | } |
| 284 | 284 | }); |
| 285 | 285 | |
| 286 | 286 | desc('Create new domain'); |
| 287 | -task('ispmanager:domain-create', function () { |
|
| 288 | - $config = get ('ispmanager'); |
|
| 287 | +task('ispmanager:domain-create', function() { |
|
| 288 | + $config = get('ispmanager'); |
|
| 289 | 289 | |
| 290 | - if (is_null ($config['createDomain'])) { |
|
| 291 | - warning ('Action for domain create is not active'); |
|
| 290 | + if (is_null($config['createDomain'])) { |
|
| 291 | + warning('Action for domain create is not active'); |
|
| 292 | 292 | return; |
| 293 | 293 | } |
| 294 | 294 | |
@@ -297,14 +297,14 @@ discard block |
||
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | // Check domain exists |
| 300 | - $existDomains = get ('ispmanager_domains'); |
|
| 300 | + $existDomains = get('ispmanager_domains'); |
|
| 301 | 301 | |
| 302 | - if (in_array ($config['createDomain']['name'], $existDomains)) { |
|
| 302 | + if (in_array($config['createDomain']['name'], $existDomains)) { |
|
| 303 | 303 | if (!isset ($config['createDomain']['skipIfExist']) || !$config['createDomain']['skipIfExist']) { |
| 304 | 304 | throw new Exception('Domain already exists!'); |
| 305 | 305 | } |
| 306 | 306 | else { |
| 307 | - warning1 ('Domain already exists - skipping'); |
|
| 307 | + warning1('Domain already exists - skipping'); |
|
| 308 | 308 | return true; |
| 309 | 309 | } |
| 310 | 310 | } |
@@ -327,12 +327,12 @@ discard block |
||
| 327 | 327 | throw new Exception($response['doc']['error']['msg']['$']); |
| 328 | 328 | } |
| 329 | 329 | else { |
| 330 | - info ('Domain successfully created'); |
|
| 330 | + info('Domain successfully created'); |
|
| 331 | 331 | } |
| 332 | 332 | }); |
| 333 | 333 | |
| 334 | 334 | desc('Get allowed PHP modes and versions'); |
| 335 | -task('ispmanager:get-php-list', function () { |
|
| 335 | +task('ispmanager:get-php-list', function() { |
|
| 336 | 336 | // Get www-root settings for fpm version |
| 337 | 337 | $response = ispmanagerRequest('get', [ |
| 338 | 338 | 'func' => 'user.edit', |
@@ -378,11 +378,11 @@ discard block |
||
| 378 | 378 | }); |
| 379 | 379 | |
| 380 | 380 | desc('Print allowed PHP modes and versions'); |
| 381 | -task('ispmanager:print-php-list', function () { |
|
| 381 | +task('ispmanager:print-php-list', function() { |
|
| 382 | 382 | invoke('ispmanager:get-php-list'); |
| 383 | 383 | |
| 384 | 384 | $versions = get('ispmanager_phplist'); |
| 385 | - writeln ("PHP versions: "); |
|
| 385 | + writeln("PHP versions: "); |
|
| 386 | 386 | writeln(str_repeat('*', 32)); |
| 387 | 387 | foreach ($versions as $versionKey => $versionData) { |
| 388 | 388 | writeln('PHP ' . $versionData['name'] . ' (ID: ' . $versionKey . ')'); |
@@ -420,11 +420,11 @@ discard block |
||
| 420 | 420 | }); |
| 421 | 421 | |
| 422 | 422 | desc('Switch PHP version for domain'); |
| 423 | -task('ispmanager:domain-php-select', function () { |
|
| 424 | - $config = get ('ispmanager'); |
|
| 423 | +task('ispmanager:domain-php-select', function() { |
|
| 424 | + $config = get('ispmanager'); |
|
| 425 | 425 | |
| 426 | - if (is_null ($config['phpSelect'])) { |
|
| 427 | - warning ('Action for domain update is not active'); |
|
| 426 | + if (is_null($config['phpSelect'])) { |
|
| 427 | + warning('Action for domain update is not active'); |
|
| 428 | 428 | return; |
| 429 | 429 | } |
| 430 | 430 | |
@@ -432,9 +432,9 @@ discard block |
||
| 432 | 432 | throw new Exception('Invalid domain name!'); |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | - $existDomains = get ('ispmanager_domains'); |
|
| 435 | + $existDomains = get('ispmanager_domains'); |
|
| 436 | 436 | |
| 437 | - if (!in_array ($config['phpSelect']['name'], $existDomains)) { |
|
| 437 | + if (!in_array($config['phpSelect']['name'], $existDomains)) { |
|
| 438 | 438 | throw new Exception('Domain not exist!'); |
| 439 | 439 | } |
| 440 | 440 | |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | return; |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | - $phpVersions = get ('ispmanager_phplist'); |
|
| 446 | + $phpVersions = get('ispmanager_phplist'); |
|
| 447 | 447 | |
| 448 | 448 | $newVersion = $config['phpSelect']['version']; |
| 449 | 449 | $newMode = $config['phpSelect']['mode']; |
@@ -491,16 +491,16 @@ discard block |
||
| 491 | 491 | throw new Exception($response['doc']['error']['msg']['$']); |
| 492 | 492 | } |
| 493 | 493 | else { |
| 494 | - info ('PHP successfully selected'); |
|
| 494 | + info('PHP successfully selected'); |
|
| 495 | 495 | } |
| 496 | 496 | }); |
| 497 | 497 | |
| 498 | 498 | desc('Create new domain alias'); |
| 499 | -task('ispmanager:domain-alias-create', function () { |
|
| 500 | - $config = get ('ispmanager'); |
|
| 499 | +task('ispmanager:domain-alias-create', function() { |
|
| 500 | + $config = get('ispmanager'); |
|
| 501 | 501 | |
| 502 | - if (is_null ($config['createAlias'])) { |
|
| 503 | - warning ('Action for alias create is not active'); |
|
| 502 | + if (is_null($config['createAlias'])) { |
|
| 503 | + warning('Action for alias create is not active'); |
|
| 504 | 504 | return; |
| 505 | 505 | } |
| 506 | 506 | |
@@ -508,9 +508,9 @@ discard block |
||
| 508 | 508 | throw new Exception('Invalid domain name!'); |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | - $existDomains = get ('ispmanager_domains'); |
|
| 511 | + $existDomains = get('ispmanager_domains'); |
|
| 512 | 512 | |
| 513 | - if (!in_array ($config['createAlias']['name'], $existDomains)) { |
|
| 513 | + if (!in_array($config['createAlias']['name'], $existDomains)) { |
|
| 514 | 514 | throw new Exception('Domain not exist!'); |
| 515 | 515 | } |
| 516 | 516 | |
@@ -527,18 +527,18 @@ discard block |
||
| 527 | 527 | |
| 528 | 528 | $existAliases = []; |
| 529 | 529 | if (isset ($response['doc']['aliases']['$'])) { |
| 530 | - $existAliases = explode (' ', $response['doc']['aliases']['$']); |
|
| 530 | + $existAliases = explode(' ', $response['doc']['aliases']['$']); |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | $newAliasList = []; |
| 534 | - $createAliasList = explode (' ', $config['createAlias']['alias']); |
|
| 534 | + $createAliasList = explode(' ', $config['createAlias']['alias']); |
|
| 535 | 535 | foreach ($createAliasList as $createAlias) { |
| 536 | - if (in_array ($createAlias, $existAliases)) { |
|
| 536 | + if (in_array($createAlias, $existAliases)) { |
|
| 537 | 537 | if (!isset ($config['createAlias']['skipIfExist']) || !$config['createAlias']['skipIfExist']) { |
| 538 | 538 | throw new Exception('Alias already exists!'); |
| 539 | 539 | } |
| 540 | 540 | else { |
| 541 | - warning ('Alias ' . $createAlias . ' already exists - skipping'); |
|
| 541 | + warning('Alias ' . $createAlias . ' already exists - skipping'); |
|
| 542 | 542 | continue; |
| 543 | 543 | } |
| 544 | 544 | } |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | 'func' => 'webdomain.edit', |
| 553 | 553 | 'elid' => $config['createAlias']['name'], |
| 554 | 554 | 'name' => $config['createAlias']['name'], |
| 555 | - 'aliases' => implode (' ', $saveAliases), |
|
| 555 | + 'aliases' => implode(' ', $saveAliases), |
|
| 556 | 556 | 'sok' => 'ok', |
| 557 | 557 | ]; |
| 558 | 558 | |
@@ -562,16 +562,16 @@ discard block |
||
| 562 | 562 | throw new Exception($response['doc']['error']['msg']['$']); |
| 563 | 563 | } |
| 564 | 564 | else { |
| 565 | - info ('Alias successfully created'); |
|
| 565 | + info('Alias successfully created'); |
|
| 566 | 566 | } |
| 567 | 567 | }); |
| 568 | 568 | |
| 569 | 569 | desc('Delete domain alias'); |
| 570 | -task('ispmanager:domain-alias-delete', function () { |
|
| 571 | - $config = get ('ispmanager'); |
|
| 570 | +task('ispmanager:domain-alias-delete', function() { |
|
| 571 | + $config = get('ispmanager'); |
|
| 572 | 572 | |
| 573 | - if (is_null ($config['deleteAlias'])) { |
|
| 574 | - warning ('Action for alias create is not active'); |
|
| 573 | + if (is_null($config['deleteAlias'])) { |
|
| 574 | + warning('Action for alias create is not active'); |
|
| 575 | 575 | return; |
| 576 | 576 | } |
| 577 | 577 | |
@@ -579,9 +579,9 @@ discard block |
||
| 579 | 579 | throw new Exception('Invalid domain name!'); |
| 580 | 580 | } |
| 581 | 581 | |
| 582 | - $existDomains = get ('ispmanager_domains'); |
|
| 582 | + $existDomains = get('ispmanager_domains'); |
|
| 583 | 583 | |
| 584 | - if (!in_array ($config['deleteAlias']['name'], $existDomains)) { |
|
| 584 | + if (!in_array($config['deleteAlias']['name'], $existDomains)) { |
|
| 585 | 585 | throw new Exception('Domain not exist!'); |
| 586 | 586 | } |
| 587 | 587 | |
@@ -598,22 +598,22 @@ discard block |
||
| 598 | 598 | |
| 599 | 599 | $existAliases = []; |
| 600 | 600 | if (isset ($response['doc']['aliases']['$'])) { |
| 601 | - $existAliases = explode (' ', $response['doc']['aliases']['$']); |
|
| 601 | + $existAliases = explode(' ', $response['doc']['aliases']['$']); |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | - $deleteAliasList = explode (' ', $config['deleteAlias']['alias']); |
|
| 604 | + $deleteAliasList = explode(' ', $config['deleteAlias']['alias']); |
|
| 605 | 605 | foreach ($deleteAliasList as $deleteAlias) { |
| 606 | 606 | if (!in_array($deleteAlias, $existAliases)) { |
| 607 | 607 | if (!isset ($config['deleteAlias']['skipIfNotExist']) || !$config['deleteAlias']['skipIfNotExist']) { |
| 608 | 608 | throw new Exception('Alias not exist!'); |
| 609 | 609 | } |
| 610 | 610 | else { |
| 611 | - warning ('Alias ' . $deleteAlias . ' not exist - skipping'); |
|
| 611 | + warning('Alias ' . $deleteAlias . ' not exist - skipping'); |
|
| 612 | 612 | continue; |
| 613 | 613 | } |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | - if (($index = array_search ($deleteAlias, $existAliases))!== FALSE){ |
|
| 616 | + if (($index = array_search($deleteAlias, $existAliases)) !== FALSE) { |
|
| 617 | 617 | unset ($existAliases[$index]); |
| 618 | 618 | } |
| 619 | 619 | } |
@@ -622,7 +622,7 @@ discard block |
||
| 622 | 622 | 'func' => 'webdomain.edit', |
| 623 | 623 | 'elid' => $config['deleteAlias']['name'], |
| 624 | 624 | 'name' => $config['deleteAlias']['name'], |
| 625 | - 'aliases' => implode (' ', $existAliases), |
|
| 625 | + 'aliases' => implode(' ', $existAliases), |
|
| 626 | 626 | 'sok' => 'ok', |
| 627 | 627 | ]; |
| 628 | 628 | |
@@ -632,16 +632,16 @@ discard block |
||
| 632 | 632 | throw new Exception($response['doc']['error']['msg']['$']); |
| 633 | 633 | } |
| 634 | 634 | else { |
| 635 | - info ('Alias successfully deleted'); |
|
| 635 | + info('Alias successfully deleted'); |
|
| 636 | 636 | } |
| 637 | 637 | }); |
| 638 | 638 | |
| 639 | 639 | desc('Delete domain'); |
| 640 | -task('ispmanager:domain-delete', function () { |
|
| 641 | - $config = get ('ispmanager'); |
|
| 640 | +task('ispmanager:domain-delete', function() { |
|
| 641 | + $config = get('ispmanager'); |
|
| 642 | 642 | |
| 643 | - if (is_null ($config['deleteDomain'])) { |
|
| 644 | - warning ('Action for domain delete is not active'); |
|
| 643 | + if (is_null($config['deleteDomain'])) { |
|
| 644 | + warning('Action for domain delete is not active'); |
|
| 645 | 645 | return; |
| 646 | 646 | } |
| 647 | 647 | |
@@ -650,14 +650,14 @@ discard block |
||
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | // Check domain exists |
| 653 | - $existDomains = get ('ispmanager_domains'); |
|
| 653 | + $existDomains = get('ispmanager_domains'); |
|
| 654 | 654 | |
| 655 | - if (!in_array ($config['deleteDomain']['name'], $existDomains)) { |
|
| 655 | + if (!in_array($config['deleteDomain']['name'], $existDomains)) { |
|
| 656 | 656 | if (!isset ($config['deleteDomain']['skipIfNotExist']) || !$config['deleteDomain']['skipIfNotExist']) { |
| 657 | 657 | throw new Exception('Domain not exist!'); |
| 658 | 658 | } |
| 659 | 659 | else { |
| 660 | - warning ('Domain not exist - skipping'); |
|
| 660 | + warning('Domain not exist - skipping'); |
|
| 661 | 661 | return true; |
| 662 | 662 | } |
| 663 | 663 | } |
@@ -682,56 +682,56 @@ discard block |
||
| 682 | 682 | throw new Exception($response['doc']['error']['msg']['$']); |
| 683 | 683 | } |
| 684 | 684 | else { |
| 685 | - info ('Domain successfully deleted'); |
|
| 685 | + info('Domain successfully deleted'); |
|
| 686 | 686 | } |
| 687 | 687 | }); |
| 688 | 688 | |
| 689 | 689 | desc('Auto task processing'); |
| 690 | -task('ispmanager:process', function () { |
|
| 691 | - $config = get ('ispmanager'); |
|
| 690 | +task('ispmanager:process', function() { |
|
| 691 | + $config = get('ispmanager'); |
|
| 692 | 692 | |
| 693 | - if (!is_null ($config['createDatabase'])) { |
|
| 693 | + if (!is_null($config['createDatabase'])) { |
|
| 694 | 694 | invoke('ispmanager:db-create'); |
| 695 | 695 | } |
| 696 | 696 | |
| 697 | - if (!is_null ($config['deleteDatabase'])) { |
|
| 697 | + if (!is_null($config['deleteDatabase'])) { |
|
| 698 | 698 | invoke('ispmanager:db-delete'); |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | - if (!is_null ($config['createDomain'])) { |
|
| 701 | + if (!is_null($config['createDomain'])) { |
|
| 702 | 702 | invoke('ispmanager:domain-create'); |
| 703 | 703 | } |
| 704 | 704 | |
| 705 | - if (!is_null ($config['deleteDomain'])) { |
|
| 705 | + if (!is_null($config['deleteDomain'])) { |
|
| 706 | 706 | invoke('ispmanager:domain-delete'); |
| 707 | 707 | } |
| 708 | 708 | |
| 709 | - if (!is_null ($config['phpSelect'])) { |
|
| 709 | + if (!is_null($config['phpSelect'])) { |
|
| 710 | 710 | invoke('ispmanager:domain-php-select'); |
| 711 | 711 | } |
| 712 | 712 | |
| 713 | - if (!is_null ($config['createAlias'])) { |
|
| 713 | + if (!is_null($config['createAlias'])) { |
|
| 714 | 714 | invoke('ispmanager:domain-alias-create'); |
| 715 | 715 | } |
| 716 | 716 | |
| 717 | - if (!is_null ($config['deleteAlias'])) { |
|
| 717 | + if (!is_null($config['deleteAlias'])) { |
|
| 718 | 718 | invoke('ispmanager:domain-alias-delete'); |
| 719 | 719 | } |
| 720 | 720 | }); |
| 721 | 721 | |
| 722 | -function ispmanagerRequest ($method, $requestData) { |
|
| 723 | - $config = get ('ispmanager'); |
|
| 722 | +function ispmanagerRequest($method, $requestData) { |
|
| 723 | + $config = get('ispmanager'); |
|
| 724 | 724 | $dsnData = parse_url($config['api']['dsn']); |
| 725 | 725 | |
| 726 | 726 | $requestUrl = $dsnData['scheme'] . '://' . $dsnData['host'] . ':' . $dsnData['port'] . $dsnData['path']; |
| 727 | 727 | |
| 728 | 728 | if ($config['api']['secure'] && get('ispmanager_session') == '') { |
| 729 | - ispmanagerAuthRequest ($requestUrl, $dsnData['user'], $dsnData['pass']); |
|
| 729 | + ispmanagerAuthRequest($requestUrl, $dsnData['user'], $dsnData['pass']); |
|
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | if ($method == 'post') { |
| 733 | 733 | return Httpie::post($requestUrl) |
| 734 | - ->form (prepareRequest($requestData)) |
|
| 734 | + ->form(prepareRequest($requestData)) |
|
| 735 | 735 | ->setopt(CURLOPT_SSL_VERIFYPEER, false) |
| 736 | 736 | ->setopt(CURLOPT_SSL_VERIFYHOST, false) |
| 737 | 737 | ->getJson(); |
@@ -748,7 +748,7 @@ discard block |
||
| 748 | 748 | } |
| 749 | 749 | } |
| 750 | 750 | |
| 751 | -function ispmanagerAuthRequest ($url, $login, $pass) { |
|
| 751 | +function ispmanagerAuthRequest($url, $login, $pass) { |
|
| 752 | 752 | $authRequestData = [ |
| 753 | 753 | 'func' => 'auth', |
| 754 | 754 | 'username' => $login, |
@@ -758,7 +758,7 @@ discard block |
||
| 758 | 758 | $responseData = Httpie::post($url) |
| 759 | 759 | ->setopt(CURLOPT_SSL_VERIFYPEER, false) |
| 760 | 760 | ->setopt(CURLOPT_SSL_VERIFYHOST, false) |
| 761 | - ->form (prepareRequest($authRequestData)) |
|
| 761 | + ->form(prepareRequest($authRequestData)) |
|
| 762 | 762 | ->getJson(); |
| 763 | 763 | |
| 764 | 764 | if (isset ($responseData['doc']['auth']['$id'])) { |
@@ -769,8 +769,8 @@ discard block |
||
| 769 | 769 | } |
| 770 | 770 | } |
| 771 | 771 | |
| 772 | -function prepareRequest ($requestData) { |
|
| 773 | - $config = get ('ispmanager'); |
|
| 772 | +function prepareRequest($requestData) { |
|
| 773 | + $config = get('ispmanager'); |
|
| 774 | 774 | $dsnData = parse_url($config['api']['dsn']); |
| 775 | 775 | |
| 776 | 776 | if (!isset ($requestData['out'])) { |
@@ -789,8 +789,8 @@ discard block |
||
| 789 | 789 | return $requestData; |
| 790 | 790 | } |
| 791 | 791 | |
| 792 | -function generatePassword ($lenght) { |
|
| 793 | - return substr (md5(uniqid()), 0, $lenght); |
|
| 792 | +function generatePassword($lenght) { |
|
| 793 | + return substr(md5(uniqid()), 0, $lenght); |
|
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | // Callbacks before actions under domains |
@@ -99,8 +99,7 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | if (!strpos ($dbServer['host']['$'], ':')) { |
| 101 | 101 | $dbHost = $dbServer['host']['$'] . ':3306'; |
| 102 | - } |
|
| 103 | - else { |
|
| 102 | + } else { |
|
| 104 | 103 | $dbHost = $dbServer['host']['$']; |
| 105 | 104 | } |
| 106 | 105 | |
@@ -188,8 +187,7 @@ discard block |
||
| 188 | 187 | if (isset ($dbInfo['dblist'][$dbLocation])) { |
| 189 | 188 | if (!isset ($config['createDatabase']['skipIfExist']) || !$config['createDatabase']['skipIfExist']) { |
| 190 | 189 | throw new Exception('Database already exists!'); |
| 191 | - } |
|
| 192 | - else { |
|
| 190 | + } else { |
|
| 193 | 191 | warning ('Database already exists - skipping'); |
| 194 | 192 | return true; |
| 195 | 193 | } |
@@ -210,12 +208,10 @@ discard block |
||
| 210 | 208 | |
| 211 | 209 | if ($dsnData['pass'] == '*') { |
| 212 | 210 | $dbCreateRequest['password'] = generatePassword (8); |
| 213 | - } |
|
| 214 | - else { |
|
| 211 | + } else { |
|
| 215 | 212 | $dbCreateRequest['password'] = $dsnData['pass']; |
| 216 | 213 | } |
| 217 | - } |
|
| 218 | - else { |
|
| 214 | + } else { |
|
| 219 | 215 | $dbCreateRequest['user'] = $dsnData['user']; |
| 220 | 216 | } |
| 221 | 217 | |
@@ -224,8 +220,7 @@ discard block |
||
| 224 | 220 | |
| 225 | 221 | if (isset ($response['doc']['error']['msg']['$'])) { |
| 226 | 222 | throw new Exception($response['doc']['error']['msg']['$']); |
| 227 | - } |
|
| 228 | - else { |
|
| 223 | + } else { |
|
| 229 | 224 | info ('Database successfully created'); |
| 230 | 225 | } |
| 231 | 226 | }); |
@@ -261,8 +256,7 @@ discard block |
||
| 261 | 256 | if (!isset ($dbInfo['dblist'][$dbLocation])) { |
| 262 | 257 | if (!isset ($config['deleteDatabase']['skipIfNotExist']) || !$config['deleteDatabase']['skipIfNotExist']) { |
| 263 | 258 | throw new Exception('Database not exist!'); |
| 264 | - } |
|
| 265 | - else { |
|
| 259 | + } else { |
|
| 266 | 260 | warning ('Database not exist - skipping'); |
| 267 | 261 | return true; |
| 268 | 262 | } |
@@ -277,8 +271,7 @@ discard block |
||
| 277 | 271 | |
| 278 | 272 | if (isset ($response['doc']['error']['msg']['$'])) { |
| 279 | 273 | throw new Exception($response['doc']['error']['msg']['$']); |
| 280 | - } |
|
| 281 | - else { |
|
| 274 | + } else { |
|
| 282 | 275 | info ('Database successfully deleted'); |
| 283 | 276 | } |
| 284 | 277 | }); |
@@ -302,8 +295,7 @@ discard block |
||
| 302 | 295 | if (in_array ($config['createDomain']['name'], $existDomains)) { |
| 303 | 296 | if (!isset ($config['createDomain']['skipIfExist']) || !$config['createDomain']['skipIfExist']) { |
| 304 | 297 | throw new Exception('Domain already exists!'); |
| 305 | - } |
|
| 306 | - else { |
|
| 298 | + } else { |
|
| 307 | 299 | warning1 ('Domain already exists - skipping'); |
| 308 | 300 | return true; |
| 309 | 301 | } |
@@ -325,8 +317,7 @@ discard block |
||
| 325 | 317 | |
| 326 | 318 | if (isset ($response['doc']['error']['msg']['$'])) { |
| 327 | 319 | throw new Exception($response['doc']['error']['msg']['$']); |
| 328 | - } |
|
| 329 | - else { |
|
| 320 | + } else { |
|
| 330 | 321 | info ('Domain successfully created'); |
| 331 | 322 | } |
| 332 | 323 | }); |
@@ -389,29 +380,25 @@ discard block |
||
| 389 | 380 | writeln(str_repeat('*', 32)); |
| 390 | 381 | if (!$versionData['php_mode_mod']) { |
| 391 | 382 | writeln('Apache module support (php_mode_mod) - <fg=red;options=bold>NO</>'); |
| 392 | - } |
|
| 393 | - else { |
|
| 383 | + } else { |
|
| 394 | 384 | writeln('Apache module support (php_mode_mod) - <fg=green;options=bold>YES</>'); |
| 395 | 385 | } |
| 396 | 386 | |
| 397 | 387 | if (!$versionData['php_mode_cgi']) { |
| 398 | 388 | writeln('CGI support (php_mode_cgi) - <fg=red;options=bold>NO</>'); |
| 399 | - } |
|
| 400 | - else { |
|
| 389 | + } else { |
|
| 401 | 390 | writeln('CGI support (php_mode_cgi) - <fg=green;options=bold>YES</>'); |
| 402 | 391 | } |
| 403 | 392 | |
| 404 | 393 | if (!$versionData['php_mode_fcgi_apache']) { |
| 405 | 394 | writeln('Apache fast-cgi support (php_mode_fcgi_apache) - <fg=red;options=bold>NO</>'); |
| 406 | - } |
|
| 407 | - else { |
|
| 395 | + } else { |
|
| 408 | 396 | writeln('Apache fast-cgi support (php_mode_fcgi_apache) - <fg=green;options=bold>YES</>'); |
| 409 | 397 | } |
| 410 | 398 | |
| 411 | 399 | if (!$versionData['php_mode_fcgi_nginxfpm']) { |
| 412 | 400 | writeln('nginx fast-cgi support (php_mode_fcgi_nginxfpm) - <fg=red;options=bold>NO</>'); |
| 413 | - } |
|
| 414 | - else { |
|
| 401 | + } else { |
|
| 415 | 402 | writeln('nginx fast-cgi support (php_mode_fcgi_nginxfpm) - <fg=green;options=bold>YES</>'); |
| 416 | 403 | } |
| 417 | 404 | |
@@ -469,19 +456,15 @@ discard block |
||
| 469 | 456 | |
| 470 | 457 | if ($newMode == 'php_mode_mod') { |
| 471 | 458 | $domainUpdateRequest['php_apache_version'] = $newVersion; |
| 472 | - } |
|
| 473 | - elseif ($newMode == 'php_mode_cgi') { |
|
| 459 | + } elseif ($newMode == 'php_mode_cgi') { |
|
| 474 | 460 | $domainUpdateRequest['php_cgi_version'] = $newVersion; |
| 475 | - } |
|
| 476 | - elseif ($newMode == 'php_mode_fcgi_apache') { |
|
| 461 | + } elseif ($newMode == 'php_mode_fcgi_apache') { |
|
| 477 | 462 | $domainUpdateRequest['php_cgi_version'] = $newVersion; |
| 478 | 463 | $domainUpdateRequest['php_apache_version'] = $newVersion; |
| 479 | - } |
|
| 480 | - elseif ($newMode == 'php_mode_fcgi_nginxfpm') { |
|
| 464 | + } elseif ($newMode == 'php_mode_fcgi_nginxfpm') { |
|
| 481 | 465 | $domainUpdateRequest['php_cgi_version'] = $newVersion; |
| 482 | 466 | $domainUpdateRequest['php_fpm_version'] = $newVersion; |
| 483 | - } |
|
| 484 | - else { |
|
| 467 | + } else { |
|
| 485 | 468 | throw new Exception('Unknown PHP mode!'); |
| 486 | 469 | } |
| 487 | 470 | |
@@ -489,8 +472,7 @@ discard block |
||
| 489 | 472 | |
| 490 | 473 | if (isset ($response['doc']['error']['msg']['$'])) { |
| 491 | 474 | throw new Exception($response['doc']['error']['msg']['$']); |
| 492 | - } |
|
| 493 | - else { |
|
| 475 | + } else { |
|
| 494 | 476 | info ('PHP successfully selected'); |
| 495 | 477 | } |
| 496 | 478 | }); |
@@ -536,8 +518,7 @@ discard block |
||
| 536 | 518 | if (in_array ($createAlias, $existAliases)) { |
| 537 | 519 | if (!isset ($config['createAlias']['skipIfExist']) || !$config['createAlias']['skipIfExist']) { |
| 538 | 520 | throw new Exception('Alias already exists!'); |
| 539 | - } |
|
| 540 | - else { |
|
| 521 | + } else { |
|
| 541 | 522 | warning ('Alias ' . $createAlias . ' already exists - skipping'); |
| 542 | 523 | continue; |
| 543 | 524 | } |
@@ -560,8 +541,7 @@ discard block |
||
| 560 | 541 | |
| 561 | 542 | if (isset ($response['doc']['error']['msg']['$'])) { |
| 562 | 543 | throw new Exception($response['doc']['error']['msg']['$']); |
| 563 | - } |
|
| 564 | - else { |
|
| 544 | + } else { |
|
| 565 | 545 | info ('Alias successfully created'); |
| 566 | 546 | } |
| 567 | 547 | }); |
@@ -606,8 +586,7 @@ discard block |
||
| 606 | 586 | if (!in_array($deleteAlias, $existAliases)) { |
| 607 | 587 | if (!isset ($config['deleteAlias']['skipIfNotExist']) || !$config['deleteAlias']['skipIfNotExist']) { |
| 608 | 588 | throw new Exception('Alias not exist!'); |
| 609 | - } |
|
| 610 | - else { |
|
| 589 | + } else { |
|
| 611 | 590 | warning ('Alias ' . $deleteAlias . ' not exist - skipping'); |
| 612 | 591 | continue; |
| 613 | 592 | } |
@@ -630,8 +609,7 @@ discard block |
||
| 630 | 609 | |
| 631 | 610 | if (isset ($response['doc']['error']['msg']['$'])) { |
| 632 | 611 | throw new Exception($response['doc']['error']['msg']['$']); |
| 633 | - } |
|
| 634 | - else { |
|
| 612 | + } else { |
|
| 635 | 613 | info ('Alias successfully deleted'); |
| 636 | 614 | } |
| 637 | 615 | }); |
@@ -655,8 +633,7 @@ discard block |
||
| 655 | 633 | if (!in_array ($config['deleteDomain']['name'], $existDomains)) { |
| 656 | 634 | if (!isset ($config['deleteDomain']['skipIfNotExist']) || !$config['deleteDomain']['skipIfNotExist']) { |
| 657 | 635 | throw new Exception('Domain not exist!'); |
| 658 | - } |
|
| 659 | - else { |
|
| 636 | + } else { |
|
| 660 | 637 | warning ('Domain not exist - skipping'); |
| 661 | 638 | return true; |
| 662 | 639 | } |
@@ -671,8 +648,7 @@ discard block |
||
| 671 | 648 | |
| 672 | 649 | if (!isset ($config['deleteDomain']['removeDir']) || !$config['deleteDomain']['removeDir']) { |
| 673 | 650 | $domainDeleteRequest['remove_directory'] = 'off'; |
| 674 | - } |
|
| 675 | - else { |
|
| 651 | + } else { |
|
| 676 | 652 | $domainDeleteRequest['remove_directory'] = 'on'; |
| 677 | 653 | } |
| 678 | 654 | |
@@ -680,8 +656,7 @@ discard block |
||
| 680 | 656 | |
| 681 | 657 | if (isset ($response['doc']['error']['msg']['$'])) { |
| 682 | 658 | throw new Exception($response['doc']['error']['msg']['$']); |
| 683 | - } |
|
| 684 | - else { |
|
| 659 | + } else { |
|
| 685 | 660 | info ('Domain successfully deleted'); |
| 686 | 661 | } |
| 687 | 662 | }); |
@@ -735,15 +710,13 @@ discard block |
||
| 735 | 710 | ->setopt(CURLOPT_SSL_VERIFYPEER, false) |
| 736 | 711 | ->setopt(CURLOPT_SSL_VERIFYHOST, false) |
| 737 | 712 | ->getJson(); |
| 738 | - } |
|
| 739 | - elseif ($method == 'get') { |
|
| 713 | + } elseif ($method == 'get') { |
|
| 740 | 714 | return Httpie::get($requestUrl) |
| 741 | 715 | ->query(prepareRequest($requestData)) |
| 742 | 716 | ->setopt(CURLOPT_SSL_VERIFYPEER, false) |
| 743 | 717 | ->setopt(CURLOPT_SSL_VERIFYHOST, false) |
| 744 | 718 | ->getJson(); |
| 745 | - } |
|
| 746 | - else { |
|
| 719 | + } else { |
|
| 747 | 720 | throw new Exception('Unknown request method'); |
| 748 | 721 | } |
| 749 | 722 | } |
@@ -763,8 +736,7 @@ discard block |
||
| 763 | 736 | |
| 764 | 737 | if (isset ($responseData['doc']['auth']['$id'])) { |
| 765 | 738 | set('ispmanager_session', $responseData['doc']['auth']['$id']); |
| 766 | - } |
|
| 767 | - else { |
|
| 739 | + } else { |
|
| 768 | 740 | throw new Exception('Error while create auth session'); |
| 769 | 741 | } |
| 770 | 742 | } |
@@ -779,8 +751,7 @@ discard block |
||
| 779 | 751 | |
| 780 | 752 | if (!$config['api']['secure']) { |
| 781 | 753 | $requestData['authinfo'] = $dsnData['user'] . ':' . $dsnData['pass']; |
| 782 | - } |
|
| 783 | - else { |
|
| 754 | + } else { |
|
| 784 | 755 | if (get('ispmanager_session') != '') { |
| 785 | 756 | $requestData['auth'] = get('ispmanager_session'); |
| 786 | 757 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | !isset($config['port']) || |
| 30 | 30 | !isset($config['username']) || |
| 31 | 31 | !isset($config['token']) || |
| 32 | - !isset($config['user']) ) { |
|
| 32 | + !isset($config['user'])) { |
|
| 33 | 33 | throw new \RuntimeException("<comment>Please configure CPanel config:</comment> <info>set('cpanel', array('host' => 'xxx.xxx.xxx.xxx:', 'port' => 2087 , 'username' => 'root', 'token' => 'asdfasdf', 'cpaneluser' => 'guy'));</info>"); |
| 34 | 34 | } |
| 35 | 35 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | desc('Creating database though CPanel API'); |
| 62 | -task('cpanel:createdb', function () { |
|
| 62 | +task('cpanel:createdb', function() { |
|
| 63 | 63 | |
| 64 | 64 | $cpanel = getCPanel(); |
| 65 | 65 | $config = get('cpanel', []); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | }); |
| 88 | 88 | |
| 89 | 89 | desc('Creating addon domain though CPanel API'); |
| 90 | -task('cpanel:createaddondomain', function () { |
|
| 90 | +task('cpanel:createaddondomain', function() { |
|
| 91 | 91 | $cpanel = getCPanel(); |
| 92 | 92 | $config = get('cpanel', []); |
| 93 | 93 | $domain = getDomainInfo()['domain']; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | }); |
| 111 | 111 | |
| 112 | 112 | desc('Delete addon domain though CPanel API'); |
| 113 | -task('cpanel:deleteaddondomain', function () { |
|
| 113 | +task('cpanel:deleteaddondomain', function() { |
|
| 114 | 114 | $cpanel = getCPanel(); |
| 115 | 115 | $config = get('cpanel', []); |
| 116 | 116 | $domain = getDomainInfo()['domain']; |
@@ -7,12 +7,12 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | namespace Deployer; |
| 9 | 9 | |
| 10 | -set('bin/npm', function () { |
|
| 10 | +set('bin/npm', function() { |
|
| 11 | 11 | return run('which npm'); |
| 12 | 12 | }); |
| 13 | 13 | |
| 14 | 14 | desc('Install npm packages'); |
| 15 | -task('npm:install', function () { |
|
| 15 | +task('npm:install', function() { |
|
| 16 | 16 | if (has('previous_release')) { |
| 17 | 17 | if (test('[ -d {{previous_release}}/node_modules ]')) { |
| 18 | 18 | run('cp -R {{previous_release}}/node_modules {{release_path}}'); |
@@ -28,6 +28,6 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | desc('Install npm packages with a clean slate'); |
| 31 | -task('npm:ci', function () { |
|
| 31 | +task('npm:ci', function() { |
|
| 32 | 32 | run("cd {{release_path}} && {{bin/npm}} ci"); |
| 33 | 33 | }); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | ]); |
| 35 | 35 | |
| 36 | 36 | desc('Ensure what provision run as root'); |
| 37 | -task('provision:switch-user', function () { |
|
| 37 | +task('provision:switch-user', function() { |
|
| 38 | 38 | run('whoami'); |
| 39 | 39 | if (get('remote_user') !== 'root') { |
| 40 | 40 | set('remote_user', 'root'); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | //Deployer::get()->preTask->add('provision:*', 'provision:switch-user'); |
| 45 | 45 | |
| 46 | 46 | desc('Check pre-required state'); |
| 47 | -task('provision:check', function () { |
|
| 47 | +task('provision:check', function() { |
|
| 48 | 48 | $ok = true; |
| 49 | 49 | if (get('php_version') !== '7.4') { |
| 50 | 50 | $ok = false; |
@@ -65,13 +65,13 @@ discard block |
||
| 65 | 65 | }); |
| 66 | 66 | |
| 67 | 67 | desc('Upgrade all packages'); |
| 68 | -task('provision:upgrade', function () { |
|
| 68 | +task('provision:upgrade', function() { |
|
| 69 | 69 | run('apt-get update'); |
| 70 | 70 | run('apt-get upgrade -y'); |
| 71 | 71 | }); |
| 72 | 72 | |
| 73 | 73 | desc('Install base packages'); |
| 74 | -task('provision:install', function () { |
|
| 74 | +task('provision:install', function() { |
|
| 75 | 75 | $packages = [ |
| 76 | 76 | 'build-essential', |
| 77 | 77 | 'curl', |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | }); |
| 95 | 95 | |
| 96 | 96 | desc('Configure SSH'); |
| 97 | -task('provision:ssh', function () { |
|
| 97 | +task('provision:ssh', function() { |
|
| 98 | 98 | run('sed -i "/PasswordAuthentication yes/d" /etc/ssh/sshd_config'); |
| 99 | 99 | run('echo "" | sudo tee -a /etc/ssh/sshd_config'); |
| 100 | 100 | run('echo "" | sudo tee -a /etc/ssh/sshd_config'); |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | }); |
| 109 | 109 | |
| 110 | 110 | desc('Setup deployer user'); |
| 111 | -task('provision:user:deployer', function () { |
|
| 111 | +task('provision:user:deployer', function() { |
|
| 112 | 112 | if (test('id deployer >/dev/null 2>&1')) { |
| 113 | 113 | info('deployer user already exist'); |
| 114 | 114 | } else { |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | }); |
| 144 | 144 | |
| 145 | 145 | desc('Setup firewall'); |
| 146 | -task('provision:firewall', function () { |
|
| 146 | +task('provision:firewall', function() { |
|
| 147 | 147 | run('ufw allow 22'); |
| 148 | 148 | run('ufw allow 80'); |
| 149 | 149 | run('ufw allow 443'); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | }); |
| 152 | 152 | |
| 153 | 153 | desc('Install PHP packages'); |
| 154 | -task('provision:install:php', function () { |
|
| 154 | +task('provision:install:php', function() { |
|
| 155 | 155 | $packages = [ |
| 156 | 156 | "php-bcmath", |
| 157 | 157 | "php-cli", |
@@ -176,13 +176,13 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | |
| 178 | 178 | desc('Install Composer'); |
| 179 | -task('provision:install:composer', function () { |
|
| 179 | +task('provision:install:composer', function() { |
|
| 180 | 180 | run('curl -sS https://getcomposer.org/installer | php'); |
| 181 | 181 | run('mv composer.phar /usr/local/bin/composer'); |
| 182 | 182 | }); |
| 183 | 183 | |
| 184 | 184 | desc('Configure PHP-CLI'); |
| 185 | -task('provision:config:php-cli', function () { |
|
| 185 | +task('provision:config:php-cli', function() { |
|
| 186 | 186 | run('sudo sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php/{{php_version}}/cli/php.ini'); |
| 187 | 187 | run('sudo sed -i "s/display_errors = .*/display_errors = On/" /etc/php/{{php_version}}/cli/php.ini'); |
| 188 | 188 | run('sudo sed -i "s/memory_limit = .*/memory_limit = 512M/" /etc/php/{{php_version}}/cli/php.ini'); |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | }); |
| 191 | 191 | |
| 192 | 192 | desc('Configure PHP-FPM'); |
| 193 | -task('provision:config:php-fpm', function () { |
|
| 193 | +task('provision:config:php-fpm', function() { |
|
| 194 | 194 | run('sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php/{{php_version}}/fpm/php.ini'); |
| 195 | 195 | run('sed -i "s/display_errors = .*/display_errors = On/" /etc/php/{{php_version}}/fpm/php.ini'); |
| 196 | 196 | run('sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/{{php_version}}/fpm/php.ini'); |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | }); |
| 200 | 200 | |
| 201 | 201 | desc('Configure FPM Pool'); |
| 202 | -task('provision:config:php-fpm:pool', function () { |
|
| 202 | +task('provision:config:php-fpm:pool', function() { |
|
| 203 | 203 | run('sed -i "s/^user = www-data/user = deployer/" /etc/php/{{php_version}}/fpm/pool.d/www.conf'); |
| 204 | 204 | run('sed -i "s/^group = www-data/group = deployer/" /etc/php/{{php_version}}/fpm/pool.d/www.conf'); |
| 205 | 205 | run('sed -i "s/;listen\.owner.*/listen.owner = deployer/" /etc/php/{{php_version}}/fpm/pool.d/www.conf'); |
@@ -209,13 +209,13 @@ discard block |
||
| 209 | 209 | }); |
| 210 | 210 | |
| 211 | 211 | desc('Configure php sessions directory'); |
| 212 | -task('provision:config:php:sessions', function () { |
|
| 212 | +task('provision:config:php:sessions', function() { |
|
| 213 | 213 | run('chmod 733 /var/lib/php/sessions'); |
| 214 | 214 | run('chmod +t /var/lib/php/sessions'); |
| 215 | 215 | }); |
| 216 | 216 | |
| 217 | 217 | desc('Generating DH (Diffie Hellman) key'); |
| 218 | -task('provision:nginx:dhparam', function () { |
|
| 218 | +task('provision:nginx:dhparam', function() { |
|
| 219 | 219 | if (test('[ -f /etc/nginx/dhparams.pem ]')) { |
| 220 | 220 | info('/etc/nginx/dhparams.pem already exist'); |
| 221 | 221 | } else { |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | }); |
| 227 | 227 | |
| 228 | 228 | desc('Install nginx & php-fpm'); |
| 229 | -task('provision:nginx', function () { |
|
| 229 | +task('provision:nginx', function() { |
|
| 230 | 230 | run('systemctl enable nginx.service'); |
| 231 | 231 | |
| 232 | 232 | run('sed -i "s/user www-data;/user deployer;/" /etc/nginx/nginx.conf'); |
@@ -14,16 +14,16 @@ discard block |
||
| 14 | 14 | set('writable_dirs', ['var']); |
| 15 | 15 | set('migrations_config', ''); |
| 16 | 16 | |
| 17 | -set('bin/console', function () { |
|
| 17 | +set('bin/console', function() { |
|
| 18 | 18 | return parse('{{release_path}}/bin/console'); |
| 19 | 19 | }); |
| 20 | 20 | |
| 21 | -set('console_options', function () { |
|
| 21 | +set('console_options', function() { |
|
| 22 | 22 | return '--no-interaction'; |
| 23 | 23 | }); |
| 24 | 24 | |
| 25 | 25 | desc('Migrate database'); |
| 26 | -task('database:migrate', function () { |
|
| 26 | +task('database:migrate', function() { |
|
| 27 | 27 | $options = '--allow-no-migration'; |
| 28 | 28 | if (get('migrations_config') !== '') { |
| 29 | 29 | $options = sprintf('%s --configuration={{release_path}}/{{migrations_config}}', $options); |
@@ -33,12 +33,12 @@ discard block |
||
| 33 | 33 | }); |
| 34 | 34 | |
| 35 | 35 | desc('Clear cache'); |
| 36 | -task('deploy:cache:clear', function () { |
|
| 36 | +task('deploy:cache:clear', function() { |
|
| 37 | 37 | run('{{bin/php}} {{bin/console}} cache:clear {{console_options}} --no-warmup'); |
| 38 | 38 | }); |
| 39 | 39 | |
| 40 | 40 | desc('Warm up cache'); |
| 41 | -task('deploy:cache:warmup', function () { |
|
| 41 | +task('deploy:cache:warmup', function() { |
|
| 42 | 42 | run('{{bin/php}} {{bin/console}} cache:warmup {{console_options}}'); |
| 43 | 43 | }); |
| 44 | 44 | |
@@ -22,14 +22,14 @@ |
||
| 22 | 22 | /** |
| 23 | 23 | * Create plugins' symlinks |
| 24 | 24 | */ |
| 25 | -task('deploy:init', function () { |
|
| 25 | +task('deploy:init', function() { |
|
| 26 | 26 | run('{{release_path}}/bin/cake plugin assets symlink'); |
| 27 | 27 | })->desc('Initialization'); |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Run migrations |
| 31 | 31 | */ |
| 32 | -task('deploy:run_migrations', function () { |
|
| 32 | +task('deploy:run_migrations', function() { |
|
| 33 | 33 | run('{{release_path}}/bin/cake migrations migrate'); |
| 34 | 34 | run('{{release_path}}/bin/cake schema_cache clear'); |
| 35 | 35 | run('{{release_path}}/bin/cake schema_cachebuild'); |