Top Level Namespace

Defined Under Namespace

Modules: Apt, Deprec2, Emerge, Gem, Std

Constant Summary collapse

OK =

Exit status

0
WARNING =
1
CRITICAL =
2

Instance Method Summary collapse

Instance Method Details

#accept_licenseObject



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/deprec/recipes/java.rb', line 1

def accept_license
  # don't ask to accept the license if already preset
  return if java_dlj_11_license_accepted
  in_license = false
  # read license text from bottom of this file
  Capistrano::CLI.ui.say(IO.readlines(__FILE__).collect do |line|
    in_license = false if line =~ /^# END_LICENSE/
    current_line = in_license ? line.strip.gsub(/^#[ ]?/, '') : nil  
    in_license = true if line =~ /^# START_LICENSE/
    current_line
  end.compact.join("\n"))
  # ask whether user accepts the license
  prompt = "Accept license (YES, [NO])?  "
  answer = Capistrano::CLI.ui.ask(prompt) do |q|
    q.overwrite = false
    q.default = 'NO'
    q.validate = /(yes)|(no)|\n/i
    q.responses[:not_valid] = prompt
  end
  # set variable to true if license is accepted
  if answer.upcase == 'YES'
    set :java_dlj_11_license_accepted, true
  end
end

#chdir_cwdObject



20
21
22
23
24
25
# File 'lib/deprec/templates/nagios/check_mongrel_cluster.rb', line 20

def chdir_cwd
  pwd = Dir.pwd
  Dir.chdir(@options["cwd"]) if @options["cwd"]     
  yield
  Dir.chdir(pwd) if @options["cwd"]
end

#read_pid(port) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/deprec/templates/nagios/check_mongrel_cluster.rb', line 27

def read_pid(port)
  pid_file = port_pid_file(port)
  pid = 0
  chdir_cwd do     
    pid = File.read(pid_file)
  end
  pid
end

#run_mysql_command(command, user = "root", password = nil, database = nil) ⇒ Object

Copyright 2006-2010 by Mike Bailey, le1t0@github. All rights reserved.



3
4
5
6
7
# File 'lib/deprec/recipes/db/mysql.rb', line 3

def run_mysql_command(command, user = "root", password = nil, database=nil)
  database = database.nil? ? "" : " #{database}"
  password = password.nil? ? "" : " -p #{password}"
  run "echo \"#{command}\" | mysql -u #{user} #{password} #{database}"
end

#running?(pid) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/deprec/templates/nagios/check_mongrel_cluster.rb', line 14

def running?(pid)
  # check if pid is running
  ps_output = `ps -p #{pid}`
  ps_output =~ /mongrel_rails/
end