attr_accessor :distribution_list
attr_accessor :sync_interval, :passwd
+ # constant
+ SERVER_ROOT = "#{PackageServerConfig::CONFIG_ROOT}/pkg_server"
+ LOCK_FILE = "#{SERVER_ROOT}/.server_loc"
+ AUTO_SYNC_CHK_FILE = "#{SERVER_ROOT}/auto_sync"
+
# initialize
def initialize (id)
@location = ""
update_config_information(id)
- if not File.exist?( PackageServerConfig::SERVER_ROOT )
- FileUtils.mkdir_p( PackageServerConfig::SERVER_ROOT )
+ if not File.exist?( SERVER_ROOT )
+ FileUtils.mkdir_p( SERVER_ROOT )
end
@log = PackageServerLog.new( @log_file_path )
end
# create locking file
- @lock_file = Utils.file_lock(PackageServerConfig::LOCK_FILE)
+ @lock_file = Utils.file_lock(LOCK_FILE)
# create server config directory
FileUtils.mkdir_p @config_dir
end
def add_distribution( dist_name, server_url, clone )
- @lock_file = Utils.file_lock(PackageServerConfig::LOCK_FILE)
+ @lock_file = Utils.file_lock(LOCK_FILE)
# error check : check for already exist in server directory
if @dist_to_server_url.keys.include? dist_name.strip then
def remove_server()
@log.info( "Package server [#{@id}] will be removed and all server information delete", Log::LV_USER)
- @lock_file = Utils.file_lock(PackageServerConfig::LOCK_FILE)
+ @lock_file = Utils.file_lock(LOCK_FILE)
if File.exist? @config_file_path then
File.open @config_file_path do |f|
f.each_line do |l|
@log.info "remove distribution in server"
distribution = get_distribution( dist_name )
- @lock_file = Utils.file_lock(PackageServerConfig::LOCK_FILE)
+ @lock_file = Utils.file_lock(LOCK_FILE)
# modify config file
config_file = File.readlines(@config_file_path)
@log.info "package remove in server"
distribution = get_distribution( dist_name )
- @lock_file = Utils.file_lock(PackageServerConfig::LOCK_FILE)
+ @lock_file = Utils.file_lock(LOCK_FILE)
distribution.remove_pkg(pkg_name_list, os, recursive)
@log.info "remove snapshot in server"
distribution = get_distribution( dist_name )
- @lock_file = Utils.file_lock(PackageServerConfig::LOCK_FILE)
+ @lock_file = Utils.file_lock(LOCK_FILE)
distribution.remove_snapshot(snapshot_list)
@log.info "pakcage server clean"
distribution = get_distribution( dist_name )
- @lock_file = Utils.file_lock(PackageServerConfig::LOCK_FILE)
+ @lock_file = Utils.file_lock(LOCK_FILE)
distribution.clean( snapshot_list )
end
def self.list_id
- @@log = PackageServerLog.new( "#{PackageServerConfig::SERVER_ROOT}/.log" )
+ @@log = PackageServerLog.new( "#{SERVER_ROOT}/.log" )
- d = Dir.new( PackageServerConfig::SERVER_ROOT )
+ d = Dir.new( SERVER_ROOT )
s = d.select {|f| not f.start_with?(".") }
s.sort!
end
def self.list_dist( id )
- @@log = PackageServerLog.new( "#{PackageServerConfig::SERVER_ROOT}/.log" )
+ @@log = PackageServerLog.new( "#{SERVER_ROOT}/.log" )
@@log.output( "=== ID [#{id}]'s distribution list ===", Log::LV_USER)
# read package id information
- config_file_path = "#{PackageServerConfig::SERVER_ROOT}/#{id}/config"
+ config_file_path = "#{SERVER_ROOT}/#{id}/config"
if not File.exist? config_file_path
raise RuntimeError, "[#{id}] is not server ID"
end
def reload_dist_package()
# create locking file
- @lock_file = Utils.file_lock(PackageServerConfig::LOCK_FILE)
+ @lock_file = Utils.file_lock(LOCK_FILE)
@distribution_list.each do |dist|
dist.initialize_pkg_list
end
def server_information_initialize
# if id is nil or empty then find default id
if @id.nil? or @id.empty?
- d = Dir.new( PackageServerConfig::SERVER_ROOT )
+ d = Dir.new( SERVER_ROOT )
s = d.select {|f| not f.start_with?(".") }
if s.length.eql? 1 then
@log.info "using default server ID [#{s[0]}]"
def update_config_information(id)
@id = id
- @config_dir = "#{PackageServerConfig::SERVER_ROOT}/#{@id}"
- @log_file_path = "#{PackageServerConfig::SERVER_ROOT}/#{@id}.log"
+ @config_dir = "#{SERVER_ROOT}/#{@id}"
+ @log_file_path = "#{SERVER_ROOT}/#{@id}.log"
@config_file_path = "#{@config_dir}/config"
@incoming_path = "#{@config_dir}/incoming"
end