Revision ad8bb0c7
Added by Greg Sutcliffe almost 12 years ago
- ID ad8bb0c7f0b5f142093a8fcbd6cc64bc8d430fd9
bin/smart-proxy | ||
---|---|---|
$LOAD_PATH.unshift *Dir["#{File.dirname(__FILE__)}/../lib"]
|
||
APP_ROOT = "#{File.dirname(__FILE__)}/.."
|
||
|
||
require "rubygems"
|
||
require "checks"
|
||
require "rubygems" if USE_GEMS
|
||
require "proxy"
|
||
require "sinatra-patch"
|
||
require "json"
|
||
... | ... | |
|
||
set :root, APP_ROOT
|
||
set :views, APP_ROOT + '/views'
|
||
set :public, APP_ROOT + '/public'
|
||
set :logging, true
|
||
set :env, :production
|
||
set :run, true
|
||
|
||
# This changed in later Sinatra versions
|
||
if ( Sinatra::VERSION.split('.').map{|s|s.to_i} <=> [1,3,0] ) > 0
|
||
set :public_folder, APP_ROOT + '/public'
|
||
else
|
||
set :public, APP_ROOT + '/public'
|
||
end
|
||
|
||
require "tftp_api" if SETTINGS.tftp
|
||
require "puppet_api" if SETTINGS.puppet
|
||
require "puppetca_api" if SETTINGS.puppetca
|
extra/debian/init.d | ||
---|---|---|
# 2 if daemon could not be started
|
||
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|
||
|| return 1
|
||
export USE_GEMS=false # No need for rubygems here
|
||
start-stop-daemon --start --quiet --chuid $DAEMON_USER --pidfile $PIDFILE --exec $DAEMON -- \
|
||
$DAEMON_ARGS \
|
||
|| return 2
|
lib/checks.rb | ||
---|---|---|
# included in various places, to check the ruby environment
|
||
|
||
# Test for 1.9
|
||
if (RUBY_VERSION.split('.').map{|s|s.to_i} <=> [1,9,0]) > 0 then
|
||
PLATFORM = RUBY_PLATFORM
|
||
RUBY_1_9 = true
|
||
else
|
||
RUBY_1_9 = false
|
||
end
|
||
|
||
# Don't load rubygems in production, it's for developers
|
||
USE_GEMS = ENV['USE_GEMS'] == "false" ? false : true
|
lib/proxy.rb | ||
---|---|---|
MODULES = %w{dns dhcp tftp puppetca puppet}
|
||
VERSION = "0.3.1"
|
||
|
||
require "checks"
|
||
require "proxy/settings"
|
||
require "fileutils"
|
||
require "pathname"
|
||
require "rubygems" # required for testing
|
||
require "rubygems" if USE_GEMS # required for testing
|
||
require "proxy/log"
|
||
require "proxy/util"
|
||
require "proxy/tftp" if SETTINGS.tftp
|
lib/proxy/dhcp/server/isc.rb | ||
---|---|---|
end
|
||
|
||
def report msg, response=""
|
||
if response.nil? or !response.grep(/can't|no more|not connected|Syntax error/).empty?
|
||
if response.nil? or (!response.empty? and !response.grep(/can't|no more|not connected|Syntax error/).empty?)
|
||
logger.error "Omshell failed:\n" + (response.nil? ? "No response from DHCP server" : response.join(", "))
|
||
msg.sub! /Removed/, "remove"
|
||
msg.sub! /Added/, "add"
|
lib/proxy/dhcp/server/native_ms.rb | ||
---|---|---|
require 'rubygems'
|
||
require 'checks'
|
||
require 'rubygems' if USE_GEMS
|
||
require 'win32/open3'
|
||
|
||
module Proxy::DHCP
|
lib/proxy/dhcp/subnet.rb | ||
---|---|---|
require 'checks'
|
||
require 'ipaddr'
|
||
require 'proxy/dhcp/monkey_patches' unless IPAddr.new.respond_to?('to_range')
|
||
require 'ping'
|
||
require 'ping' unless RUBY_1_9
|
||
require 'proxy/validations'
|
||
require "net/ping"
|
||
require 'net/ping'
|
||
|
||
module Proxy::DHCP
|
||
# Represents a DHCP Subnet
|
Also available in: Unified diff
Changes for Ruby 1.8/9 compatibilty, and Debian packaging guidelines