@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | desc('Creates a database on DirectAdmin'); |
76 | -task('directadmin:createdb', function () { |
|
76 | +task('directadmin:createdb', function() { |
|
77 | 77 | $config = getDirectAdminConfig(); |
78 | 78 | |
79 | 79 | if (!is_array($config) || |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | }); |
94 | 94 | |
95 | 95 | desc('Deletes a database on DirectAdmin'); |
96 | -task('directadmin:deletedb', function () { |
|
96 | +task('directadmin:deletedb', function() { |
|
97 | 97 | $config = getDirectAdminConfig(); |
98 | 98 | |
99 | 99 | if (!is_array($config) || |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | }); |
109 | 109 | |
110 | 110 | desc('Creates a domain on DirectAdmin'); |
111 | -task('directadmin:createdomain', function () { |
|
111 | +task('directadmin:createdomain', function() { |
|
112 | 112 | $config = getDirectAdminConfig(); |
113 | 113 | |
114 | 114 | if (!is_array($config) || |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | }); |
127 | 127 | |
128 | 128 | desc('Deletes a domain on DirectAdmin'); |
129 | -task('directadmin:deletedomain', function () { |
|
129 | +task('directadmin:deletedomain', function() { |
|
130 | 130 | $config = getDirectAdminConfig(); |
131 | 131 | |
132 | 132 | if (!is_array($config) || |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | }); |
143 | 143 | |
144 | 144 | desc('Symlink your private_html to public_html'); |
145 | -task('directadmin:symlink-private-html', function () { |
|
145 | +task('directadmin:symlink-private-html', function() { |
|
146 | 146 | $config = getDirectAdminConfig(); |
147 | 147 | |
148 | 148 | if (!is_array($config) || |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | }); |
159 | 159 | |
160 | 160 | desc('Changes the PHP version from a domain'); |
161 | -task('directadmin:php-version', function () { |
|
161 | +task('directadmin:php-version', function() { |
|
162 | 162 | $config = getDirectAdminConfig(); |
163 | 163 | |
164 | 164 | if (!is_array($config) || |
@@ -65,7 +65,7 @@ |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | $m = []; |
68 | - $match = function ($regexp) use ($line, &$m) { |
|
68 | + $match = function($regexp) use ($line, &$m) { |
|
69 | 69 | return preg_match("#$regexp#", $line, $m); |
70 | 70 | }; |
71 | 71 | switch ($state) { |
@@ -73,13 +73,13 @@ |
||
73 | 73 | self::assertEquals([$a, $b, $c], $scriptManager->getTasks('group')); |
74 | 74 | self::assertNull($a->getSelector()); |
75 | 75 | self::assertEquals([[['=', 'stage', ['beta']]]], $b->getSelector()); |
76 | - self::assertEquals([[['=', 'stage', ['alpha', 'beta']],['=', 'role', ['db']]]], $c->getSelector()); |
|
76 | + self::assertEquals([[['=', 'stage', ['alpha', 'beta']], ['=', 'role', ['db']]]], $c->getSelector()); |
|
77 | 77 | |
78 | 78 | $group->select('role=prod'); |
79 | 79 | self::assertEquals([$a, $b, $c], $scriptManager->getTasks('group')); |
80 | 80 | self::assertEquals([[['=', 'role', ['prod']]]], $a->getSelector()); |
81 | - self::assertEquals([[['=', 'stage', ['beta']]],[['=', 'role', ['prod']]]], $b->getSelector()); |
|
82 | - self::assertEquals([[['=', 'stage', ['alpha', 'beta']],['=', 'role', ['db']]],[['=', 'role', ['prod']]]], $c->getSelector()); |
|
81 | + self::assertEquals([[['=', 'stage', ['beta']]], [['=', 'role', ['prod']]]], $b->getSelector()); |
|
82 | + self::assertEquals([[['=', 'stage', ['alpha', 'beta']], ['=', 'role', ['db']]], [['=', 'role', ['prod']]]], $c->getSelector()); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | public function testThrowsExceptionIfTaskCollectionEmpty() |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace Deployer; |
4 | 4 | |
5 | -set('db_type', function () { |
|
5 | +set('db_type', function() { |
|
6 | 6 | $supportedDbTypes = [ |
7 | 7 | 'none', |
8 | 8 | 'mysql', |
@@ -12,20 +12,20 @@ discard block |
||
12 | 12 | return askChoice(' What DB to install? ', $supportedDbTypes, 0); |
13 | 13 | }); |
14 | 14 | |
15 | -set('db_name', function () { |
|
15 | +set('db_name', function() { |
|
16 | 16 | return ask(' DB name: ', 'prod'); |
17 | 17 | }); |
18 | 18 | |
19 | -set('db_user', function () { |
|
19 | +set('db_user', function() { |
|
20 | 20 | return ask(' DB user: ', 'deployer'); |
21 | 21 | }); |
22 | 22 | |
23 | -set('db_password', function () { |
|
23 | +set('db_password', function() { |
|
24 | 24 | return askHiddenResponse(' DB password: '); |
25 | 25 | }); |
26 | 26 | |
27 | 27 | desc('Provision databases'); |
28 | -task('provision:databases', function () { |
|
28 | +task('provision:databases', function() { |
|
29 | 29 | $dbType = get('db_type'); |
30 | 30 | if ($dbType === 'none') { |
31 | 31 | return; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | ->limit(1); |
36 | 36 | |
37 | 37 | desc('Provision MySQL'); |
38 | -task('provision:mysql', function () { |
|
38 | +task('provision:mysql', function() { |
|
39 | 39 | run('apt-get install -y mysql-server', ['env' => ['DEBIAN_FRONTEND' => 'noninteractive'], 'timeout' => 900]); |
40 | 40 | run("mysql --user=\"root\" -e \"CREATE USER IF NOT EXISTS '{{db_user}}'@'0.0.0.0' IDENTIFIED BY '%secret%';\"", ['secret' => get('db_password')]); |
41 | 41 | run("mysql --user=\"root\" -e \"CREATE USER IF NOT EXISTS '{{db_user}}'@'%' IDENTIFIED BY '%secret%';\"", ['secret' => get('db_password')]); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | }); |
47 | 47 | |
48 | 48 | desc('Provision MariaDB'); |
49 | -task('provision:mariadb', function () { |
|
49 | +task('provision:mariadb', function() { |
|
50 | 50 | run('apt-get install -y mariadb-server', ['env' => ['DEBIAN_FRONTEND' => 'noninteractive'], 'timeout' => 900]); |
51 | 51 | run("mysql --user=\"root\" -e \"CREATE USER IF NOT EXISTS '{{db_user}}'@'0.0.0.0' IDENTIFIED BY '%secret%';\"", ['secret' => get('db_password')]); |
52 | 52 | run("mysql --user=\"root\" -e \"CREATE USER IF NOT EXISTS '{{db_user}}'@'%' IDENTIFIED BY '%secret%';\"", ['secret' => get('db_password')]); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | }); |
58 | 58 | |
59 | 59 | desc('Provision PostgreSQL'); |
60 | -task('provision:postgresql', function () { |
|
60 | +task('provision:postgresql', function() { |
|
61 | 61 | run('apt-get install -y postgresql postgresql-contrib', ['env' => ['DEBIAN_FRONTEND' => 'noninteractive'], 'timeout' => 900]); |
62 | 62 | run("sudo -u postgres psql <<< $'CREATE DATABASE {{db_name}};'"); |
63 | 63 | run("sudo -u postgres psql <<< $'CREATE USER {{db_user}} WITH ENCRYPTED PASSWORD \'%secret%\';'", ['secret' => get('db_password')]); |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace Deployer; |
4 | 4 | |
5 | -set('php_version', function () { |
|
5 | +set('php_version', function() { |
|
6 | 6 | $defaultPhpVersion = file_exists('composer.json') |
7 | 7 | ? explode('|', preg_replace('/[^0-9.|]+/', '', json_decode(file_get_contents('composer.json'), true)['require']['php'] ?? '8.3'))[0] |
8 | 8 | : '8.3'; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | }); |
11 | 11 | |
12 | 12 | desc('Installs PHP packages'); |
13 | -task('provision:php', function () { |
|
13 | +task('provision:php', function() { |
|
14 | 14 | $version = get('php_version'); |
15 | 15 | info("Installing PHP $version"); |
16 | 16 | $packages = [ |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | ->limit(1); |
64 | 64 | |
65 | 65 | desc('Shows php-fpm logs'); |
66 | -task('logs:php-fpm', function () { |
|
66 | +task('logs:php-fpm', function() { |
|
67 | 67 | run('tail -f /var/log/fpm-php.www.log'); |
68 | 68 | })->verbose(); |
69 | 69 | |
70 | 70 | desc('Installs Composer'); |
71 | -task('provision:composer', function () { |
|
71 | +task('provision:composer', function() { |
|
72 | 72 | run('curl -sS https://getcomposer.org/installer | php'); |
73 | 73 | run('mv composer.phar /usr/local/bin/composer'); |
74 | 74 | })->oncePerNode(); |
@@ -7,7 +7,7 @@ |
||
7 | 7 | set('node_version', '23.x'); |
8 | 8 | |
9 | 9 | desc('Installs npm packages'); |
10 | -task('provision:node', function () { |
|
10 | +task('provision:node', function() { |
|
11 | 11 | if (has('nodejs_version')) { |
12 | 12 | throw new \RuntimeException('nodejs_version is deprecated, use node_version_version instead.'); |
13 | 13 | } |
@@ -4,16 +4,16 @@ discard block |
||
4 | 4 | |
5 | 5 | namespace Deployer; |
6 | 6 | |
7 | -set('domain', function () { |
|
7 | +set('domain', function() { |
|
8 | 8 | return ask(' Domain: '); |
9 | 9 | }); |
10 | 10 | |
11 | -set('public_path', function () { |
|
11 | +set('public_path', function() { |
|
12 | 12 | return ask(' Public path: ', 'public'); |
13 | 13 | }); |
14 | 14 | |
15 | 15 | desc('Configures a server'); |
16 | -task('provision:server', function () { |
|
16 | +task('provision:server', function() { |
|
17 | 17 | run('usermod -a -G www-data caddy'); |
18 | 18 | $html = <<<'HTML' |
19 | 19 | <!DOCTYPE html> |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | })->oncePerNode(); |
75 | 75 | |
76 | 76 | desc('Provision website'); |
77 | -task('provision:website', function () { |
|
77 | +task('provision:website', function() { |
|
78 | 78 | $restoreBecome = become('deployer'); |
79 | 79 | |
80 | 80 | run("[ -d {{deploy_path}} ] || mkdir -p {{deploy_path}}"); |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | })->limit(1); |
119 | 119 | |
120 | 120 | desc('Shows access logs'); |
121 | -task('logs:access', function () { |
|
121 | +task('logs:access', function() { |
|
122 | 122 | run('tail -f {{deploy_path}}/log/access.log'); |
123 | 123 | })->verbose(); |
124 | 124 | |
125 | 125 | desc('Shows caddy syslog'); |
126 | -task('logs:caddy', function () { |
|
126 | +task('logs:caddy', function() { |
|
127 | 127 | run('sudo journalctl -u caddy -f'); |
128 | 128 | })->verbose(); |
@@ -5,13 +5,13 @@ discard block |
||
5 | 5 | |
6 | 6 | use function Deployer\Support\parse_home_dir; |
7 | 7 | |
8 | -set('sudo_password', function () { |
|
8 | +set('sudo_password', function() { |
|
9 | 9 | return askHiddenResponse(' Password for sudo: '); |
10 | 10 | }); |
11 | 11 | |
12 | 12 | |
13 | 13 | desc('Setups a deployer user'); |
14 | -task('provision:user', function () { |
|
14 | +task('provision:user', function() { |
|
15 | 15 | if (test('id deployer >/dev/null 2>&1')) { |
16 | 16 | // TODO: Check what created deployer user configured correctly. |
17 | 17 | // TODO: Update sudo_password of deployer user. |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | |
53 | 53 | desc('Copy public key to remote server'); |
54 | -task('provision:ssh_copy_id', function () { |
|
54 | +task('provision:ssh_copy_id', function() { |
|
55 | 55 | $defaultKeys = [ |
56 | 56 | '~/.ssh/id_rsa.pub', |
57 | 57 | '~/.ssh/id_ed25519.pub', |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | // Name of lsb_release like: focal, bionic, etc. |
17 | 17 | // As only Ubuntu 20.04 LTS is supported for provision should be the `focal`. |
18 | -set('lsb_release', function () { |
|
18 | +set('lsb_release', function() { |
|
19 | 19 | return run("lsb_release -s -c"); |
20 | 20 | }); |
21 | 21 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | ]); |
40 | 40 | |
41 | 41 | desc('Checks pre-required state'); |
42 | -task('provision:check', function () { |
|
42 | +task('provision:check', function() { |
|
43 | 43 | if (get('remote_user') !== 'root' && get('become') !== 'root') { |
44 | 44 | warning(''); |
45 | 45 | warning('Run provision as root: -o remote_user=root'); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | })->oncePerNode(); |
70 | 70 | |
71 | 71 | desc('Collects required params'); |
72 | -task('provision:configure', function () { |
|
72 | +task('provision:configure', function() { |
|
73 | 73 | $params = [ |
74 | 74 | 'sudo_password', |
75 | 75 | 'domain', |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | |
117 | 117 | desc('Adds repositories and update'); |
118 | -task('provision:update', function () { |
|
118 | +task('provision:update', function() { |
|
119 | 119 | // PHP |
120 | 120 | run('apt-add-repository ppa:ondrej/php -y', ['env' => ['DEBIAN_FRONTEND' => 'noninteractive']]); |
121 | 121 | |
@@ -130,14 +130,14 @@ discard block |
||
130 | 130 | ->verbose(); |
131 | 131 | |
132 | 132 | desc('Upgrades all packages'); |
133 | -task('provision:upgrade', function () { |
|
133 | +task('provision:upgrade', function() { |
|
134 | 134 | run('apt-get upgrade -y', ['env' => ['DEBIAN_FRONTEND' => 'noninteractive'], 'timeout' => 900]); |
135 | 135 | }) |
136 | 136 | ->oncePerNode() |
137 | 137 | ->verbose(); |
138 | 138 | |
139 | 139 | desc('Installs packages'); |
140 | -task('provision:install', function () { |
|
140 | +task('provision:install', function() { |
|
141 | 141 | $packages = [ |
142 | 142 | 'acl', |
143 | 143 | 'apt-transport-https', |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | ->oncePerNode(); |
172 | 172 | |
173 | 173 | desc('Configures the ssh'); |
174 | -task('provision:ssh', function () { |
|
174 | +task('provision:ssh', function() { |
|
175 | 175 | run("sed -i 's/PasswordAuthentication .*/PasswordAuthentication no/' /etc/ssh/sshd_config"); |
176 | 176 | run('ssh-keygen -A'); |
177 | 177 | run('service ssh restart'); |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | })->oncePerNode(); |
183 | 183 | |
184 | 184 | desc('Setups a firewall'); |
185 | -task('provision:firewall', function () { |
|
185 | +task('provision:firewall', function() { |
|
186 | 186 | run('ufw allow 22'); |
187 | 187 | run('ufw allow 80'); |
188 | 188 | run('ufw allow 443'); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | })->oncePerNode(); |
191 | 191 | |
192 | 192 | desc('Verifies what provision was successful'); |
193 | -task('provision:verify', function () { |
|
193 | +task('provision:verify', function() { |
|
194 | 194 | fetch('{{domain}}', 'get', [], null, $info, true); |
195 | 195 | if ($info['http_code'] === 404) { |
196 | 196 | info("provisioned successfully!"); |