2023-11-23 23:20:16 +00:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#
|
|
|
|
# SPDX-FileCopyrightText: 2023 Glenn Y. Rolland <glenux@glenux.net>
|
|
|
|
# Copyright © 2023 Glenn Y. Rolland <glenux@glenux.net>
|
|
|
|
|
|
|
|
require "yaml"
|
|
|
|
require "./abstract_filesystem_config"
|
|
|
|
|
|
|
|
module GX::Models
|
2023-11-24 09:25:30 +00:00
|
|
|
class InvalidEnvironmentError < Exception
|
|
|
|
end
|
|
|
|
|
2023-11-23 23:20:16 +00:00
|
|
|
class GlobalConfig
|
|
|
|
include YAML::Serializable
|
|
|
|
include YAML::Serializable::Strict
|
|
|
|
|
2023-11-24 09:49:55 +00:00
|
|
|
@[YAML::Field(key: "mount_point_base")]
|
|
|
|
getter mount_point_base : String?
|
2023-11-23 23:20:16 +00:00
|
|
|
|
2024-01-14 19:31:38 +00:00
|
|
|
def after_initialize
|
2023-11-24 09:25:30 +00:00
|
|
|
raise InvalidEnvironmentError.new("Home directory not found") if !ENV["HOME"]?
|
|
|
|
home_dir = ENV["HOME"]
|
2023-11-23 23:20:16 +00:00
|
|
|
|
|
|
|
# Set default mountpoint from global if none defined
|
2023-11-24 09:49:55 +00:00
|
|
|
if @mount_point_base.nil? || @mount_point_base.try &.empty?
|
|
|
|
@mount_point_base = File.join(home_dir, "mnt")
|
2023-11-23 23:20:16 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|