methods/in_common.rb
# Check if a directory exists
# If not create it
Check if a directory exists
If not create it
Check if a directory exists If not create it
def check_dir_exists(options,dir_name)
  output = ""
  dir_name = dir_name.to_s
  if !File.directory?(dir_name) && !File.symlink?(dir_name)
    if dir_name.match(/[a-z]|[A-Z]/)
      message = "Information:\tCreating: "+dir_name
      if dir_name.match(/^\/etc/)
        command = "sudo mkdir -p \"#{dir_name}\""
      else
        command = "mkdir -p \"#{dir_name}\""
      end
      output  = execute_command(options,message,command)
    end
  end
  return output
end
def check_dir_exists ( options , dir_name ) output = "" dir_name = dir_name . to_s if ! File . directory? ( dir_name ) && ! File . symlink? ( dir_name ) if dir_name . match ( / [a-z]|[A-Z] / ) message = "Information:\tCreating: " + dir_name if dir_name . match ( / ^ \/ etc / ) command = "sudo mkdir -p \"#{dir_name}\"" else command = "mkdir -p \"#{dir_name}\"" end output = execute_command ( options , message , command ) end end return output end
Check if a directory exists
If not create it
Check if a directory exists If not create it
options
<not_specific>
dir_name
<not_specific>