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-1.10.3 bin/filbunked
filbunke-1.10.2 bin/filbunked
filbunke-1.10.1 bin/filbunked
filbunke-1.10.0 bin/filbunked
filbunke-1.9.2 bin/filbunked
filbunke-1.9.1 bin/filbunked
filbunke-1.9.0 bin/filbunked
filbunke-1.8.4 bin/filbunked
filbunke-1.8.3 bin/filbunked
filbunke-1.8.2 bin/filbunked
filbunke-1.8.1 bin/filbunked
filbunke-1.8.0 bin/filbunked
filbunke-1.7.3 bin/filbunked
filbunke-1.7.2 bin/filbunked
filbunke-1.7.1 bin/filbunked
filbunke-1.7.0 bin/filbunked