rigup 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62efb1ff293f94f8729e1c494fc07e9cfc5d8c80
4
- data.tar.gz: ead2e1620710ed87d57be6f7fe5edcf3e4a4f967
3
+ metadata.gz: 93976958d3e4fb8d72c039d7e8e2386d03db5699
4
+ data.tar.gz: a35ef540e688543b45e2653d5a4052b3b6c2bb0c
5
5
  SHA512:
6
- metadata.gz: f9d33144732cb205306bf335b484dce1b4f84b07dacacbbf979be5234c5d30282e55b4d83440ad8956edd8a99f141b9295c3acda0bcc7c117fd8523f08e70fbd
7
- data.tar.gz: dcc9ed34920e9a6f8fb168e504feba5ce107994b09253fead2fa50760da6ab04165a98142468bda7ff8de7d56f91a5c28f7d6e56b198e49745a5ff49ccbad9aa
6
+ metadata.gz: 42e0879308c9794c7eb0a327a261c27b9c06365f804115e0af3590e2f590df67926c85fc07305f0bc5c5f66a593db93b9c35feae725cc17c65dea601160f8d3f
7
+ data.tar.gz: d09e52aac08a191fb3983fcae42eff3c1c9d0dec57583a01dbb203ab70f39ef654001d4af1db3aee93f250ca29ce3c245a3ea88ab839228e1380487abd5aa84c
data/lib/rigup/cli.rb CHANGED
@@ -18,7 +18,9 @@ module Rigup
18
18
  file_config = YAML.load(String.from_file(f))
19
19
  aConfig.merge!(file_config)
20
20
  end
21
- config = Rigup::Config.new(aConfig.merge(site_dir: @site_dir))
21
+ aConfig = aConfig.merge(site_dir: @site_dir)
22
+ aConfig[:user] ||= ENV['USER']
23
+ config = Rigup::Config.new(aConfig)
22
24
  @context = Rigup::Context.new(
23
25
  config: config,
24
26
  logger: ::Logger.new(STDOUT),
@@ -100,7 +102,7 @@ module Rigup
100
102
  end
101
103
 
102
104
  def link_live
103
- ensure_link(@release_path,File.expand_path(File.join(site_dir,'current')))
105
+ ensure_link(@release_path,File.expand_path(File.join(site_dir,'current')),"#{config[:user]}:#{config[:group]}")
104
106
  end
105
107
 
106
108
  def cleanup
@@ -125,7 +127,6 @@ module Rigup
125
127
  run cmdline
126
128
  end
127
129
  end
128
-
129
130
  end
130
131
 
131
132
  public
@@ -152,6 +153,7 @@ module Rigup
152
153
  def deploy(aPath=nil)
153
154
  init(aPath)
154
155
  update_cache
156
+ #gem 'debugger'; require 'debugger'; debugger
155
157
  release
156
158
  call_release_command(:install) # call install_command if defined eg. defaults to "thor deploy:install" eg. make changes to files
157
159
  call_release_command(:block)
data/lib/rigup/config.rb CHANGED
@@ -11,6 +11,7 @@ module Rigup
11
11
  branch: String,
12
12
  commit: String,
13
13
  stage: 'live', # or 'staging' or 'development'
14
+ sudo: 'sudo',
14
15
  block_command: nil,
15
16
  install_command: 'thor deploy:install',
16
17
  restart_command: 'thor deploy:restart',
data/lib/rigup/context.rb CHANGED
@@ -4,10 +4,6 @@ module Rigup
4
4
  attr_reader :config, :options, :argv, :env, :stdout, :stdin, :stderr, :key_chain, :credentials, :logger, :pwd, :variant
5
5
  attr_writer :pwd
6
6
 
7
- def sudo
8
- ''
9
- end
10
-
11
7
  def initialize(aValues=nil)
12
8
  return if !aValues
13
9
 
@@ -5,8 +5,8 @@ module Rigup
5
5
  ext = Buzztools::File.extension(aFile,aExtendedExtension)
6
6
  no_ext = Buzztools::File.no_extension(aFile,aExtendedExtension)
7
7
  dir = File.dirname(aFile)
8
- run "#{@context.sudo} mv -f #{no_ext}.#{@context.config[:stage]}.#{ext} #{aFile}"
9
- run "#{@context.sudo} rm -f #{no_ext}.*.#{ext}"
8
+ run "#{@context.config[:sudo]} mv -f #{no_ext}.#{@context.config[:stage]}.#{ext} #{aFile}"
9
+ run "#{@context.config[:sudo]} rm -f #{no_ext}.*.#{ext}"
10
10
  end
11
11
 
12
12
  # Especially for modifiying behaviour eg. of FCKEditor without upsetting the standard files
@@ -17,8 +17,8 @@ module Rigup
17
17
  def override_folder(aFolder,aOverrideFolder=nil,aRemove=true)
18
18
  aFolder = aFolder.desuffix('/')
19
19
  aOverrideFolder ||= (aFolder+'_override')
20
- run "#{@context.sudo} cp -vrf #{aOverrideFolder}/* #{aFolder}/"
21
- run "#{@context.sudo} rm -rf #{aOverrideFolder}" if aRemove
20
+ run "#{@context.config[:sudo]} cp -vrf #{aOverrideFolder}/* #{aFolder}/"
21
+ run "#{@context.config[:sudo]} rm -rf #{aOverrideFolder}" if aRemove
22
22
  end
23
23
 
24
24
 
@@ -27,7 +27,7 @@ module Rigup
27
27
  aUser ||= @user
28
28
  aGroup ||= @group
29
29
 
30
- run "#{@context.sudo} chown -R #{aUser}:#{aGroup} #{aPath.ensure_suffix('/')}"
30
+ run "#{@context.config[:sudo]} chown -R #{aUser}:#{aGroup} #{aPath.ensure_suffix('/')}"
31
31
  run_for_all("chmod 755",aPath,:dirs) # !!! perhaps reduce other permissions
32
32
  run_for_all("chmod 644",aPath,:files)
33
33
  run_for_all("chmod g+s",aPath,:dirs)
@@ -59,7 +59,7 @@ module Rigup
59
59
  #permissions_for_web_writable("#{aPath}/tmp")
60
60
  make_public_cache_dir("#{aPath}/tmp")
61
61
 
62
- run "#{@context.sudo} chown #{@apache_user} #{aPath}/config/environment.rb" unless DEV_MODE # very important for passenger, which uses the owner of this file to run as
62
+ run "#{@context.config[:sudo]} chown #{@apache_user} #{aPath}/config/environment.rb" unless DEV_MODE # very important for passenger, which uses the owner of this file to run as
63
63
 
64
64
  when 'spree' then
65
65
  internal_permissions(aPath,'rails')
@@ -80,11 +80,11 @@ module Rigup
80
80
  cmd << "#{aSudo} rm -rf #{aFrom}"
81
81
  cmd << "#{aSudo} ln -sf #{aTo} #{aFrom}"
82
82
  cmd << "#{aSudo} chown -h #{aUserGroup} #{aFrom}" if aUserGroup
83
- run cmd.join(' && ')
83
+ run(cmd.join(' && '),raise: false)
84
84
  end
85
85
 
86
86
  def make_public_cache_dir(aStartPath)
87
- run "#{@context.sudo} mkdir -p #{aStartPath}"
87
+ run "#{@context.config[:sudo]} mkdir -p #{aStartPath}"
88
88
  permissions_for_web(aStartPath)
89
89
  permissions_for_web_writable(aStartPath)
90
90
  end
@@ -1,12 +1,12 @@
1
1
  module Rigup
2
2
  module Runability
3
3
 
4
- def shell
5
- @shell ||= ::Session::Bash.new
4
+ def bash
5
+ @bash ||= ::Session::Bash.new
6
6
  end
7
7
 
8
8
  def pwd
9
- shell.execute("pwd", stdout: nil).first.strip
9
+ bash.execute("pwd", stdout: nil).first.strip
10
10
  end
11
11
 
12
12
  def cd(aPath,&block)
@@ -15,21 +15,24 @@ module Rigup
15
15
  before_path = pwd
16
16
  cd(aPath)
17
17
  yield aPath,before_path
18
+ rescue Exception => e
19
+ @context.logger.info e.message
18
20
  ensure
19
21
  cd(before_path)
20
22
  end
21
23
  else
22
24
  aPath = File.expand_path(aPath)
23
25
  Dir.chdir(aPath)
24
- shell.execute("cd \"#{aPath}\"")
26
+ bash.execute("cd \"#{aPath}\"")
25
27
  end
26
28
  aPath
27
29
  end
28
30
 
29
- def run(aCommand)
31
+ def run(aCommand,aOptions=nil)
32
+ aOptions ||= {}
30
33
  @context.logger.debug aCommand
31
- response,errout = @shell.execute(aCommand,stdout: STDOUT) # ::POpen4::shell(aCommand,aDir || @context.pwd)
32
- raise Error, "Command Failed" unless @shell.exit_status==0
34
+ response,errout = bash.execute(aCommand,stdout: STDOUT) # ::POpen4::shell(aCommand,aDir || @context.pwd)
35
+ raise "Command Failed" unless bash.exit_status==0 or aOptions[:raise]==false
33
36
  return response
34
37
  end
35
38
 
data/lib/rigup/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rigup
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/notes.txt CHANGED
@@ -1,3 +1,11 @@
1
+ Permissions for sudo :
2
+
3
+ > sudo nano /etc/sudoers
4
+ Add "%deploy ALL=NOPASSWD: ALL" after %sudo
5
+
6
+ > groupadd deploy
7
+ > sudo adduser gary deploy
8
+
1
9
  https://github.com/ahoward/wrap
2
10
 
3
11
  https://github.com/ahoward/session/tree/master
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rigup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gary McGhee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-14 00:00:00.000000000 Z
11
+ date: 2014-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler