@@ -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 | set('remote_user', get('provision_user')); |
30 | 30 | |
31 | 31 | $dbType = get('db_type'); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | ->limit(1); |
38 | 38 | |
39 | 39 | desc('Provision MySQL'); |
40 | -task('provision:mysql', function () { |
|
40 | +task('provision:mysql', function() { |
|
41 | 41 | run('apt-get install -y mysql-server', ['env' => ['DEBIAN_FRONTEND' => 'noninteractive'], 'timeout' => 900]); |
42 | 42 | run("mysql --user=\"root\" -e \"CREATE USER IF NOT EXISTS '{{db_user}}'@'0.0.0.0' IDENTIFIED BY '%secret%';\"", ['secret' => get('db_password')]); |
43 | 43 | run("mysql --user=\"root\" -e \"CREATE USER IF NOT EXISTS '{{db_user}}'@'%' IDENTIFIED BY '%secret%';\"", ['secret' => get('db_password')]); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | }); |
49 | 49 | |
50 | 50 | desc('Provision MariaDB'); |
51 | -task('provision:mariadb', function () { |
|
51 | +task('provision:mariadb', function() { |
|
52 | 52 | run('apt-get install -y mariadb-server', ['env' => ['DEBIAN_FRONTEND' => 'noninteractive'], 'timeout' => 900]); |
53 | 53 | run("mysql --user=\"root\" -e \"CREATE USER IF NOT EXISTS '{{db_user}}'@'0.0.0.0' IDENTIFIED BY '%secret%';\"", ['secret' => get('db_password')]); |
54 | 54 | run("mysql --user=\"root\" -e \"CREATE USER IF NOT EXISTS '{{db_user}}'@'%' IDENTIFIED BY '%secret%';\"", ['secret' => get('db_password')]); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | }); |
60 | 60 | |
61 | 61 | desc('Provision PostgreSQL'); |
62 | -task('provision:postgresql', function () { |
|
62 | +task('provision:postgresql', function() { |
|
63 | 63 | run('apt-get install -y postgresql postgresql-contrib', ['env' => ['DEBIAN_FRONTEND' => 'noninteractive'], 'timeout' => 900]); |
64 | 64 | run("sudo -u postgres psql <<< $'CREATE DATABASE {{db_name}};'"); |
65 | 65 | run("sudo -u postgres psql <<< $'CREATE USER {{db_user}} WITH ENCRYPTED PASSWORD \'%secret%\';'", ['secret' => get('db_password')]); |
@@ -4,13 +4,13 @@ discard block |
||
4 | 4 | |
5 | 5 | use function Deployer\Support\parse_home_dir; |
6 | 6 | |
7 | -set('sudo_password', function () { |
|
7 | +set('sudo_password', function() { |
|
8 | 8 | return askHiddenResponse(' Password for sudo: '); |
9 | 9 | }); |
10 | 10 | |
11 | 11 | |
12 | 12 | desc('Setups a deployer user'); |
13 | -task('provision:user', function () { |
|
13 | +task('provision:user', function() { |
|
14 | 14 | set('remote_user', get('provision_user')); |
15 | 15 | |
16 | 16 | if (test('id deployer >/dev/null 2>&1')) { |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | |
54 | 54 | desc('Copy public key to remote server'); |
55 | -task('provision:ssh_copy_id', function () { |
|
55 | +task('provision:ssh_copy_id', function() { |
|
56 | 56 | $defaultKeys = [ |
57 | 57 | '~/.ssh/id_rsa.pub', |
58 | 58 | '~/.ssh/id_ed25519.pub', |
@@ -6,16 +6,16 @@ discard block |
||
6 | 6 | |
7 | 7 | use function Deployer\Support\escape_shell_argument; |
8 | 8 | |
9 | -set('domain', function () { |
|
9 | +set('domain', function() { |
|
10 | 10 | return ask(' Domain: ', get('hostname')); |
11 | 11 | }); |
12 | 12 | |
13 | -set('public_path', function () { |
|
13 | +set('public_path', function() { |
|
14 | 14 | return ask(' Public path: ', 'public'); |
15 | 15 | }); |
16 | 16 | |
17 | 17 | desc('Configures a server'); |
18 | -task('provision:server', function () { |
|
18 | +task('provision:server', function() { |
|
19 | 19 | set('remote_user', get('provision_user')); |
20 | 20 | run('usermod -a -G www-data caddy'); |
21 | 21 | run("mkdir -p /var/deployer"); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | })->oncePerNode(); |
25 | 25 | |
26 | 26 | desc('Provision website'); |
27 | -task('provision:website', function () { |
|
27 | +task('provision:website', function() { |
|
28 | 28 | $restoreBecome = become('deployer'); |
29 | 29 | |
30 | 30 | run("[ -d {{deploy_path}} ] || mkdir -p {{deploy_path}}"); |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | })->limit(1); |
69 | 69 | |
70 | 70 | desc('Shows access logs'); |
71 | -task('logs:access', function () { |
|
71 | +task('logs:access', function() { |
|
72 | 72 | run('tail -f {{deploy_path}}/log/access.log'); |
73 | 73 | })->verbose(); |
74 | 74 | |
75 | 75 | desc('Shows caddy syslog'); |
76 | -task('logs:caddy', function () { |
|
76 | +task('logs:caddy', function() { |
|
77 | 77 | run('sudo journalctl -u caddy -f'); |
78 | 78 | })->verbose(); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | |
17 | 17 | // Name of lsb_release like: focal, bionic, etc. |
18 | 18 | // As only Ubuntu 20.04 LTS is supported for provision should be the `focal`. |
19 | -set('lsb_release', function () { |
|
19 | +set('lsb_release', function() { |
|
20 | 20 | return run("lsb_release -s -c"); |
21 | 21 | }); |
22 | 22 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | set('provision_user', 'root'); |
44 | 44 | |
45 | 45 | desc('Checks pre-required state'); |
46 | -task('provision:check', function () { |
|
46 | +task('provision:check', function() { |
|
47 | 47 | set('remote_user', get('provision_user')); |
48 | 48 | |
49 | 49 | $release = run('cat /etc/os-release'); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | })->oncePerNode(); |
69 | 69 | |
70 | 70 | desc('Collects required params'); |
71 | -task('provision:configure', function () { |
|
71 | +task('provision:configure', function() { |
|
72 | 72 | set('remote_user', get('provision_user')); |
73 | 73 | |
74 | 74 | $params = [ |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | |
118 | 118 | desc('Adds repositories and update'); |
119 | -task('provision:update', function () { |
|
119 | +task('provision:update', function() { |
|
120 | 120 | set('remote_user', get('provision_user')); |
121 | 121 | |
122 | 122 | // PHP |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | ->verbose(); |
134 | 134 | |
135 | 135 | desc('Upgrades all packages'); |
136 | -task('provision:upgrade', function () { |
|
136 | +task('provision:upgrade', function() { |
|
137 | 137 | set('remote_user', get('provision_user')); |
138 | 138 | run('apt-get upgrade -y', ['env' => ['DEBIAN_FRONTEND' => 'noninteractive'], 'timeout' => 900]); |
139 | 139 | }) |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | ->verbose(); |
142 | 142 | |
143 | 143 | desc('Installs packages'); |
144 | -task('provision:install', function () { |
|
144 | +task('provision:install', function() { |
|
145 | 145 | set('remote_user', get('provision_user')); |
146 | 146 | $packages = [ |
147 | 147 | 'acl', |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | ->oncePerNode(); |
177 | 177 | |
178 | 178 | desc('Configures the ssh'); |
179 | -task('provision:ssh', function () { |
|
179 | +task('provision:ssh', function() { |
|
180 | 180 | set('remote_user', get('provision_user')); |
181 | 181 | run("sed -i 's/PasswordAuthentication .*/PasswordAuthentication no/' /etc/ssh/sshd_config"); |
182 | 182 | run('ssh-keygen -A'); |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | })->oncePerNode(); |
189 | 189 | |
190 | 190 | desc('Setups a firewall'); |
191 | -task('provision:firewall', function () { |
|
191 | +task('provision:firewall', function() { |
|
192 | 192 | set('remote_user', get('provision_user')); |
193 | 193 | run('ufw allow 22'); |
194 | 194 | run('ufw allow 80'); |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | })->oncePerNode(); |
198 | 198 | |
199 | 199 | desc('Verifies what provision was successful'); |
200 | -task('provision:verify', function () { |
|
200 | +task('provision:verify', function() { |
|
201 | 201 | fetch('{{domain}}', 'get', [], null, $info, true); |
202 | 202 | if ($info['http_code'] === 404) { |
203 | 203 | info("provisioned successfully!"); |
@@ -8,7 +8,7 @@ |
||
8 | 8 | set('node_version', '23.x'); |
9 | 9 | |
10 | 10 | desc('Installs npm packages'); |
11 | -task('provision:node', function () { |
|
11 | +task('provision:node', function() { |
|
12 | 12 | set('remote_user', get('provision_user')); |
13 | 13 | |
14 | 14 | if (has('nodejs_version')) { |
@@ -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 | set('remote_user', get('provision_user')); |
15 | 15 | |
16 | 16 | $version = get('php_version'); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | ->limit(1); |
66 | 66 | |
67 | 67 | desc('Shows php-fpm logs'); |
68 | -task('logs:php-fpm', function () { |
|
68 | +task('logs:php-fpm', function() { |
|
69 | 69 | $fpmLogs = run("ls -1 /var/log | grep fpm"); |
70 | 70 | if (empty($fpmLogs)) { |
71 | 71 | throw new \RuntimeException('No PHP-FPM logs found.'); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | })->verbose(); |
75 | 75 | |
76 | 76 | desc('Installs Composer'); |
77 | -task('provision:composer', function () { |
|
77 | +task('provision:composer', function() { |
|
78 | 78 | run('curl -sS https://getcomposer.org/installer | php'); |
79 | 79 | run('mv composer.phar /usr/local/bin/composer'); |
80 | 80 | })->oncePerNode(); |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | // Defines "what" text for the 'deploy:info' task. |
6 | 6 | // Uses one of the following sources: |
7 | 7 | // 1. Repository name |
8 | -set('what', function () { |
|
8 | +set('what', function() { |
|
9 | 9 | $repo = get('repository'); |
10 | 10 | if (!empty($repo)) { |
11 | 11 | return preg_replace('/\.git$/', '', basename($repo)); |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | // Uses one of the following sources: |
18 | 18 | // 1. Host's stage label |
19 | 19 | // 2. Host's alias |
20 | -set('where', function () { |
|
20 | +set('where', function() { |
|
21 | 21 | $labels = get('labels'); |
22 | 22 | if (isset($labels['stage'])) { |
23 | 23 | return $labels['stage']; |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | }); |
27 | 27 | |
28 | 28 | desc('Displays info about deployment'); |
29 | -task('deploy:info', function () { |
|
29 | +task('deploy:info', function() { |
|
30 | 30 | $releaseName = test('[ -d {{deploy_path}}/.dep ]') ? get('release_name') : 1; |
31 | 31 | |
32 | 32 | info("deploying <fg=green;options=bold>{{what}}</> to <fg=magenta;options=bold>{{where}}</> (release <fg=magenta;options=bold>{$releaseName}</>)"); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | use Deployer\Utility\Httpie; |
64 | 64 | |
65 | -set('rockchat_title', function () { |
|
65 | +set('rockchat_title', function() { |
|
66 | 66 | return get('application', 'Project'); |
67 | 67 | }); |
68 | 68 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | set('rocketchat_failure_text', 'Deploy to *{{where}}* failed'); |
84 | 84 | |
85 | 85 | desc('Notifies RocketChat'); |
86 | -task('rocketchat:notify', function () { |
|
86 | +task('rocketchat:notify', function() { |
|
87 | 87 | if (null === get('rocketchat_webhook')) { |
88 | 88 | return; |
89 | 89 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | }); |
114 | 114 | |
115 | 115 | desc('Notifies RocketChat about deploy finish'); |
116 | -task('rocketchat:notify:success', function () { |
|
116 | +task('rocketchat:notify:success', function() { |
|
117 | 117 | if (null === get('rocketchat_webhook')) { |
118 | 118 | return; |
119 | 119 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | }); |
144 | 144 | |
145 | 145 | desc('Notifies RocketChat about deploy failure'); |
146 | -task('rocketchat:notify:failure', function () { |
|
146 | +task('rocketchat:notify:failure', function() { |
|
147 | 147 | if (null === get('rocketchat_webhook')) { |
148 | 148 | return; |
149 | 149 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | set('rollbar_comment', '_{{user}}_ deploying `{{what}}` to *{{where}}*'); |
28 | 28 | |
29 | 29 | desc('Notifies Rollbar of deployment'); |
30 | -task('rollbar:notify', function () { |
|
30 | +task('rollbar:notify', function() { |
|
31 | 31 | if (!get('rollbar_token', false)) { |
32 | 32 | return; |
33 | 33 | } |