12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/wslave_tools.rb', line 12
def self.set_dev_perms(path = '.')
begin
unless Dir.exist?("#{path}/public/data")
FileUtils.mkdir("#{path}/public/data")
FileUtils.touch("#{path}/public/data/.gitkeep")
end
FileUtils.chown(nil, 'www-data', "#{path}/public/data")
FileUtils.chmod(0775, "#{path}/public/data")
FileUtils.chown(nil, 'www-data', "#{path}/public/wp-content/themes")
FileUtils.chmod(0775, "#{path}/public/wp-content/themes")
FileUtils.chown(nil, 'www-data', "#{path}/public/wp-content/uploads")
FileUtils.chmod(0775, "#{path}/public/wp-content/uploads")
FileUtils.chown(nil, 'www-data', "#{path}/public/wp-content/plugins")
FileUtils.chmod(0775, "#{path}/public/wp-content/plugins")
unless Dir.exist?("#{path}/public/wp-content/upgrade")
FileUtils.mkdir("#{path}/public/wp-content/upgrade")
FileUtils.touch("#{path}/public/wp-content/upgrade/.gitkeep")
end
FileUtils.chown(nil, 'www-data', "#{path}/public/wp-content/upgrade")
FileUtils.chmod(0775, "#{path}/public/wp-content/upgrade")
unless Dir.exist?("#{path}/db")
FileUtils.mkdir("#{path}/db")
end
FileUtils.chown(nil, 'www-data', "#{path}/db")
FileUtils.chmod(0775, "#{path}/db")
unless Dir.exist?("#{path}/db/active")
FileUtils.mkdir("#{path}/db/active")
FileUtils.touch("#{path}/db/active/.gitkeep")
end
FileUtils.chown(nil, 'www-data', "#{path}/db/active")
FileUtils.chmod(0775, "#{path}/db/active")
unless Dir.exist?("#{path}/db/dev")
FileUtils.mkdir("#{path}/db/dev")
FileUtils.touch("#{path}/db/dev/.gitkeep")
end
FileUtils.chown(nil, 'www-data', "#{path}/db/dev")
FileUtils.chmod(0775, "#{path}/db/dev")
unless Dir.exist?("#{path}/db/staging")
FileUtils.mkdir("#{path}/db/staging")
FileUtils.touch("#{path}/db/staging/.gitkeep")
end
FileUtils.chown(nil, 'www-data', "#{path}/db/staging")
FileUtils.chmod(0775, "#{path}/db/staging")
unless Dir.exist?("#{path}/db/production")
FileUtils.mkdir("#{path}/db/production")
FileUtils.touch("#{path}/db/production/.gitkeep")
end
FileUtils.chown(nil, 'www-data', "#{path}/db/production")
FileUtils.chmod(0775, "#{path}/db/production")
rescue Errno::EPERM
puts "!!!WARNING!!! Your user does not belong to the www-data group!\n" \
" >>> Unable to make folders writable for devlopment. <<<\n" \
" >>> You will not be able to edit files or themes in the WP dev container! <<<\n"
end
end
|