Module: Opensips::Pi

Defined in:
lib/opensips-pi.rb,
lib/opensips-pi/version.rb

Constant Summary collapse

VERSION =
"0.0.5"
@@logger =
nil
@@bin =
nil

Class Method Summary collapse

Class Method Details

.add(user, pass, domain = nil) ⇒ Object

Add a new OpenSIPS user.

Parameters:

  • user (String)
  • pass (String)
  • domain (String) (defaults to: nil)


51
52
53
# File 'lib/opensips-pi.rb', line 51

def self.add(user, pass, domain=nil)
  call("#{bin} add #{identifier(user,domain).shellescape} #{pass.shellescape}")
end

.binString

Returns the OpenSIPS control tool, that is “opensipsctl” by default. You can customize this with bin=.

Returns:

  • (String)


15
16
17
# File 'lib/opensips-pi.rb', line 15

def self.bin
  @@bin || "opensipsctl"
end

.bin=(cmd) ⇒ Object

Customize the OpenSIPS control tool. See bin for more information.

Examples:

Opensips::Pi.bin = "/usr/sbin/opensipsctl"
Opensips::Pi.bin #=> "/usr/sbin/opensipsctl"

Parameters:

  • cmd (String)

    Path to OpenSIPS control tool.



25
26
27
# File 'lib/opensips-pi.rb', line 25

def self.bin=(cmd)
  @@bin = cmd
end

.loggerLogger

Returns an instance of Ruby’s Logger (by default) or a logger set with logger=.

Returns:

  • (Logger)


33
34
35
# File 'lib/opensips-pi.rb', line 33

def self.logger
  @@logger ||= Logger.new(STDOUT)
end

.logger=(klass) ⇒ Object

Customize the logger. See logger for more information.

Examples:

Opensips::Pi.logger = Rails.logger

Parameters:

  • (Logger)


42
43
44
# File 'lib/opensips-pi.rb', line 42

def self.logger=(klass)
  @@logger = klass
end

.password(user, pass, domain = nil) ⇒ Object

Change user’s password.

Parameters:

  • user (String)
  • pass (String)

    New password

  • domain (String) (defaults to: nil)


68
69
70
# File 'lib/opensips-pi.rb', line 68

def self.password(user, pass, domain=nil)
  call("#{bin} passwd #{identifier(user,domain).shellescape} #{pass.shellescape}")
end

.remove(user, domain = nil) ⇒ Object

Remove an user from OpenSIPS.

Parameters:

  • user (String)
  • domain (String) (defaults to: nil)


59
60
61
# File 'lib/opensips-pi.rb', line 59

def self.remove(user, domain=nil)
  call("#{bin} rm #{identifier(user,domain).shellescape}")
end