Sha256: 620a8f1c58b55482f24196d67380e61a4793857f3e0a7885ee5cce564a228ee8

Contents?: true

Size: 1.14 KB

Versions: 36

Compression:

Stored size: 1.14 KB

Contents

#!/usr/bin/env ruby
$0=File.join(File.dirname(__FILE__), 'filbunked')
require 'rubygems'
require 'yaml'
require 'getoptlong'

raw_opts = GetoptLong.new(
        [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
        [ '--config', '-c', GetoptLong::REQUIRED_ARGUMENT ],
        [ '--dev', '-d', GetoptLong::NO_ARGUMENT]
)

opts = {}
raw_opts.each do |opt, arg|
  opts[opt] = arg
end

if opts['--help'] || opts['--config'] == nil || opts['--config'] == ""
  puts "Usage: filbunked -c <config_file.yml>"
  exit 1
else
  if opts['--dev'] then
    require 'lib/filbunke.rb'
    
    config_file = File.read(opts['--config'])
    config = YAML.load(config_file)
    daemon = Filbunke::Daemon.new(config, true)
    
    daemon.run!    
  else
    if Process.uid != 0 then
      puts "Filbunke should be started as root!"
      exit 1
    end
    
    require 'filbunke'
    child_process = fork {
      config_file = File.read(opts['--config'])
      config = YAML.load(config_file)
      daemon = Filbunke::Daemon.new(config)
      Process::UID.change_privilege(Etc.getpwnam(config["user"]).uid)
      daemon.run!
    }
    Process.detach(child_process)
    
  end
  

end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
filbunke-2.1.7 bin/filbunked
filbunke-2.1.6 bin/filbunked
filbunke-2.1.4 bin/filbunked
filbunke-1.13.5 bin/filbunked
filbunke-1.13.4 bin/filbunked
filbunke-2.1.3 bin/filbunked
filbunke-2.1.2 bin/filbunked
filbunke-1.13.3 bin/filbunked
filbunke-1.13.2 bin/filbunked
filbunke-1.13.1 bin/filbunked
filbunke-2.1.0 bin/filbunked
filbunke-1.13.0 bin/filbunked
filbunke-1.12.0 bin/filbunked
filbunke-1.11.9 bin/filbunked
filbunke-2.0.9 bin/filbunked
filbunke-1.11.8 bin/filbunked
filbunke-2.0.8 bin/filbunked
filbunke-2.0.6 bin/filbunked
filbunke-1.11.6 bin/filbunked
filbunke-2.0.2 bin/filbunked