Guard only if the owner if folder is


#1

how can I add a guard to a folder that says
run only_if the owner of /blahblah/ folder is medya ?


#2

Hi Medya,

You can use File::Stat#uid
http://ruby-doc.org/core-2.2.1/File/Stat.html#method-i-uid

Please consider searching before sending questions like this to the
mailing list :slight_smile:

cheers,

–aj

On Sat, Mar 14, 2015 at 12:01 PM, Medya medya.gh@gmail.com wrote:

how can I add a guard to a folder that says
run only_if the owner of /blahblah/ folder is medya ?


#3

Aj, that is only for UID, that means I means I have to find out another way
to find out Uid of a username which I couldn’t find in ruby libraries

On Fri, Mar 13, 2015 at 6:18 PM, AJ Christensen <aj@junglistheavy.industries

wrote:

Hi Medya,

You can use File::Stat#uid
http://ruby-doc.org/core-2.2.1/File/Stat.html#method-i-uid

Please consider searching before sending questions like this to the
mailing list :slight_smile:

cheers,

–aj

On Sat, Mar 14, 2015 at 12:01 PM, Medya medya.gh@gmail.com wrote:

how can I add a guard to a folder that says
run only_if the owner of /blahblah/ folder is medya ?


#4

try this

require 'etc’
uid = File.stat(‘testfile’).uid
puts 'Owner name: ', Etc.getpwuid(uid).name

On Tue, Mar 17, 2015 at 11:52 AM, Medya medya.gh@gmail.com wrote:

Aj, that is only for UID, that means I means I have to find out another
way to find out Uid of a username which I couldn’t find in ruby libraries

On Fri, Mar 13, 2015 at 6:18 PM, AJ Christensen <
aj@junglistheavy.industries> wrote:

Hi Medya,

You can use File::Stat#uid
http://ruby-doc.org/core-2.2.1/File/Stat.html#method-i-uid

Please consider searching before sending questions like this to the
mailing list :slight_smile:

cheers,

–aj

On Sat, Mar 14, 2015 at 12:01 PM, Medya medya.gh@gmail.com wrote:

how can I add a guard to a folder that says
run only_if the owner of /blahblah/ folder is medya ?


#5

Thanks Jake, only problem is, the code will fail at compile time ( because
during that time recipe hasn’t created any folder yet) so when I try to say
get my owner of that folder, it fails in compile time…

how can I make that ruby code to run after compile phase?

here is my code

list_of_dir_to_enforce.each do |d|
uid = File.stat(d).uid
current_owner =Etc.getpwuid(uid).name
log “current owner is”+current_owner
bash "do something on #{d} " do
not_if current_owner=="medya"
end
end

On Tue, Mar 17, 2015 at 12:59 PM, Jake Plimack jake.plimack@gmail.com
wrote:

try this

require 'etc’
uid = File.stat(‘testfile’).uid
puts 'Owner name: ', Etc.getpwuid(uid).name

On Tue, Mar 17, 2015 at 11:52 AM, Medya medya.gh@gmail.com wrote:

Aj, that is only for UID, that means I means I have to find out another
way to find out Uid of a username which I couldn’t find in ruby libraries

On Fri, Mar 13, 2015 at 6:18 PM, AJ Christensen <
aj@junglistheavy.industries> wrote:

Hi Medya,

You can use File::Stat#uid
http://ruby-doc.org/core-2.2.1/File/Stat.html#method-i-uid

Please consider searching before sending questions like this to the
mailing list :slight_smile:

cheers,

–aj

On Sat, Mar 14, 2015 at 12:01 PM, Medya medya.gh@gmail.com wrote:

how can I add a guard to a folder that says
run only_if the owner of /blahblah/ folder is medya ?