55 lines
1.3 KiB
Ruby
55 lines
1.3 KiB
Ruby
# Configuration for L4D2 server paths
|
|
module L4dServer
|
|
class Config
|
|
class << self
|
|
# Base directory for all L4D2 server files
|
|
def base_path
|
|
@base_path ||= ENV.fetch("L4D2_BASE_PATH", "/opt/l4d2")
|
|
end
|
|
|
|
def base_path=(path)
|
|
@base_path = path
|
|
end
|
|
|
|
# Directory containing the base L4D2 installation
|
|
def installation_path
|
|
File.join(base_path, "installation")
|
|
end
|
|
|
|
# Directory containing overlay filesystems
|
|
def overlays_path
|
|
File.join(base_path, "overlays")
|
|
end
|
|
|
|
# Directory containing individual server instances
|
|
def servers_path
|
|
File.join(base_path, "servers")
|
|
end
|
|
|
|
# Directory containing helper scripts (start-server, stop-server)
|
|
def bin_path
|
|
File.join(base_path, "bin")
|
|
end
|
|
|
|
# Full path to a specific server directory
|
|
def server_path(server_id)
|
|
File.join(servers_path, server_id.to_s)
|
|
end
|
|
|
|
# Full path to a specific overlay directory
|
|
def overlay_path(slug)
|
|
File.join(overlays_path, slug)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
systemd_user_dir = File.expand_path("~/.config/systemd/user")
|
|
|
|
unless Dir.exist?(systemd_user_dir)
|
|
begin
|
|
FileUtils.mkdir_p(systemd_user_dir)
|
|
rescue => e
|
|
Rails.logger.warn("Could not create systemd user directory: #{e.message}")
|
|
end
|
|
end
|