bin/oversip in oversip-1.0.5 vs bin/oversip in oversip-1.0.6.beta1

- old
+ new

@@ -1,12 +1,18 @@ #!/usr/bin/ruby # -*- encoding: binary -*- unless RUBY_VERSION >= "1.9.2" - raise LoadError, "OverSIP requires Ruby version >= 1.9.2 (current version is #{RUBY_VERSION})" + raise ::LoadError, "OverSIP requires Ruby version >= 1.9.2 (current version is #{RUBY_VERSION})" end +# When OverSIP is executed automaticaly via the system init (i.e. after booting the host) +# the Encoding.default_external is US_ASCII which causes fails when reading daat from +# some files (i.e. the cacert.pem file which contains no valid US_ASCII symbols). So +# make the default external encoding UTF-8 right now. +::Encoding.default_external = ::Encoding::UTF_8 + # First of all, trap some signals in order to ignore them if they arrive while # loading server libraries. [:HUP, :INT, :USR1, :USR2].each {|signal| trap(signal) {} } require "optparse" @@ -71,11 +77,11 @@ opts.on("--remove-mqueue MQUEUE", "Destroy the Posix Message Queue with the given name and exit") do |value| require "posix_mq" begin - POSIX_MQ.unlink value + ::POSIX_MQ.unlink value rescue ::Errno::ENOENT rescue ::Errno::EACCES => e fatal "cannot remove '#{value}' posix message queue due file permissions" exit 1 rescue ::Errno::EINVAL => e @@ -139,27 +145,27 @@ unless options[:pid_file] fatal "PID file is required (use -P or --pid option)" end # Ignore user/group if the launcher is not being running as root. - unless Process.euid == 0 + unless ::Process.euid == 0 log_system_warn "ignoring user/group parameters when not running as root" options.delete :user options.delete :group else # Get the uid and gid to run with. if options[:user] begin - Etc.getpwnam options[:user] - rescue ArgumentError + ::Etc.getpwnam options[:user] + rescue ::ArgumentError fatal "user '#{options[:user]}' does not exist in the system" end end if options[:group] begin - Etc.getgrnam options[:group] - rescue ArgumentError + ::Etc.getgrnam options[:group] + rescue ::ArgumentError fatal "group '#{options[:group]}' does not exist in the system" end end end @@ -168,24 +174,24 @@ fatal "num_instances #{n} is not a valid value (must be greater than 0)" end # Set the command name (as it appears in "ps" output) to given --process_name option (-p) # or to the script filename otherwise. - $0 = options[:process_name] || File.basename(__FILE__) + $0 = options[:process_name] || ::File.basename(__FILE__) - OverSIP.master_name = $0 - log_system_info "master process name: #{OverSIP.master_name}" + ::OverSIP.master_name = $0 + log_system_info "master process name: #{::OverSIP.master_name}" - OverSIP::Config.load options[:config_dir], options[:config_file] + ::OverSIP::Config.load options[:config_dir], options[:config_file] log_system_info "applied configuration:" - OverSIP::Config.print options[:colorize] + ::OverSIP::Config.print options[:colorize] log_system_info "creating Posix Message Queue for communicating master and syslogger processes" - OverSIP::Logger.init_logger_mq options[:num_instances], options[:group] - OverSIP::Logger.load_methods + ::OverSIP::Logger.init_logger_mq options[:num_instances], options[:group] + ::OverSIP::Logger.load_methods - OverSIP::Launcher.daemonize!(options) - OverSIP::Launcher.run(options) + ::OverSIP::Launcher.daemonize!(options) + ::OverSIP::Launcher.run(options) end # def run end # class Executable end # module OverSIP