obs_deploy 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c5cefbf1ffca4ed2d230cd169498f9360900f937066e87191e9a0709fb6a8d4
4
- data.tar.gz: 4b87d73be2eebec73b7a060db49bac63d548f22d4a65bb36247214af1c40d2fb
3
+ metadata.gz: 56e0cc88321f0bc33598a1e3ea3ded2ed35b4d9bead0dc610283f8763c2dd535
4
+ data.tar.gz: 95753db3ab45df12657cd1732e5eb99a90f297a5fe4bfc755faeaface8768e67
5
5
  SHA512:
6
- metadata.gz: db9fdc959797fa2229398817caf16b821e81464e188a16fe6b9be35da1aed74e9fdd2151fb21b0ccb887a07c6b196fe11ce310587c2d53d45dae2939071b47e5
7
- data.tar.gz: 2a8f6ac5f785efb947c4c40f57609c1cb8724fc7d7362bcadc848fc34083cefac99454c6daca47581cc195cd56357e94d97beaa99126c49036045cb32a8fd46a
6
+ metadata.gz: 358cdbc116947e6f1a4138cf3a1bb547758b362f5d46cb6bf0bca2324010ad2ed5c526a16551c0aa35d6fa6d8ab2e2e00dbf27ee7e8da07e290aeea54c18733a
7
+ data.tar.gz: 0a9dfb324d28c6629ddb598e7081c22561d63721f595dd455528b7c83bae324903f6f25985c6fc963dafca3a4bc26b8bdbec2e9a00585762a0ff795ad6b607a2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- obs_deploy (0.2.4)
4
+ obs_deploy (0.2.5)
5
5
  cheetah
6
6
  dry-cli
7
7
  nokogiri
@@ -2,30 +2,56 @@
2
2
 
3
3
  module ObsDeploy
4
4
  class ApacheSysconfig
5
- attr_reader :apache_sysconfig
5
+ attr_reader :path
6
6
 
7
7
  def initialize
8
- @apache_sysconfig = '/etc/sysconfig/apache2'
8
+ @path = '/etc/sysconfig/apache2'
9
9
  end
10
10
 
11
11
  def enable_maintenance_mode
12
- write_apache_sysconfig('APACHE_SERVER_FLAGS="STATUS MAINTENANCE"')
12
+ unless maintenance_mode?
13
+ content = File.read(path).gsub(/^#{server_flags}=\"STATUS\"$/,
14
+ apache_status_line(maintenance))
15
+ write_apache_sysconfig(content)
16
+ end
13
17
  end
14
18
 
15
19
  def disable_maintenance_mode
16
- write_apache_sysconfig('APACHE_SERVER_FLAGS="STATUS"')
20
+ if maintenance_mode?
21
+ content = File.read(path).gsub(/^#{server_flags}=\"STATUS MAINTENANCE\"/,
22
+ apache_status_line(no_maintenance))
23
+ write_apache_sysconfig(content)
24
+ end
17
25
  end
18
26
 
19
27
  def maintenance_mode?
20
- File.open(apache_sysconfig).read.include?('MAINTENANCE')
28
+ find_server_flags.all? { |r| r.include?('MAINTENANCE') }
21
29
  end
22
30
 
23
31
  private
24
32
 
25
- def write_apache_sysconfig(line)
26
- File.open(apache_sysconfig, 'w') do |file|
27
- file.write(line)
28
- end
33
+ def no_maintenance
34
+ 'STATUS'
35
+ end
36
+
37
+ def maintenance
38
+ 'STATUS MAINTENANCE'
39
+ end
40
+
41
+ def server_flags
42
+ 'APACHE_SERVER_FLAGS'
43
+ end
44
+
45
+ def apache_status_line(status)
46
+ "#{server_flags}=\"#{status}\""
47
+ end
48
+
49
+ def find_server_flags
50
+ File.readlines(path).grep(/^#{server_flags}=/)
51
+ end
52
+
53
+ def write_apache_sysconfig(content)
54
+ File.open(path, 'wb') { |file| file.write(content) }
29
55
  end
30
56
  end
31
57
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ObsDeploy
4
- VERSION = '0.2.4'
4
+ VERSION = '0.2.5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obs_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pereira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-28 00:00:00.000000000 Z
11
+ date: 2020-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler