diff --git a/lib/gems/pending/appliance_console/internal_database_configuration.rb b/lib/gems/pending/appliance_console/internal_database_configuration.rb index 2b4be1e76..017e983e2 100644 --- a/lib/gems/pending/appliance_console/internal_database_configuration.rb +++ b/lib/gems/pending/appliance_console/internal_database_configuration.rb @@ -3,6 +3,7 @@ require "pathname" require "util/postgres_admin" require "pg" +require "linux_admin" RAILS_ROOT ||= Pathname.new(__dir__).join("../../../") @@ -67,6 +68,9 @@ def ask_questions def choose_disk @disk = ask_for_disk("database disk") + error_message = "The disk for database must be a mount point" + raise error_message unless disk || pg_mount_point? + disk end def initialize_postgresql_disk @@ -108,7 +112,7 @@ def post_activation private def mount_point - Pathname.new(ENV.fetch("APPLIANCE_PG_MOUNT_POINT")) + PostgresAdmin.mount_point end def copy_template(src, src_dir = self.class.postgresql_template, dest_dir = PostgresAdmin.data_directory) @@ -121,6 +125,10 @@ def copy_template(src, src_dir = self.class.postgresql_template, dest_dir = Post end end + def pg_mount_point? + LinuxAdmin::LogicalVolume.mount_point_exists?(mount_point) + end + def run_initdb AwesomeSpawn.run!("service", :params => {nil => [PostgresAdmin.service_name, "initdb"]}) end