|
4 | 4 | require_relative 'assets' |
5 | 5 | require_relative 'deploy_secrets' |
6 | 6 | require_relative 'install_ruby' |
| 7 | +require_relative 'preinstall' |
7 | 8 | require_relative 'restart' |
8 | 9 | require_relative 'revision_logger' |
9 | 10 | require_relative 'ruby_version' |
|
53 | 54 | # sticky; all deployments made within it should be owned by the deployer group too. This |
54 | 55 | # means that e.g. a deployment by "bob.smith" can then be rolled back by "tom.jones". |
55 | 56 | run "mkdir -p #{deploy_to}" |
56 | | - run "chgrp -R deployer #{deploy_to}" |
| 57 | + # Set deployer group for everything created by this user |
| 58 | + # run "chgrp -R deployer #{deploy_to}" |
| 59 | + run "find #{deploy_to} -group #{fetch(:user)} -print0 |xargs -r0 chgrp -h deployer" |
57 | 60 |
|
58 | 61 | # The sticky group will apply automatically to new subdirectories, but |
59 | 62 | # any existing subdirectories will need it manually applying via `-R`. |
60 | | - run "chmod -R g+s #{deploy_to}" |
| 63 | + # run "chmod -R g+s #{deploy_to}" |
| 64 | + run "find #{deploy_to} -user #{fetch(:user)} -type d " \ |
| 65 | + '-not -perm -2000 -print0 |xargs -r0 chmod g+s' |
61 | 66 | end |
62 | 67 |
|
63 | 68 | desc 'Custom tasks to be run once, after the initial `cap setup`' |
|
67 | 72 | run "mkdir -p #{full_path}" |
68 | 73 |
|
69 | 74 | # Allow the application to write into here: |
70 | | - run "chgrp -R #{application_group} #{full_path}" |
71 | | - run "chmod -R g+s #{full_path}" |
| 75 | + # run "chgrp -R #{application_group} #{full_path}" |
| 76 | + # run "chmod -R g+s #{full_path}" |
| 77 | + run "find #{full_path} -user #{fetch(:user)} -not -group #{application_group} " \ |
| 78 | + "-print0 |xargs -r0 chgrp -h #{application_group}" |
| 79 | + run "find #{full_path} -user #{fetch(:user)} -type d " \ |
| 80 | + '-not -perm -2000 -print0 |xargs -r0 chmod g+s' |
72 | 81 | end |
73 | 82 |
|
74 | 83 | fetch(:shared_paths, []).each do |path| |
@@ -185,6 +194,14 @@ def target_ruby_version_for(env) |
185 | 194 | match ? match[:version] : raise('Unrecognized Ruby version!') |
186 | 195 | end |
187 | 196 |
|
| 197 | +def log_deployment_message(msg) |
| 198 | + name = fetch(:deployer_name, capture('id -un').chomp) |
| 199 | + log = File.join(shared_path, 'revisions.log') |
| 200 | + msg = "[#{Time.now}] #{name} #{msg}" # rubocop:disable Rails/TimeZone |
| 201 | + |
| 202 | + run "(test -e #{log} || (touch #{log} && chmod 664 #{log})) && echo #{Shellwords.escape(msg)} >> #{log};" |
| 203 | +end |
| 204 | + |
188 | 205 | def add_target(env, name, app, port, app_user, is_web_server) |
189 | 206 | desc "Deploy to #{env} service #{app_user || 'you'}@#{app}:#{port}" |
190 | 207 | task(name) do |
|
0 commit comments