Module: Rigup::InstallUtils
- Included in:
- Cli, DeployBase
- Defined in:
- lib/rigup/install_utils.rb
Instance Method Summary collapse
- #apply_permissions(aPath = nil, aKind = nil) ⇒ Object
- #ensure_link(aTo, aFrom, aUserGroup = nil, aSudo = '') ⇒ Object
- #internal_permissions(aPath, aKind) ⇒ Object
- #make_public_cache_dir(aStartPath) ⇒ Object
-
#override_folder(aFolder, aOverrideFolder = nil, aRemove = true) ⇒ Object
Especially for modifiying behaviour eg.
-
#permissions_for_web(aPath, aUser = nil, aGroup = nil, aHideScm = nil) ⇒ Object
set standard permissions for web sites - readonly for apache user.
-
#permissions_for_web_writable(aPath) ⇒ Object
run this after permissions_for_web() on dirs that need to be writable by group (apache).
- #select_suffixed_file(aFile, aExtendedExtension = false) ⇒ Object
Instance Method Details
#apply_permissions(aPath = nil, aKind = nil) ⇒ Object
71 72 73 74 75 |
# File 'lib/rigup/install_utils.rb', line 71 def (aPath=nil,aKind=nil) aPath ||= @release_path aKind ||= @kind || 'rails' (aPath, aKind) end |
#ensure_link(aTo, aFrom, aUserGroup = nil, aSudo = '') ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/rigup/install_utils.rb', line 77 def ensure_link(aTo,aFrom,aUserGroup=nil,aSudo='') raise "Must supply from" if !aFrom cmd = [] cmd << "#{aSudo} rm -rf #{aFrom}" cmd << "#{aSudo} ln -sf #{aTo} #{aFrom}" cmd << "#{aSudo} chown -h #{aUserGroup} #{aFrom}" if aUserGroup run(cmd.join(' && '),raise: false) end |
#internal_permissions(aPath, aKind) ⇒ Object
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 |
# File 'lib/rigup/install_utils.rb', line 45 def (aPath,aKind) case aKind when 'rails' then (aPath,@user,@group,true) run_for_all("chmod +x",File.join(aPath,'script'),:files) uploads = @shared_path+'/uploads' make_public_cache_dir(uploads) #if File.exists?(uploads) # permissions_for_web(uploads,@user,@group,true) # permissions_for_web_writable(uploads) #end #permissions_for_web_writable("#{aPath}/tmp") make_public_cache_dir("#{aPath}/tmp") 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 when 'spree' then (aPath,'rails') when 'browsercms' then (aPath,'rails') end end |
#make_public_cache_dir(aStartPath) ⇒ Object
86 87 88 89 90 |
# File 'lib/rigup/install_utils.rb', line 86 def make_public_cache_dir(aStartPath) run "#{@context.config[:sudo]} mkdir -p #{aStartPath}" (aStartPath) (aStartPath) end |
#override_folder(aFolder, aOverrideFolder = nil, aRemove = true) ⇒ Object
Especially for modifiying behaviour eg. of FCKEditor without upsetting the standard files eg. create a public_override folder that duplicates the same structure as public, and contains the modified files. On deployment call override_folder(“#@release_path/public”) # equiv to override_folder(“#@release_path/public”, “#@release_path/public_override”) and the files in public_override will be copied over public, then public_override removed
17 18 19 20 21 22 |
# File 'lib/rigup/install_utils.rb', line 17 def override_folder(aFolder,aOverrideFolder=nil,aRemove=true) aFolder = aFolder.desuffix('/') aOverrideFolder ||= (aFolder+'_override') run "#{@context.config[:sudo]} cp -vrf #{aOverrideFolder}/* #{aFolder}/" run "#{@context.config[:sudo]} rm -rf #{aOverrideFolder}" if aRemove end |
#permissions_for_web(aPath, aUser = nil, aGroup = nil, aHideScm = nil) ⇒ Object
set standard permissions for web sites - readonly for apache user
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rigup/install_utils.rb', line 26 def (aPath,aUser=nil,aGroup=nil,aHideScm=nil) aUser ||= @user aGroup ||= @group run "#{@context.config[:sudo]} chown -R #{aUser}:#{aGroup} #{aPath.ensure_suffix('/')}" run_for_all("chmod 755",aPath,:dirs) # !!! perhaps reduce other permissions run_for_all("chmod 644",aPath,:files) run_for_all("chmod g+s",aPath,:dirs) case aHideScm when :svn then run_for_all("chmod -R 700",aPath,:dirs,"*/.svn") end end |
#permissions_for_web_writable(aPath) ⇒ Object
run this after permissions_for_web() on dirs that need to be writable by group (apache)
40 41 42 43 |
# File 'lib/rigup/install_utils.rb', line 40 def (aPath) run "chmod -R g+w #{aPath.ensure_suffix('/')}" run_for_all("chmod -R 700",aPath,:dirs,"*/.svn") end |
#select_suffixed_file(aFile, aExtendedExtension = false) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/rigup/install_utils.rb', line 4 def select_suffixed_file(aFile,aExtendedExtension=false) ext = Buzztools::File.extension(aFile,aExtendedExtension) no_ext = Buzztools::File.no_extension(aFile,aExtendedExtension) dir = File.dirname(aFile) run "#{@context.config[:sudo]} mv -f #{no_ext}.#{@context.config[:stage]}.#{ext} #{aFile}" run "#{@context.config[:sudo]} rm -f #{no_ext}.*.#{ext}" end |