oversip 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/etc/custom_lib.rb +15 -0
- data/etc/logic.rb +1 -1
- data/etc/oversip.conf +2 -1
- data/etc/proxies.conf +1 -1
- data/etc/system_events.rb +18 -0
- data/etc/websocket_policy.rb +1 -2
- data/lib/oversip/config.rb +74 -40
- data/lib/oversip/config_validators.rb +4 -4
- data/lib/oversip/launcher.rb +17 -4
- data/lib/oversip/logger.rb +1 -1
- data/lib/oversip/posix_mq.rb +17 -14
- data/lib/oversip/syslogger_process.rb +11 -11
- data/lib/oversip/version.rb +5 -7
- metadata +21 -28
- data/debian/changelog +0 -5
- data/debian/compat +0 -1
- data/debian/control +0 -25
- data/debian/copyright +0 -25
- data/debian/oversip.default +0 -25
- data/debian/oversip.init +0 -226
- data/debian/postrm +0 -16
- data/debian/preinst +0 -34
- data/debian/rules +0 -66
data/etc/custom_lib.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#
|
2
|
+
# OverSIP - Custom Library.
|
3
|
+
#
|
4
|
+
#
|
5
|
+
# Add your custom code for your application running on top of OverSIP.
|
6
|
+
# Here you can load thirdy-party libraries and so on.
|
7
|
+
|
8
|
+
|
9
|
+
module MyOverSIP
|
10
|
+
|
11
|
+
extend ::OverSIP::Logger
|
12
|
+
|
13
|
+
# Add here your code.
|
14
|
+
|
15
|
+
end
|
data/etc/logic.rb
CHANGED
data/etc/oversip.conf
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# OverSIP - Configuration
|
2
|
+
# OverSIP - Main Configuration.
|
3
3
|
#
|
4
4
|
#
|
5
5
|
# IMPORTANT:
|
@@ -151,6 +151,7 @@ websocket:
|
|
151
151
|
listen_ipv4: null
|
152
152
|
|
153
153
|
# Enable or dissable IPv6. By default _yes_.
|
154
|
+
#
|
154
155
|
enable_ipv6: yes
|
155
156
|
|
156
157
|
# IPv6 in which OverSIP listens for SIP messages. Using "::" is not
|
data/etc/proxies.conf
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
#
|
2
|
+
# OverSIP - System Events.
|
3
|
+
#
|
4
|
+
#
|
5
|
+
# OverSIP system callbacks. Fill them according to your needs.
|
6
|
+
|
7
|
+
|
8
|
+
module OverSIP::SystemEvents
|
9
|
+
|
10
|
+
extend ::OverSIP::Logger
|
11
|
+
@log_id = "SystemEvents"
|
12
|
+
|
13
|
+
# This method is called once the OverSIP reactor has been started.
|
14
|
+
def self.on_started
|
15
|
+
# Do something.
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/etc/websocket_policy.rb
CHANGED
data/lib/oversip/config.rb
CHANGED
@@ -15,6 +15,8 @@ module OverSIP
|
|
15
15
|
PROXIES_FILE = "proxies.conf"
|
16
16
|
LOGIC_FILE = "logic.rb"
|
17
17
|
WEBSOCKET_POLICY_FILE = "websocket_policy.rb"
|
18
|
+
SYSTEM_EVENTS_FILE = "system_events.rb"
|
19
|
+
CUSTOM_LIB_FILE = "custom_lib.rb"
|
18
20
|
|
19
21
|
def self.log_id
|
20
22
|
@log_id ||= "Config"
|
@@ -122,30 +124,48 @@ module OverSIP
|
|
122
124
|
@config_dir = (config_dir || DEFAULT_CONFIG_DIR)
|
123
125
|
@config_file = ::File.join(@config_dir, config_file || DEFAULT_CONFIG_FILE)
|
124
126
|
@proxies_file = ::File.join(@config_dir, PROXIES_FILE)
|
125
|
-
@logic_file
|
126
|
-
@websocket_policy_file
|
127
|
+
@logic_file = ::File.join(@config_dir, LOGIC_FILE)
|
128
|
+
@websocket_policy_file = ::File.join(@config_dir, WEBSOCKET_POLICY_FILE)
|
129
|
+
@system_events_file = ::File.join(@config_dir, SYSTEM_EVENTS_FILE)
|
130
|
+
@custom_lib_file = ::File.join(@config_dir, CUSTOM_LIB_FILE)
|
127
131
|
|
128
132
|
begin
|
129
133
|
conf_yaml = ::YAML.load_file @config_file
|
130
134
|
rescue => e
|
131
|
-
fatal "error loading
|
135
|
+
fatal "error loading Main Configuration file '#{@config_file}': #{e.message} (#{e.class})"
|
136
|
+
end
|
137
|
+
|
138
|
+
begin
|
139
|
+
::Kernel.load @custom_lib_file
|
140
|
+
rescue ::LoadError => e
|
141
|
+
log_system_warn "cannot load Custom Lib file '#{@custom_lib_file}': #{e.message} (#{e.class})"
|
142
|
+
rescue ::Exception => e
|
143
|
+
log_system_crit "error loading Custom Lib file '#{@custom_lib_file}':"
|
144
|
+
fatal e
|
145
|
+
end
|
146
|
+
|
147
|
+
begin
|
148
|
+
::Kernel.load @system_events_file
|
149
|
+
rescue ::Exception => e
|
150
|
+
log_system_crit "error loading System Events file '#{@system_events_file}':"
|
151
|
+
fatal e
|
132
152
|
end
|
133
153
|
|
134
154
|
begin
|
135
155
|
proxies_yaml = ::YAML.load_file @proxies_file
|
136
156
|
rescue => e
|
137
|
-
fatal "error loading
|
157
|
+
fatal "error loading Proxies Configuration file '#{@proxies_file}': #{e.message} (#{e.class})"
|
138
158
|
end
|
139
159
|
|
140
160
|
begin
|
141
|
-
Kernel.load @logic_file
|
142
|
-
rescue LoadError => e
|
143
|
-
fatal "error loading
|
161
|
+
::Kernel.load @logic_file
|
162
|
+
rescue ::LoadError => e
|
163
|
+
fatal "error loading Logic file '#{@logic_file}': #{e.message} (#{e.class})"
|
144
164
|
end
|
145
165
|
|
146
166
|
begin
|
147
|
-
|
148
|
-
rescue LoadError => e
|
167
|
+
::Kernel.load @websocket_policy_file
|
168
|
+
rescue ::LoadError => e
|
149
169
|
log_system_warn "cannot load WebSocket Policy file '#{@websocket_policy_file}': #{e.message} (#{e.class}), using default policy (allow all)"
|
150
170
|
end
|
151
171
|
|
@@ -164,7 +184,7 @@ module OverSIP
|
|
164
184
|
next
|
165
185
|
end
|
166
186
|
|
167
|
-
if values.is_a? Array
|
187
|
+
if values.is_a? ::Array
|
168
188
|
unless validations.include? :multi_value
|
169
189
|
fatal "#{section}[#{parameter}] does not allow multiple values"
|
170
190
|
end
|
@@ -174,14 +194,14 @@ module OverSIP
|
|
174
194
|
end
|
175
195
|
end
|
176
196
|
|
177
|
-
values = ( values.is_a?(Array) ? values : [ values ] )
|
197
|
+
values = ( values.is_a?(::Array) ? values : [ values ] )
|
178
198
|
|
179
199
|
values.each do |value|
|
180
200
|
validations.each do |validation|
|
181
201
|
|
182
|
-
if validation.is_a? Symbol
|
202
|
+
if validation.is_a? ::Symbol
|
183
203
|
args = []
|
184
|
-
elsif validation.is_a? Array
|
204
|
+
elsif validation.is_a? ::Array
|
185
205
|
args = validation[1..-1]
|
186
206
|
validation = validation[0]
|
187
207
|
end
|
@@ -202,7 +222,7 @@ module OverSIP
|
|
202
222
|
post_process
|
203
223
|
post_check
|
204
224
|
|
205
|
-
rescue OverSIP::ConfigurationError => e
|
225
|
+
rescue ::OverSIP::ConfigurationError => e
|
206
226
|
fatal "configuration error: #{e.message}"
|
207
227
|
rescue => e
|
208
228
|
fatal e
|
@@ -220,15 +240,15 @@ module OverSIP
|
|
220
240
|
tls_private_cert = conf_yaml["tls"]["private_cert"] rescue nil
|
221
241
|
tls_ca_dir = conf_yaml["tls"]["ca_dir"] rescue nil
|
222
242
|
|
223
|
-
if tls_public_cert.is_a?(String) and tls_public_cert[0] != "/"
|
243
|
+
if tls_public_cert.is_a?(::String) and tls_public_cert[0] != "/"
|
224
244
|
conf_yaml["tls"]["public_cert"] = ::File.join(@config_dir, DEFAULT_TLS_DIR, tls_public_cert)
|
225
245
|
end
|
226
246
|
|
227
|
-
if tls_private_cert.is_a?(String) and tls_private_cert[0] != "/"
|
247
|
+
if tls_private_cert.is_a?(::String) and tls_private_cert[0] != "/"
|
228
248
|
conf_yaml["tls"]["private_cert"] = ::File.join(@config_dir, DEFAULT_TLS_DIR, tls_private_cert)
|
229
249
|
end
|
230
250
|
|
231
|
-
if tls_ca_dir.is_a?(String) and tls_ca_dir[0] != "/"
|
251
|
+
if tls_ca_dir.is_a?(::String) and tls_ca_dir[0] != "/"
|
232
252
|
conf_yaml["tls"]["ca_dir"] = ::File.join(@config_dir, DEFAULT_TLS_DIR, tls_ca_dir)
|
233
253
|
end
|
234
254
|
end
|
@@ -237,9 +257,9 @@ module OverSIP
|
|
237
257
|
if @configuration[:tls][:public_cert] and @configuration[:tls][:private_cert]
|
238
258
|
@use_tls = true
|
239
259
|
# Generate a full PEM file containing both the public and private certificate (for Stud).
|
240
|
-
full_cert = Tempfile.new("oversip_full_cert_")
|
241
|
-
full_cert.puts File.read(@configuration[:tls][:public_cert])
|
242
|
-
full_cert.puts File.read(@configuration[:tls][:private_cert])
|
260
|
+
full_cert = ::Tempfile.new("oversip_full_cert_")
|
261
|
+
full_cert.puts ::File.read(@configuration[:tls][:public_cert])
|
262
|
+
full_cert.puts ::File.read(@configuration[:tls][:private_cert])
|
243
263
|
@configuration[:tls][:full_cert] = full_cert.path
|
244
264
|
full_cert.close
|
245
265
|
else
|
@@ -326,7 +346,7 @@ module OverSIP
|
|
326
346
|
end
|
327
347
|
|
328
348
|
if @configuration[:sip][:local_domains]
|
329
|
-
if @configuration[:sip][:local_domains].is_a? String
|
349
|
+
if @configuration[:sip][:local_domains].is_a? ::String
|
330
350
|
@configuration[:sip][:local_domains] = [ @configuration[:sip][:local_domains].downcase ]
|
331
351
|
end
|
332
352
|
@configuration[:sip][:local_domains].each {|local_domain| local_domain.downcase!}
|
@@ -447,7 +467,7 @@ module OverSIP
|
|
447
467
|
|
448
468
|
|
449
469
|
def self.print colorize=true
|
450
|
-
color = Term::ANSIColor if colorize
|
470
|
+
color = ::Term::ANSIColor if colorize
|
451
471
|
|
452
472
|
puts
|
453
473
|
@configuration.each_key do |section|
|
@@ -459,17 +479,17 @@ module OverSIP
|
|
459
479
|
@configuration[section].each do |parameter, value|
|
460
480
|
humanized_value = humanize_value value
|
461
481
|
color_value = case value
|
462
|
-
when TrueClass
|
482
|
+
when ::TrueClass
|
463
483
|
colorize ? color.bold(color.green(humanized_value)) : humanized_value
|
464
|
-
when FalseClass
|
484
|
+
when ::FalseClass
|
465
485
|
colorize ? color.bold(color.red(humanized_value)) : humanized_value
|
466
|
-
when NilClass
|
486
|
+
when ::NilClass
|
467
487
|
humanized_value
|
468
|
-
when String, Symbol
|
488
|
+
when ::String, ::Symbol
|
469
489
|
colorize ? color.yellow(humanized_value) : humanized_value
|
470
|
-
when Array
|
490
|
+
when ::Array
|
471
491
|
colorize ? color.yellow(humanized_value) : humanized_value
|
472
|
-
when Fixnum, Float
|
492
|
+
when ::Fixnum, ::Float
|
473
493
|
colorize ? color.bold(color.blue(humanized_value)) : humanized_value
|
474
494
|
else
|
475
495
|
humanized_value
|
@@ -482,14 +502,14 @@ module OverSIP
|
|
482
502
|
|
483
503
|
def self.humanize_value value
|
484
504
|
case value
|
485
|
-
when TrueClass
|
486
|
-
when FalseClass
|
487
|
-
when NilClass
|
488
|
-
when String
|
489
|
-
when Symbol
|
490
|
-
when Array
|
491
|
-
when Fixnum, Float ; value.to_s
|
492
|
-
else
|
505
|
+
when ::TrueClass ; "yes"
|
506
|
+
when ::FalseClass ; "no"
|
507
|
+
when ::NilClass ; "null"
|
508
|
+
when ::String ; value
|
509
|
+
when ::Symbol ; value.to_s
|
510
|
+
when ::Array ; value.join(", ")
|
511
|
+
when ::Fixnum, ::Float ; value.to_s
|
512
|
+
else ; value.to_s
|
493
513
|
end
|
494
514
|
end
|
495
515
|
|
@@ -498,12 +518,26 @@ module OverSIP
|
|
498
518
|
if type == :ipv4
|
499
519
|
socket = ::UDPSocket.new ::Socket::AF_INET
|
500
520
|
socket.connect("1.2.3.4", 1)
|
521
|
+
ip = socket.local_address.ip_address
|
522
|
+
socket.close
|
523
|
+
socket = ::UDPSocket.new ::Socket::AF_INET
|
501
524
|
elsif type == :ipv6
|
502
525
|
socket = ::UDPSocket.new ::Socket::AF_INET6
|
503
526
|
socket.connect("2001::1", 1)
|
527
|
+
ip = socket.local_address.ip_address
|
528
|
+
socket.close
|
529
|
+
socket = ::UDPSocket.new ::Socket::AF_INET6
|
530
|
+
end
|
531
|
+
# Test whether the IP is in fact bindeable (not true for link-scope IPv6 addresses).
|
532
|
+
begin
|
533
|
+
socket.bind ip, 0
|
534
|
+
rescue => e
|
535
|
+
log_system_warn "cannot bind in autodiscovered local #{type == :ipv4 ? "IPv4" : "IPv6"} '#{ip}': #{e.message} (#{e.class})"
|
536
|
+
return false
|
537
|
+
ensure
|
538
|
+
socket.close
|
504
539
|
end
|
505
|
-
|
506
|
-
socket.close
|
540
|
+
# Valid IP, return it.
|
507
541
|
return ip
|
508
542
|
rescue => e
|
509
543
|
log_system_warn "cannot autodiscover local #{type == :ipv4 ? "IPv4" : "IPv6"}: #{e.message} (#{e.class})"
|
@@ -513,10 +547,10 @@ module OverSIP
|
|
513
547
|
|
514
548
|
def self.reload_logic
|
515
549
|
begin
|
516
|
-
Kernel.load @logic_file
|
550
|
+
::Kernel.load @logic_file
|
517
551
|
log_system_info "logic reloaded"
|
518
552
|
true
|
519
|
-
rescue Exception => e
|
553
|
+
rescue ::Exception => e
|
520
554
|
log_system_crit "error reloading logic"
|
521
555
|
log_system_crit e
|
522
556
|
false
|
@@ -29,22 +29,22 @@ module OverSIP
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def ipv4 value
|
32
|
-
return false unless value.is_a? String
|
32
|
+
return false unless value.is_a? ::String
|
33
33
|
::OverSIP::Utils.ip_type(value) == :ipv4 and value != "0.0.0.0"
|
34
34
|
end
|
35
35
|
|
36
36
|
def ipv6 value
|
37
|
-
return false unless value.is_a? String
|
37
|
+
return false unless value.is_a? ::String
|
38
38
|
::OverSIP::Utils.ip_type(value) == :ipv6 and ::OverSIP::Utils.normalize_ipv6(value) != "::"
|
39
39
|
end
|
40
40
|
|
41
41
|
def ipv4_any value
|
42
|
-
return false unless value.is_a? String
|
42
|
+
return false unless value.is_a? ::String
|
43
43
|
::OverSIP::Utils.ip_type(value) == :ipv4
|
44
44
|
end
|
45
45
|
|
46
46
|
def ipv6_any value
|
47
|
-
return false unless value.is_a? String
|
47
|
+
return false unless value.is_a? ::String
|
48
48
|
::OverSIP::Utils.ip_type(value) == :ipv6
|
49
49
|
end
|
50
50
|
|
data/lib/oversip/launcher.rb
CHANGED
@@ -298,6 +298,16 @@ module OverSIP::Launcher
|
|
298
298
|
create_pid_file(options[:pid_file])
|
299
299
|
|
300
300
|
log_system_info "reactor running"
|
301
|
+
|
302
|
+
# Run the user provided on_started callback.
|
303
|
+
log_system_info "calling user provided OverSIP::SystemEvents.on_started() callback..."
|
304
|
+
begin
|
305
|
+
::OverSIP::SystemEvents.on_started
|
306
|
+
rescue ::Exception => e
|
307
|
+
log_system_crit "error calling user provided OverSIP::SystemEvents.on_started() callback:"
|
308
|
+
fatal e
|
309
|
+
end
|
310
|
+
|
301
311
|
log_system_info "master process (PID #{$$}) ready"
|
302
312
|
log_system_info "#{::OverSIP::PROGRAM_NAME} #{::OverSIP::VERSION} running in background"
|
303
313
|
|
@@ -313,9 +323,10 @@ module OverSIP::Launcher
|
|
313
323
|
$stdout.reopen("/dev/null")
|
314
324
|
$stderr.reopen("/dev/null")
|
315
325
|
::OverSIP.daemonized = true
|
316
|
-
|
326
|
+
# So update the logger to write to syslog.
|
317
327
|
::OverSIP::Logger.load_methods
|
318
328
|
|
329
|
+
# Set the EventMachine error handler.
|
319
330
|
::EM.error_handler do |e|
|
320
331
|
log_system_error "error raised during event loop and rescued by EM.error_handler:"
|
321
332
|
log_system_error e
|
@@ -427,11 +438,12 @@ module OverSIP::Launcher
|
|
427
438
|
|
428
439
|
# Signal CHLD is sent by syslogger process if it dies.
|
429
440
|
trap :CHLD do
|
430
|
-
#
|
441
|
+
# NOTE: This won't be logged if the died proces is oversip_syslogger!
|
431
442
|
log_system_crit "CHLD signal received, syslogger process could be death"
|
432
443
|
end
|
433
444
|
end
|
434
445
|
|
446
|
+
|
435
447
|
def self.terminate error=false
|
436
448
|
unless error
|
437
449
|
log_system_info "exiting, thank you for tasting #{::OverSIP::PROGRAM_NAME}"
|
@@ -441,7 +453,7 @@ module OverSIP::Launcher
|
|
441
453
|
kill_stud_processes
|
442
454
|
|
443
455
|
# Wait a bit so pending log messages in the Posix MQ can be queued.
|
444
|
-
sleep 0.
|
456
|
+
sleep 0.1
|
445
457
|
delete_pid_file
|
446
458
|
::OverSIP::Logger.close
|
447
459
|
|
@@ -502,7 +514,7 @@ module OverSIP::Launcher
|
|
502
514
|
stdout_file = "/tmp/stud.#{listen_ip}:#{listen_port}.out"
|
503
515
|
|
504
516
|
::Dir.chdir(bin_dir) do
|
505
|
-
pid = POSIX::Spawn.spawn "./oversip_stud #{stud_user_group} #{ssl_option} -f '#{listen_ip},#{listen_port}' -b '#{bg_ip},#{bg_port}' -n 2 -s --daemon --write-proxy #{::OverSIP.configuration[:tls][:full_cert]}", :out => stdout_file, :err => "/dev/null"
|
517
|
+
pid = ::POSIX::Spawn.spawn "./oversip_stud #{stud_user_group} #{ssl_option} -f '#{listen_ip},#{listen_port}' -b '#{bg_ip},#{bg_port}' -n 2 -s --daemon --write-proxy #{::OverSIP.configuration[:tls][:full_cert]}", :out => stdout_file, :err => "/dev/null"
|
506
518
|
Process.waitpid(pid)
|
507
519
|
end
|
508
520
|
|
@@ -531,6 +543,7 @@ module OverSIP::Launcher
|
|
531
543
|
|
532
544
|
def self.kill_stud_processes
|
533
545
|
return false unless ::OverSIP.master_pid
|
546
|
+
return false unless ::OverSIP.stud_pids
|
534
547
|
|
535
548
|
::OverSIP.stud_pids.each do |pid|
|
536
549
|
begin
|
data/lib/oversip/logger.rb
CHANGED
@@ -161,7 +161,7 @@ module OverSIP
|
|
161
161
|
end
|
162
162
|
|
163
163
|
# Default logging identifier is the class name. If log_id() method is redefined by the
|
164
|
-
# class including this module, or it sets @log_id, then such value takes preference.
|
164
|
+
# class including this module, or it sets @log_id, then such a value takes preference.
|
165
165
|
def log_id
|
166
166
|
@log_id ||= self.class.name
|
167
167
|
end
|
data/lib/oversip/posix_mq.rb
CHANGED
@@ -28,17 +28,20 @@ module OverSIP
|
|
28
28
|
rescue ::Errno::ENOENT
|
29
29
|
rescue ::Errno::EACCES => e
|
30
30
|
fatal "queue already exists and cannot remove it due file permissions"
|
31
|
+
# Kernel has no support for posix message queues.
|
32
|
+
rescue ::Errno::ENOSYS => e
|
33
|
+
fatal "the kernel has no support for posix messages queues, enable it (#{e.class}: #{e.message})"
|
31
34
|
end
|
32
35
|
|
33
36
|
# Set the UMASK in a way that the group has permission to delete the queue.
|
34
|
-
orig_umask = File.umask(0007)
|
37
|
+
orig_umask = ::File.umask(0007)
|
35
38
|
|
36
39
|
# Change the effective group for the Posix queue. Keep the original
|
37
40
|
# group.
|
38
|
-
orig_gid = Process::GID.eid
|
41
|
+
orig_gid = ::Process::GID.eid
|
39
42
|
if mq_group
|
40
|
-
gid = Etc.getgrnam(mq_group).gid
|
41
|
-
Process::GID.change_privilege(gid)
|
43
|
+
gid = ::Etc.getgrnam(mq_group).gid
|
44
|
+
::Process::GID.change_privilege(gid)
|
42
45
|
end
|
43
46
|
|
44
47
|
# System limits required size (ulimit -q).
|
@@ -60,7 +63,7 @@ module OverSIP
|
|
60
63
|
log_system_debug "incrementing rlimits (currently #{current_rlimit} bytes) to #{mq_size} bytes (ulimit -q)" if $oversip_debug
|
61
64
|
begin
|
62
65
|
::Process.setrlimit(12, mq_size)
|
63
|
-
rescue Errno::EPERM
|
66
|
+
rescue ::Errno::EPERM
|
64
67
|
fatal "current user has no permissions to increase rlimits to #{mq_size} bytes (ulimit -q)"
|
65
68
|
end
|
66
69
|
end
|
@@ -73,10 +76,10 @@ module OverSIP
|
|
73
76
|
# - mode: 00660 => User and group can write and read.
|
74
77
|
# - mq_attr => Set maxmsg and msgsize.
|
75
78
|
begin
|
76
|
-
mq = ::POSIX_MQ.new mq_name, mq_mode | IO::CREAT | IO::EXCL | IO::NONBLOCK, 00660, mq_attr
|
79
|
+
mq = ::POSIX_MQ.new mq_name, mq_mode | ::IO::CREAT | ::IO::EXCL | ::IO::NONBLOCK, 00660, mq_attr
|
77
80
|
|
78
81
|
# Kernel has no support for posix message queues.
|
79
|
-
rescue Errno::ENOSYS => e
|
82
|
+
rescue ::Errno::ENOSYS => e
|
80
83
|
fatal "the kernel has no support for posix messages queues, enable it (#{e.class}: #{e.message})"
|
81
84
|
|
82
85
|
# http://linux.die.net/man/3/mq_open
|
@@ -87,25 +90,25 @@ module OverSIP
|
|
87
90
|
# limit, and attr->mq_msgsize must be less than or equal to the msgsize_max limit. In addition, even
|
88
91
|
# in a privileged process, attr->mq_maxmsg cannot exceed the HARD_MAX limit. (See mq_overview(7) for
|
89
92
|
# details of these limits.)
|
90
|
-
rescue Errno::EINVAL
|
93
|
+
rescue ::Errno::EINVAL
|
91
94
|
log_system_warn "cannot set queue attributes due to user permissions, using system default values"
|
92
|
-
mq = ::POSIX_MQ.new mq_name, mq_mode | IO::CREAT | IO::NONBLOCK, 00660
|
93
|
-
rescue Errno::ENOMEM => e
|
95
|
+
mq = ::POSIX_MQ.new mq_name, mq_mode | ::IO::CREAT | ::IO::NONBLOCK, 00660
|
96
|
+
rescue ::Errno::ENOMEM => e
|
94
97
|
fatal "insufficient memory (#{e.class}: #{e.message})"
|
95
|
-
rescue Errno::EMFILE => e
|
98
|
+
rescue ::Errno::EMFILE => e
|
96
99
|
fatal "the process already has the maximum number of files and message queues open (#{e.class}: #{e.message})"
|
97
100
|
rescue Errno::ENFILE => e
|
98
101
|
fatal "the system limit on the total number of open files and message queues has been reached (#{e.class}: #{e.message})"
|
99
|
-
rescue Errno::ENOSPC => e
|
102
|
+
rescue ::Errno::ENOSPC => e
|
100
103
|
fatal "insufficient space for the creation of a new message queue, probably occurred because the queues_max limit was encountered (#{e.class}: #{e.message})"
|
101
104
|
|
102
105
|
end
|
103
106
|
|
104
107
|
# Recover the original Umask settings.
|
105
|
-
File.umask(orig_umask)
|
108
|
+
::File.umask(orig_umask)
|
106
109
|
|
107
110
|
# Recover the original effective group.
|
108
|
-
Process::GID.change_privilege(orig_gid) if mq_group
|
111
|
+
::Process::GID.change_privilege(orig_gid) if mq_group
|
109
112
|
|
110
113
|
if mq.attr.maxmsg == mq_attr.maxmsg and mq.attr.msgsize == mq_attr.msgsize
|
111
114
|
log_system_debug "maxmsg=#{mq.attr.maxmsg}, msgsize=#{mq.attr.msgsize}" if $oversip_debug
|
@@ -22,17 +22,17 @@ module OverSIP
|
|
22
22
|
module SysLoggerProcess
|
23
23
|
|
24
24
|
SYSLOG_FACILITY_MAPPING = {
|
25
|
-
"kern" => Syslog::LOG_KERN,
|
26
|
-
"user" => Syslog::LOG_USER,
|
27
|
-
"daemon" => Syslog::LOG_DAEMON,
|
28
|
-
"local0" => Syslog::LOG_LOCAL0,
|
29
|
-
"local1" => Syslog::LOG_LOCAL1,
|
30
|
-
"local2" => Syslog::LOG_LOCAL2,
|
31
|
-
"local3" => Syslog::LOG_LOCAL3,
|
32
|
-
"local4" => Syslog::LOG_LOCAL4,
|
33
|
-
"local5" => Syslog::LOG_LOCAL5,
|
34
|
-
"local6" => Syslog::LOG_LOCAL6,
|
35
|
-
"local7" => Syslog::LOG_LOCAL7
|
25
|
+
"kern" => ::Syslog::LOG_KERN,
|
26
|
+
"user" => ::Syslog::LOG_USER,
|
27
|
+
"daemon" => ::Syslog::LOG_DAEMON,
|
28
|
+
"local0" => ::Syslog::LOG_LOCAL0,
|
29
|
+
"local1" => ::Syslog::LOG_LOCAL1,
|
30
|
+
"local2" => ::Syslog::LOG_LOCAL2,
|
31
|
+
"local3" => ::Syslog::LOG_LOCAL3,
|
32
|
+
"local4" => ::Syslog::LOG_LOCAL4,
|
33
|
+
"local5" => ::Syslog::LOG_LOCAL5,
|
34
|
+
"local6" => ::Syslog::LOG_LOCAL6,
|
35
|
+
"local7" => ::Syslog::LOG_LOCAL7
|
36
36
|
}
|
37
37
|
|
38
38
|
class SysLoggerWatcher < ::EM::PosixMQ::Watcher
|
data/lib/oversip/version.rb
CHANGED
@@ -5,19 +5,17 @@ module OverSIP
|
|
5
5
|
module Version
|
6
6
|
MAJOR = 1
|
7
7
|
MINOR = 0
|
8
|
-
TINY =
|
8
|
+
TINY = 5
|
9
|
+
DEVEL = nil # Set to nil for stable releases.
|
9
10
|
end
|
10
11
|
|
11
12
|
PROGRAM_NAME = "OverSIP"
|
12
13
|
PROGRAM_NAME_LOW = PROGRAM_NAME.downcase
|
13
14
|
PROGRAM_DESC = "OverSIP Server"
|
14
|
-
VERSION = [Version::MAJOR, Version::MINOR, Version::TINY].join(
|
15
|
-
|
15
|
+
VERSION = [Version::MAJOR, Version::MINOR, Version::TINY].join(".")
|
16
|
+
VERSION << ".#{Version::DEVEL}" if Version::DEVEL
|
17
|
+
AUTHOR = "Inaki Baz Castillo"
|
16
18
|
AUTHOR_EMAIL = "ibc@aliax.net"
|
17
19
|
DESCRIPTION = "#{PROGRAM_NAME} #{VERSION}\n2012, #{AUTHOR} <#{AUTHOR_EMAIL}>"
|
18
20
|
|
19
|
-
module GemVersion
|
20
|
-
VERSION = ::OverSIP::VERSION
|
21
|
-
end
|
22
|
-
|
23
21
|
end
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oversip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
-
-
|
8
|
+
- Inaki Baz Castillo
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine-le
|
16
|
-
requirement: &
|
16
|
+
requirement: &23702300 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.1.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *23702300
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: iobuffer
|
27
|
-
requirement: &
|
27
|
+
requirement: &23701840 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.1.2
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *23701840
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: em-posixmq
|
38
|
-
requirement: &
|
38
|
+
requirement: &23701380 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.2.3
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *23701380
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: em-udns
|
49
|
-
requirement: &
|
49
|
+
requirement: &23717300 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.3.6
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *23717300
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: escape_utils
|
60
|
-
requirement: &
|
60
|
+
requirement: &23716840 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 0.2.4
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *23716840
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: term-ansicolor
|
71
|
-
requirement: &
|
71
|
+
requirement: &23716460 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *23716460
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: posix-spawn
|
82
|
-
requirement: &
|
82
|
+
requirement: &23715920 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 0.3.6
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *23715920
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: rake
|
93
|
-
requirement: &
|
93
|
+
requirement: &23715420 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: 0.9.2
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *23715420
|
102
102
|
description: ! "OverSIP is an async SIP server. Built on top of Ruby EventMachine\n
|
103
103
|
\ library it follows the Reactor Pattern, allowing thousands of concurrent connections
|
104
104
|
and requests\n handled by a single processor in a never-blocking fashion. It
|
@@ -229,6 +229,8 @@ files:
|
|
229
229
|
- ext/stud/extconf.rb
|
230
230
|
- thirdparty/stud/stud.tar.gz
|
231
231
|
- etc/oversip.conf
|
232
|
+
- etc/system_events.rb
|
233
|
+
- etc/custom_lib.rb
|
232
234
|
- etc/logic.rb
|
233
235
|
- etc/proxies.conf
|
234
236
|
- etc/websocket_policy.rb
|
@@ -238,15 +240,6 @@ files:
|
|
238
240
|
- etc/tls/ca/cacert.pem
|
239
241
|
- etc/tls/utils/get-sip-identities.rb
|
240
242
|
- etc/tls/utils/create-cert.rb
|
241
|
-
- debian/postrm
|
242
|
-
- debian/compat
|
243
|
-
- debian/copyright
|
244
|
-
- debian/rules
|
245
|
-
- debian/oversip.init
|
246
|
-
- debian/oversip.default
|
247
|
-
- debian/changelog
|
248
|
-
- debian/control
|
249
|
-
- debian/preinst
|
250
243
|
- Rakefile
|
251
244
|
- README.md
|
252
245
|
- AUTHORS
|
data/debian/changelog
DELETED
data/debian/compat
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
7
|
data/debian/control
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
Source: oversip
|
2
|
-
Section: comm
|
3
|
-
Priority: optional
|
4
|
-
Maintainer: Iñaki Baz Castillo <ibc@aliax.net>
|
5
|
-
Homepage: http://www.oversip.net
|
6
|
-
Build-Depends: debhelper (>= 7)
|
7
|
-
Standards-Version: 3.9.3
|
8
|
-
|
9
|
-
Package: oversip
|
10
|
-
Architecture: all
|
11
|
-
Pre-Depends: ${shlibs:Depends}, ${misc:Depends}, ruby1.9.1, ruby1.9.1-dev, make, g++, libssl-dev, libev-dev
|
12
|
-
Suggests: unbound
|
13
|
-
Description: OverSIP (the SIP dreams factory) is an async SIP proxy/server programmable in Ruby language.
|
14
|
-
Some features of OverSIP are:
|
15
|
-
- SIP transports: UDP, TCP, TLS and WebSocket.
|
16
|
-
- Full IPv4 and IPv6 support.
|
17
|
-
- RFC 3263: SIP DNS mechanism (NAPTR, SRV, A, AAAA) for failover and load
|
18
|
-
balancing based on DNS.
|
19
|
-
- RFC 5626: OverSIP is a perfect Outbound EDGE proxy, including an integrated
|
20
|
-
STUN server.
|
21
|
-
- Fully programmable in Ruby language (make SIP easy).
|
22
|
-
- Fast and efficient: OverSIP core is coded in C language.
|
23
|
-
OverSIP is build on top of EventMachine async library which follows the Reactor
|
24
|
-
Pattern design, allowing thousands of concurrent connections and requests in a
|
25
|
-
never-blocking fashion.
|
data/debian/copyright
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
Name: OverSIP
|
2
|
-
Maintainer: Iñaki Baz Castillo <ibc@aliax.net>
|
3
|
-
Copyright (c) 2012 Iñaki Baz Castillo <ibc@aliax.net>
|
4
|
-
|
5
|
-
|
6
|
-
License: The MIT LICENSE
|
7
|
-
|
8
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
9
|
-
a copy of this software and associated documentation files (the
|
10
|
-
"Software"), to deal in the Software without restriction, including
|
11
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
12
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
13
|
-
permit persons to whom the Software is furnished to do so, subject to
|
14
|
-
the following conditions:
|
15
|
-
|
16
|
-
The above copyright notice and this permission notice shall be
|
17
|
-
included in all copies or substantial portions of the Software.
|
18
|
-
|
19
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
20
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
22
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
23
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
24
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
25
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/debian/oversip.default
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# oversip startup options
|
3
|
-
#
|
4
|
-
|
5
|
-
# Set to 'yes' when configured.
|
6
|
-
RUN=no
|
7
|
-
|
8
|
-
# User to run as.
|
9
|
-
USER=oversip
|
10
|
-
|
11
|
-
# Group to run as.
|
12
|
-
GROUP=oversip
|
13
|
-
|
14
|
-
# Directory with the configuration files.
|
15
|
-
# By default '/etc/oversip/'.
|
16
|
-
#CONFIG_DIR=/etc/oversip/
|
17
|
-
|
18
|
-
# Main configuration file name (within the configuration directory).
|
19
|
-
# By default 'oversip.conf'.
|
20
|
-
#CONFIG_FILE=oversip.conf
|
21
|
-
|
22
|
-
# Number of OverSIP instances that will run together in this host.
|
23
|
-
# This parameter is just for some resources allocation, it does not run N instances!
|
24
|
-
# By default 1.
|
25
|
-
#NUM_INSTANCES=1
|
data/debian/oversip.init
DELETED
@@ -1,226 +0,0 @@
|
|
1
|
-
#! /bin/bash
|
2
|
-
|
3
|
-
### BEGIN INIT INFO
|
4
|
-
# Provides: oversip
|
5
|
-
# Required-Start: $syslog $network $remote_fs
|
6
|
-
# Required-Stop: $syslog $network $remote_fs
|
7
|
-
# Default-Start: 2 3 4 5
|
8
|
-
# Default-Stop: 0 1 6
|
9
|
-
# Short-Description: Start/stop OverSIP
|
10
|
-
# Description: Start/stop OverSIP
|
11
|
-
### END INIT INFO
|
12
|
-
|
13
|
-
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/var/lib/gems/1.9.1/bin
|
14
|
-
DESC=OverSIP
|
15
|
-
HOMEDIR=/var/run/oversip
|
16
|
-
RUN=no
|
17
|
-
RUBY_GEM=oversip
|
18
|
-
RUBY_EXE=ruby1.9.1
|
19
|
-
|
20
|
-
# Process name, it affects to the process name, Posix Message Queue name and PID file.
|
21
|
-
# The configuration file under /etc/default/ to read will also be called $NAME.
|
22
|
-
NAME=oversip
|
23
|
-
|
24
|
-
|
25
|
-
. /lib/lsb/init-functions
|
26
|
-
|
27
|
-
# Debian LSB functions don't add \n in function log_begin_msg().
|
28
|
-
# In Ubuntu such function is overriden in /etc/lsb-base-logging.sh.
|
29
|
-
UBUNTU_LOGGING=0
|
30
|
-
[ -r /etc/lsb-base-logging.sh ] && UBUNTU_LOGGING=1
|
31
|
-
|
32
|
-
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
|
33
|
-
|
34
|
-
|
35
|
-
# Check for the start/restart/force-reload actions.
|
36
|
-
if [ "$1" == "start" ] || [ "$1" == "restart" ] || [ "$1" == "force-reload" ] ; then
|
37
|
-
# Ensure that the admin has set RUN=yes in /etc/default/$NAME file.
|
38
|
-
if [ "$RUN" != "yes" ] ; then
|
39
|
-
log_failure_msg "$DESC ($NAME) not yet configured. Set RUN=yes in /etc/default/$NAME."
|
40
|
-
exit 0
|
41
|
-
fi
|
42
|
-
fi
|
43
|
-
|
44
|
-
# Ensure Ruby executable is installed.
|
45
|
-
which $RUBY_EXE >/dev/null
|
46
|
-
if [ $? -ne 0 ] ; then
|
47
|
-
log_failure_msg "ruby1.9.1 is not installed, exiting."
|
48
|
-
log_end_msg 5
|
49
|
-
exit 5
|
50
|
-
fi
|
51
|
-
|
52
|
-
# Check whether OverSIP Ruby Gem is installed and get the executable location.
|
53
|
-
DAEMON=$(which oversip)
|
54
|
-
if [ $? -ne 0 ] ; then
|
55
|
-
log_failure_msg "$DESC ($NAME): Ruby Gem '$RUBY_GEM' is not installed, exiting."
|
56
|
-
|
57
|
-
case "$1" in
|
58
|
-
status)
|
59
|
-
# LSB - 4: program or service status is unknown.
|
60
|
-
log_end_msg 4
|
61
|
-
exit 4
|
62
|
-
;;
|
63
|
-
*)
|
64
|
-
# LSB - 5: program is not installed.
|
65
|
-
log_end_msg 5
|
66
|
-
exit 5
|
67
|
-
;;
|
68
|
-
esac
|
69
|
-
fi
|
70
|
-
|
71
|
-
|
72
|
-
PIDFILE="${HOMEDIR}/${NAME}.pid"
|
73
|
-
OPTIONS="-P ${PIDFILE} -p ${NAME}"
|
74
|
-
|
75
|
-
if [ -n "$USER" ] ; then OPTIONS="${OPTIONS} -u ${USER}" ; fi
|
76
|
-
if [ -n "$GROUP" ] ; then OPTIONS="${OPTIONS} -g ${GROUP}" ; fi
|
77
|
-
if [ -n "$CONFIG_DIR" ] ; then OPTIONS="${OPTIONS} --config-dir ${CONFIG_DIR}" ; fi
|
78
|
-
if [ -n "$CONFIG_FILE" ] ; then OPTIONS="${OPTIONS} --config-file ${CONFIG_FILE}" ; fi
|
79
|
-
if [ -n "$NUM_INSTANCES" ] ; then OPTIONS="${OPTIONS} --num-instances ${NUM_INSTANCES}" ; fi
|
80
|
-
|
81
|
-
|
82
|
-
check_homedir()
|
83
|
-
{
|
84
|
-
# Create HOMEDIR directory in case it doesn't exist.
|
85
|
-
# Useful in Ubuntu as /var/run/ content is deleted in shutdown.
|
86
|
-
if [ ! -d $HOMEDIR ] ; then mkdir $HOMEDIR ; fi
|
87
|
-
|
88
|
-
# Set the appropiate owner and group
|
89
|
-
if [ -n "$USER" ] ; then chown ${USER} $HOMEDIR ; fi
|
90
|
-
if [ -n "$GROUP" ] ; then chgrp ${GROUP} $HOMEDIR ; fi
|
91
|
-
}
|
92
|
-
|
93
|
-
|
94
|
-
# Return values:
|
95
|
-
# - 3: oversip is not running.
|
96
|
-
# - 0: oversip is running.
|
97
|
-
# - 1: oversip is not running but PID file exists.
|
98
|
-
get_status() {
|
99
|
-
if [ ! -r "$PIDFILE" ]; then
|
100
|
-
return 3
|
101
|
-
fi
|
102
|
-
if read pid < "$PIDFILE" && ps -p "$pid" > /dev/null 2>&1; then
|
103
|
-
return 0
|
104
|
-
else
|
105
|
-
return 1
|
106
|
-
fi
|
107
|
-
}
|
108
|
-
|
109
|
-
|
110
|
-
start() {
|
111
|
-
set +e
|
112
|
-
get_status
|
113
|
-
case $? in
|
114
|
-
0) # Already running, do nothing.
|
115
|
-
log_warning_msg "already running."
|
116
|
-
exit 0
|
117
|
-
;;
|
118
|
-
3) # Not running, start it.
|
119
|
-
;;
|
120
|
-
1) # Not running but PID file exists, remove it and start.
|
121
|
-
log_warning_msg "not running but PID file '$PIDFILE' exists, deleting it."
|
122
|
-
rm "$PIDFILE"
|
123
|
-
;;
|
124
|
-
esac
|
125
|
-
|
126
|
-
start-stop-daemon --start --quiet --pidfile $PIDFILE --quiet \
|
127
|
-
--exec $DAEMON -- $OPTIONS
|
128
|
-
res=$?
|
129
|
-
|
130
|
-
if [ $res -eq 0 ] ; then
|
131
|
-
log_end_msg 0
|
132
|
-
exit 0
|
133
|
-
else
|
134
|
-
if [ ! -r "$PIDFILE" ]; then
|
135
|
-
log_failure_msg "error, failed to start."
|
136
|
-
log_end_msg 1
|
137
|
-
exit 1
|
138
|
-
else
|
139
|
-
log_failure_msg "error, failed to start (and PID file '$PIDFILE' exists)."
|
140
|
-
log_end_msg 1
|
141
|
-
exit 1
|
142
|
-
fi
|
143
|
-
fi
|
144
|
-
}
|
145
|
-
|
146
|
-
|
147
|
-
set -e
|
148
|
-
|
149
|
-
case "$1" in
|
150
|
-
|
151
|
-
start)
|
152
|
-
check_homedir
|
153
|
-
log_daemon_msg "Starting $DESC ($NAME)"
|
154
|
-
echo
|
155
|
-
set +e
|
156
|
-
|
157
|
-
start
|
158
|
-
;;
|
159
|
-
|
160
|
-
stop)
|
161
|
-
log_daemon_msg "Stopping $DESC ($NAME)"
|
162
|
-
echo
|
163
|
-
set +e
|
164
|
-
|
165
|
-
start-stop-daemon --oknodo --stop --pidfile $PIDFILE --quiet
|
166
|
-
res=$?
|
167
|
-
|
168
|
-
if [ $res -eq 0 ] ; then
|
169
|
-
log_end_msg 0
|
170
|
-
# Posix MQueue for syslogging is created with owner root (to ensure
|
171
|
-
# rlimits and so) so it cannot be deleted by a non root user when
|
172
|
-
# stopping the server. This command removes the mqueue when performing
|
173
|
-
# the "stop" action.
|
174
|
-
$DAEMON --remove-mqueue "/${NAME}_syslogger" 2>/dev/null
|
175
|
-
exit 0
|
176
|
-
else
|
177
|
-
log_failure_msg "error, failed to stop."
|
178
|
-
log_end_msg 1
|
179
|
-
exit 1
|
180
|
-
fi
|
181
|
-
;;
|
182
|
-
|
183
|
-
restart|force-reload)
|
184
|
-
log_daemon_msg "Restarting $DESC ($NAME)"
|
185
|
-
echo
|
186
|
-
set +e
|
187
|
-
|
188
|
-
start-stop-daemon --oknodo --stop --pidfile $PIDFILE --retry=5 --quiet
|
189
|
-
|
190
|
-
if [ $? -ne 0 ] ; then
|
191
|
-
log_failure_msg "error, failed to stop."
|
192
|
-
log_end_msg 1
|
193
|
-
exit 1
|
194
|
-
fi
|
195
|
-
|
196
|
-
check_homedir
|
197
|
-
start
|
198
|
-
;;
|
199
|
-
|
200
|
-
status)
|
201
|
-
set +e
|
202
|
-
get_status
|
203
|
-
case $? in
|
204
|
-
3) # Not running.
|
205
|
-
log_begin_msg "$DESC ($NAME) is not running."
|
206
|
-
[ $UBUNTU_LOGGING -eq 0 ] && echo
|
207
|
-
exit 3
|
208
|
-
;;
|
209
|
-
0) # Running.
|
210
|
-
log_begin_msg "$DESC ($NAME) is running."
|
211
|
-
[ $UBUNTU_LOGGING -eq 0 ] && echo
|
212
|
-
exit 0
|
213
|
-
;;
|
214
|
-
1) # Not running but PID file exists.
|
215
|
-
log_warning_msg "$DESC ($NAME) is not running but PID file '$PIDFILE' exists."
|
216
|
-
exit 1
|
217
|
-
;;
|
218
|
-
esac
|
219
|
-
;;
|
220
|
-
|
221
|
-
*)
|
222
|
-
log_failure_msg "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload|status}."
|
223
|
-
exit 1
|
224
|
-
;;
|
225
|
-
|
226
|
-
esac
|
data/debian/postrm
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
#DEBHELPER#
|
4
|
-
|
5
|
-
if [ "$1" = "purge" ] ; then
|
6
|
-
# Remove the Debian system user/group.
|
7
|
-
deluser --quiet --remove-home oversip &>/dev/null || true
|
8
|
-
|
9
|
-
# Remove the Ruby gem.
|
10
|
-
echo "uninstalling 'oversip' Ruby Gem..."
|
11
|
-
gem1.9.1 uninstall oversip -a -x
|
12
|
-
fi
|
13
|
-
|
14
|
-
exit 0
|
15
|
-
|
16
|
-
#DEBHELPER#
|
data/debian/preinst
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
# preinst script can be called with arguments 'install', 'upgrade' and 'abort-upgrade'.
|
4
|
-
|
5
|
-
set -e
|
6
|
-
|
7
|
-
#DEBHELPER#
|
8
|
-
|
9
|
-
OVERSIP_GEM_VERSION="~>1.0.4"
|
10
|
-
|
11
|
-
case "$1" in
|
12
|
-
|
13
|
-
install)
|
14
|
-
# Add a Debian system user/group called "oversip".
|
15
|
-
adduser --quiet --system --group --disabled-password \
|
16
|
-
--shell /bin/false --gecos "OverSIP" \
|
17
|
-
--home /var/run/oversip oversip || true
|
18
|
-
|
19
|
-
# Install the Ruby gem.
|
20
|
-
echo "installing 'oversip' Ruby Gem (version $OVERSIP_GEM_VERSION)..."
|
21
|
-
gem1.9.1 install oversip --no-rdoc --no-ri -v $OVERSIP_GEM_VERSION
|
22
|
-
;;
|
23
|
-
|
24
|
-
upgrade)
|
25
|
-
# Install the Ruby gem.
|
26
|
-
echo "installing 'oversip' Ruby Gem (version $OVERSIP_GEM_VERSION)..."
|
27
|
-
gem1.9.1 install oversip --no-rdoc --no-ri -v $OVERSIP_GEM_VERSION
|
28
|
-
;;
|
29
|
-
|
30
|
-
esac
|
31
|
-
|
32
|
-
exit 0
|
33
|
-
|
34
|
-
#DEBHELPER#
|
data/debian/rules
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
#!/usr/bin/make -f
|
2
|
-
# -*- makefile -*-
|
3
|
-
|
4
|
-
# Uncomment this to turn on verbose mode.
|
5
|
-
#export DH_VERBOSE=1
|
6
|
-
|
7
|
-
build: build-stamp
|
8
|
-
|
9
|
-
build-stamp:
|
10
|
-
dh_testdir
|
11
|
-
touch $@
|
12
|
-
|
13
|
-
clean:
|
14
|
-
dh_testdir
|
15
|
-
dh_testroot
|
16
|
-
rm -rf build-stamp oversip
|
17
|
-
dh_clean
|
18
|
-
|
19
|
-
install: build
|
20
|
-
dh_testdir
|
21
|
-
dh_testroot
|
22
|
-
dh_clean -k
|
23
|
-
dh_installdirs /etc
|
24
|
-
|
25
|
-
mkdir -p $(CURDIR)/debian/oversip/etc/oversip/
|
26
|
-
mkdir -p $(CURDIR)/debian/oversip/etc/oversip/tls/
|
27
|
-
mkdir -p $(CURDIR)/debian/oversip/etc/oversip/tls/ca/
|
28
|
-
mkdir -p $(CURDIR)/debian/oversip/etc/oversip/tls/utils/
|
29
|
-
mkdir -p $(CURDIR)/debian/oversip/usr/share/oversip/
|
30
|
-
install -m 644 etc/oversip.conf debian/oversip/etc/oversip/
|
31
|
-
install -m 644 etc/proxies.conf debian/oversip/etc/oversip/
|
32
|
-
install -m 644 etc/logic.rb debian/oversip/etc/oversip/
|
33
|
-
install -m 644 etc/websocket_policy.rb debian/oversip/etc/oversip/
|
34
|
-
install -m 755 etc/tls/upgrade-cacert.sh debian/oversip/etc/oversip/tls/
|
35
|
-
install -m 644 etc/tls/demo-tls.oversip.net.crt debian/oversip/etc/oversip/tls/
|
36
|
-
install -m 600 etc/tls/demo-tls.oversip.net.key debian/oversip/etc/oversip/tls/
|
37
|
-
install -m 644 etc/tls/ca/* debian/oversip/etc/oversip/tls/ca/
|
38
|
-
install -m 755 etc/tls/utils/* debian/oversip/etc/oversip/tls/utils/
|
39
|
-
|
40
|
-
# Build architecture-dependent files here.
|
41
|
-
binary-arch: install
|
42
|
-
# We have nothing to do by default.
|
43
|
-
|
44
|
-
# Build architecture-independent files here.
|
45
|
-
binary-indep: install
|
46
|
-
dh_testdir
|
47
|
-
dh_testroot
|
48
|
-
dh_installchangelogs
|
49
|
-
dh_installdocs
|
50
|
-
dh_installexamples
|
51
|
-
dh_installman
|
52
|
-
dh_installinit --restart-after-upgrade -- defaults 20
|
53
|
-
dh_link
|
54
|
-
dh_strip
|
55
|
-
dh_compress
|
56
|
-
dh_fixperms
|
57
|
-
dh_installcron
|
58
|
-
# dh_makeshlibs
|
59
|
-
dh_installdeb
|
60
|
-
dh_shlibdeps
|
61
|
-
dh_gencontrol
|
62
|
-
dh_md5sums
|
63
|
-
dh_builddeb
|
64
|
-
|
65
|
-
binary: binary-indep binary-arch
|
66
|
-
.PHONY: build clean binary-indep binary-arch binary install
|